function draw(&$nodeList, $c) { $image = new Dm_Image(W, H, 0xff000000); $graphics = $image->graphics; $graphics->lineStyle(0)->fillStyle(0x66ffffff); for ($i = 0; $i < C; $i++) { $node =& $nodeList[$i]; $node[2] = 0; } for ($i = 0; $i < C; $i++) { $node =& $nodeList[$i]; for ($j = $i; $j < C; $j++) { if ($i == $j) { continue; } $nNode =& $nodeList[$j]; $x = $node[0] - $nNode[0]; $y = $node[1] - $nNode[1]; $diff = sqrt($x * $x + $y * $y); if ($diff < D) { $node[2] += 1; $nNode[2] += 1; $graphics->lineStyle(min(10 * (D - $diff) / D, 4), Dm_Color::argb((D - $diff) / D * 0.6 + 0.2, 255, 255, 255)->toInt())->moveTo($node[0], $node[1])->lineTo($nNode[0], $nNode[1]); } } } $graphics->lineStyle(0, 0x11ffffff); for ($i = 0; $i < C; $i++) { $node = $nodeList[$i]; $graphics->drawCircle($node[0], $node[1], 2 + $node[2] * $node[2] * 0.2); } for ($i = 0; $i < C; $i++) { $node =& $nodeList[$i]; $node[0] += $node[3]; $node[1] += $node[4]; } $count = sprintf('%05d', $c); $image->saveTo(DIR_PATH . 'img' . $count . '.gif', 'gif'); }
public function execute(Dm_Image $image) { $w = $this->width; $h = $this->height; $x = (int) (($image->getWidth() - $w) * 0.5); $y = (int) (($image->getHeight() - $h) * 0.5); $resampledResource = imagecreatetruecolor($w, $h); //背景色設定(透過を有効化) imagesavealpha($resampledResource, true); // imagealphablending($imageResource, false); $colorId = Dm_Color::argb(0)->imagecolorallocatealpha($resampledResource); // imagefilledrectangle($imageResource, 0, 0, $width-1, $height-1, $colorId); imagefill($resampledResource, 0, 0, $colorId); imagecopyresampled($resampledResource, $image->getImageResource(), 0, 0, $x, $y, $image->getWidth(), $image->getHeight(), $image->getWidth(), $image->getHeight()); return $resampledResource; }
public function execute(Dm_Image $image) { $width = $this->width; $height = $this->height; $ratio = 1; $wRatio = $width / $image->getWidth(); $hRatio = $height / $image->getHeight(); if ($wRatio > $hRatio) { $ratio = $this->bounding ? $wRatio : $hRatio; } else { $ratio = $this->bounding ? $hRatio : $wRatio; } $w = $image->getWidth() * $ratio; $h = $image->getHeight() * $ratio; $resampledResource = imagecreatetruecolor($w, $h); //背景色設定(透過を有効化) imagesavealpha($resampledResource, true); // imagealphablending($imageResource, false); $colorId = Dm_Color::argb(0)->imagecolorallocatealpha($resampledResource); // imagefilledrectangle($imageResource, 0, 0, $width-1, $height-1, $colorId); imagefill($resampledResource, 0, 0, $colorId); imagecopyresampled($resampledResource, $image->getImageResource(), 0, 0, 0, 0, $w, $h, $image->getWidth(), $image->getHeight()); return $resampledResource; }
public function execute(Dm_Image $image) { $w = $this->width; $h = $this->height; $f = (int) $this->fram; $fit = new Dm_Image_Filter_Fit($w, $h, true); $crop = new Dm_Image_Filter_Crop($w, $h); $filters = array($fit, $crop); $image->applyFilters($filters); $effectImage = new Dm_Image_File(dirname(__FILE__) . '/img/instagram_effect_01.png'); $effectImage->applyFilters($filters); $image->draw($effectImage, 0, 0, $effectImage->getWidth(), $effectImage->getHeight()); $filteredResource = $image->getImageResource(); $this->effect($filteredResource); if ($f === 1 || $f === 2 || $f === 3) { $frameImage = new Dm_Image_File(dirname(__FILE__) . '/img/frame_' . str_pad($f, 2, '0', STR_PAD_LEFT) . '.png'); $frameImage->applyFilters($filters); $image->draw($frameImage, 0, 0, $frameImage->getWidth(), $frameImage->getHeight()); } $image->setImageResource($filteredResource); return $filteredResource; }
require_once $DmDirPath.'Dm/Image/Graphic/Shape.php'; require_once $DmDirPath.'Dm/Image/File.php'; require_once $DmDirPath.'Dm/Image/Filter/Abstract.php'; require_once $DmDirPath.'Dm/Image/Filter/Fit.php'; require_once $DmDirPath.'Dm/Image/Filter/Crop.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramNormal.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramLoFi.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramWalden.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramToaster.php'; */ //------------------------------------ // エラー出力(ここは必要に応じて) //------------------------------------ ini_set('display_errors', 'on'); error_reporting(-1); set_error_handler('onError'); function onError($errno, $errstr, $errfile, $errline) { var_dump($errno, $errstr, $errfile, $errline); exit; } //------------------------------------ // サンプル //------------------------------------ $image = new Dm_Image(400, 300, 0xff0099ff); $image->textGraphics->setColor(0xffffffff)->setFontSize(30)->textTo(80, 150, 'Hello world.'); $image->saveTo(dirname(__FILE__) . '/saved_image.png'); $image->saveTo(dirname(__FILE__) . '/saved_image.jpg'); $image->saveTo(dirname(__FILE__) . '/saved_image.jpeg'); $image->saveTo(dirname(__FILE__) . '/saved_image.gif'); exit;
require_once $DmDirPath.'Dm/Image/Graphic/Shape.php'; require_once $DmDirPath.'Dm/Image/File.php'; require_once $DmDirPath.'Dm/Image/Filter/Abstract.php'; require_once $DmDirPath.'Dm/Image/Filter/Fit.php'; require_once $DmDirPath.'Dm/Image/Filter/Crop.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramNormal.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramLoFi.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramWalden.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramToaster.php'; */ //------------------------------------ // エラー出力(ここは必要に応じて) //------------------------------------ ini_set('display_errors', 'on'); error_reporting(-1); set_error_handler('onError'); function onError($errno, $errstr, $errfile, $errline) { var_dump($errno, $errstr, $errfile, $errline); exit; } //------------------------------------ // サンプル //------------------------------------ $color = Dm_Color::argb(1, 255, 0, 0); //RGB指定 $color->v *= 0.5; //明度を半分に(HSV) $image = new Dm_Image(400, 300, $color->toInt()); $image->display(); exit;
require_once $DmDirPath.'Dm/Image/Filter/InstagramToaster.php'; */ require_once 'SimpleGifMerge.php'; /** * Tree \ Learning \ Processing.org * http://processing.org/learning/topics/tree.html */ define('DIR_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR); define('WIDTH', 640); define('HEIGHT', 360); $merge = new SimpleGifMerge(DIR_PATH); $merge->clear(); $l = 100; for ($i = 0; $i < $l; $i++) { $theta = sin($i / $l * pi()) * 2; $image = new Dm_Image(WIDTH, HEIGHT, 0xff000000); draw(); $count = sprintf('%05d', $i); $image->saveTo(DIR_PATH . $count . '.gif', 'gif'); } $merge->merge(); function draw() { global $image; $image->graphics->lineStyle(1, 0xffffffff)->moveTo(WIDTH / 2, HEIGHT)->lineTo(WIDTH / 2, HEIGHT - 120); $h = 120; branch($h, -M_PI / 2, WIDTH / 2, HEIGHT - 120); } function branch($h, $rotate, $x, $y) { global $image, $theta;
require_once $DmDirPath.'Dm/Image.php'; require_once $DmDirPath.'Dm/Image/Graphic/Interface.php'; require_once $DmDirPath.'Dm/Image/Graphic/Text.php'; require_once $DmDirPath.'Dm/Image/Graphic/Shape.php'; require_once $DmDirPath.'Dm/Image/File.php'; require_once $DmDirPath.'Dm/Image/Filter/Abstract.php'; require_once $DmDirPath.'Dm/Image/Filter/Fit.php'; require_once $DmDirPath.'Dm/Image/Filter/Crop.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramNormal.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramLoFi.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramWalden.php'; require_once $DmDirPath.'Dm/Image/Filter/InstagramToaster.php'; */ //------------------------------------ // エラー出力(ここは必要に応じて) //------------------------------------ ini_set('display_errors', 'on'); error_reporting(-1); set_error_handler('onError'); function onError($errno, $errstr, $errfile, $errline) { var_dump($errno, $errstr, $errfile, $errline); exit; } //------------------------------------ // サンプル //------------------------------------ $image = new Dm_Image(400, 300, 0xff0099ff); $image->textGraphics->setColor(0xffffffff)->setFontSize(30)->textTo(80, 150, 'Hello world.'); $image->startDownload('download', 'jpg', 50); exit;
*/ //------------------------------------ // エラー出力(ここは必要に応じて) //------------------------------------ ini_set('display_errors', 'on'); error_reporting(-1); set_error_handler('onError'); function onError($errno, $errstr, $errfile, $errline) { var_dump($errno, $errstr, $errfile, $errline); exit; } //------------------------------------ // サンプル //------------------------------------ $image = new Dm_Image(400, 300, 0xff0099ff); ?> <!DOCTYPE html> <head> <meta charset="UTF-8" /> </head> <body> DATA SCHEME URIで表示 <br> <img src="<?php echo $image->toDataSchemeURI(); ?> "> </body>
/** * Copy and merge part of an image * @param DmImage * @param int x-coordinate of source point. * @param int y-coordinate of source point. * @param int Source width. * @param int Source height. * @return bool Returns TRUE on success or FALSE on failure. */ public function draw(Dm_Image $image, $x = 0, $y = 0, $width = null, $height = null) { $srcImageResource = $image->getImageResource(); if (is_null($width)) { $width = $image->getWidth(); } if (is_null($height)) { $height = $image->getHeight(); } return imagecopy($this->getImageResource(), $srcImageResource, $x, $y, 0, 0, $width, $height); }