コード例 #1
0
ファイル: cssStyle.php プロジェクト: ibit-sol/CSS_GENERATOR
         } else {
             echo '.icone .icone-' . $i . ' {' . "\n\t" . 'width: ' . $this->size . 'px;' . "\n\t" . 'height: ' . $this->size . 'px;' . "\n\t" . 'background-position: -' . $this->size * $i . 'px 0px;' . "\n" . '}' . "\n\n";
         }
     }
 } else {
     $x_array = array(0);
     $y_array = array(0);
     for ($i = 0; $i <= count($x_png); $i++) {
         $x_array[] = $x_png[$i] + $x_array[$i - 1];
         $y_array[] = $y_png[$i] + $y_array[$i - 1];
     }
     echo 'body {' . "\n\t";
     if (!empty($this->padding)) {
         echo 'padding-bottom: ' . $this->padding . 'px;' . "\n\t" . 'margin: 0px;' . "\n";
     }
     echo '}' . "\n\n" . '.icone {' . "\n\t" . 'width: ' . get_colums($x_png, $this->colums) . 'px;' . "\n\t" . 'height: ' . get_colums($y_png, $this->colums) * $this->colums . 'px;' . "\n\t" . 'display: block;' . "\n\t" . 'padding-left: 0px;' . "\n" . '}' . "\n\n" . '.colums {' . "\n\t" . 'width: ' . (get_colums($x_png, $this->colums) + 50) . 'px;' . "\n\t" . 'height: ' . max($y_png) . 'px;' . "\n\t" . 'display: block;' . "\n" . '}' . "\n\n" . '.icone li{' . "\n\t" . 'display: inline-block;' . "\n\t" . 'background: url("' . $png_name . '") no-repeat;' . "\n" . '}' . "\n\n";
     $k = 0;
     $j = $this->columns;
     $l = 0;
     for ($i = 1; $i <= count($x_png); $i++) {
         if ($j == $i - 1) {
             if ($k == $this->colums) {
                 $l++;
                 $k = 0;
             }
             echo '.icone .icone-' . $i . ' {' . "\n\t" . 'width: ' . $x_png[$i - 1] . 'px;' . "\n\t" . 'height: ' . $y_png[$i - 1] . 'px;' . "\n\t" . 'background-position: -' . $x_array[$k] . 'px -' . $y_array[$l] . 'px;' . "\n" . '}' . "\n\n";
             $k++;
             $j++;
         } else {
             echo '.icone .icone-' . $i . ' {' . "\n\t" . 'width: ' . $this->size . 'px;' . "\n\t" . 'height: ' . $this->size . 'px;' . "\n\t" . 'background-position: -' . $this->size * $i . 'px 0px;' . "\n" . '}' . "\n\n";
         }
function echo_table($table_name, $condition = '', $colums = '*', $searchfields = false)
{
    echo "<table width='100%'>\n\t<tr>";
    //get alle the top item and start a loop
    $titles = get_colums($table_name, $colums);
    foreach ($titles as $name => $item) {
        //display the item
        echo "\t\t<th style='text-align:center;'>" . $item . "</th>";
    }
    echo "</tr>";
    $table = table_array($table_name, $condition, $colums);
    //diplay all sub items()
    foreach ($table as $i => $row) {
        echo "<tr>\n";
        foreach ($row as $j => $item) {
            echo "\t<td>" . $item . "</td>\n";
        }
        echo "</tr>\n";
    }
    $previous = $page['id'];
    echo "</table>";
}
コード例 #3
0
 public function spriteToPng($array_png, $png_name)
 {
     foreach ($array_png as $key => $value) {
         $this->x_png[$key] = imagesx($array_png[$key]);
         $this->y_png[$key] = imagesy($array_png[$key]);
     }
     $x = max($this->x_png);
     $x_colums = get_colums($this->x_png, $this->colums);
     $y = array_sum($this->y_png);
     $y_colums = get_colums($this->y_png, $this->colums);
     if (!empty($this->size)) {
         if (!empty($this->colums)) {
             $img = imagecreatetruecolor($this->size * $this->colums, ceil(count($array_png) / $this->colums) * $this->size);
             $color = imagecolorallocatealpha($img, 0, 0, 0, 127);
             imagefill($img, 0, 0, $color);
             imagesavealpha($img, true);
         } else {
             $img = imagecreatetruecolor($this->size, $this->size * count($array_png));
             $color = imagecolorallocatealpha($img, 0, 0, 0, 127);
             imagefill($img, 0, 0, $color);
             imagesavealpha($img, true);
         }
     } else {
         if (!empty($this->colums)) {
             $img = imagecreatetruecolor($x_colums, $y_colums * $this->colums);
             $color = imagecolorallocatealpha($img, 0, 0, 0, 127);
             imagefill($img, 0, 0, $color);
             imagesavealpha($img, true);
         } else {
             $img = imagecreatetruecolor($x, $y);
             $color = imagecolorallocatealpha($img, 0, 0, 0, 127);
             imagefill($img, 0, 0, $color);
             imagesavealpha($img, true);
         }
     }
     $dst_x = 0;
     $dst_y = 0;
     $i = 0;
     foreach ($array_png as $key => $value) {
         if (!empty($this->size)) {
             if (!empty($this->colums)) {
                 imagecopyresampled($img, $array_png[$key], $dst_x, $dst_y, 0, 0, $this->size, $this->size, $this->x_png[$i], $this->y_png[$i]);
                 if (($i + 1) % $this->colums == 0) {
                     $dst_y += $this->size;
                 }
                 if (($i + 1) % $this->colums == 0) {
                     $dst_x = 0;
                 } else {
                     $dst_x += $this->size;
                 }
                 $i++;
             } else {
                 imagecopyresampled($img, $array_png[$key], 0, $dst_y, 0, 0, $this->size, $this->size, $this->x_png[$i], $this->y_png[$i]);
                 $dst_y += $this->size;
                 $i++;
             }
         } else {
             if (!empty($this->colums)) {
                 imagecopy($img, $array_png[$key], $dst_x, $dst_y, 0, 0, $this->x_png[$i], $this->y_png[$i]);
                 if (($i + 1) % $this->colums == 0) {
                     $dst_y += $this->y_png[$i];
                 }
                 if (($i + 1) % $this->colums == 0) {
                     $dst_x = 0;
                 } else {
                     $dst_x += $this->x_png[$i];
                 }
                 $i++;
             } else {
                 imagecopy($img, $array_png[$key], 0, $dst_y, 0, 0, $this->x_png[$i], $this->y_png[$i]);
                 $dst_y += $this->y_png[$i];
                 $i++;
             }
         }
     }
     if (file_exists('images_create/' . $png_name)) {
         unlink('images_create/' . $png_name);
         imagepng($img, 'images_create/' . $png_name);
     } else {
         imagepng($img, 'images_create/' . $png_name);
     }
     $this->css->convertToCss($this->x_png, $this->y_png, $x, $y, $png_name);
 }