/** * Draw a an (optionally filled) circle on an $image * * @param resource $image * @param int $x * @param int $y * @param int|array $size * @param string $fill * @param string|int $outline */ static function drawCircle($image, $x, $y, $size, $fill, $outline) { if (!empty($fill)) { $fill = CoreUtils::hex2Rgb($fill); $fill = imagecolorallocate($image, $fill[0], $fill[1], $fill[2]); } if (is_string($outline)) { $outline = CoreUtils::hex2Rgb($outline); $outline = imagecolorallocate($image, $outline[0], $outline[1], $outline[2]); } if (is_array($size)) { $width = $size[0]; $height = $size[1]; $x2 = $x + $width; $y2 = $y + $height; } else { $x2 = $x + $size; $y2 = $y + $size; $width = $height = $size; } $cx = CoreUtils::average($x, $x2); $cy = CoreUtils::average($y, $y2); if (isset($fill)) { imagefilledellipse($image, $cx, $cy, $width, $height, $fill); } imageellipse($image, $cx, $cy, $width, $height, $outline); }
static function getSwatchesInkscape($Appearance) { $label = $Appearance['label']; $exportts = gmdate('Y-m-d H:i:s \\G\\M\\T'); $File = <<<GPL GIMP Palette Name: {$label} Columns: 6 # # Exported at: {$exportts} # GPL; $CGs = ColorGroups::get($Appearance['id']); $Colors = ColorGroups::getColorsForEach($CGs); foreach ($CGs as $cg) { foreach ($Colors[$cg['groupid']] as $c) { $rgb = CoreUtils::hex2Rgb($c['hex']); $File .= CoreUtils::pad($rgb[0], 3, ' ') . ' ' . CoreUtils::pad($rgb[1], 3, ' ') . ' ' . CoreUtils::pad($rgb[2], 3, ' ') . ' ' . $cg['label'] . ' | ' . $c['label'] . PHP_EOL; } } CoreUtils::downloadFile(rtrim($File), "{$label}.gpl"); }