This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
class Color { | |
public static function hex_to_rgb($hex){ | |
$pattern = '/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/'; | |
preg_match($pattern, $hex, $matches); | |
$matches = array_slice($matches, 1); | |
if (!function_exists('map')){ | |
function map($value){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
pre{ | |
margin: 0; | |
padding: 7px 0; | |
} | |
</style> | |
<?php | |
function rgb2hsv ($RGB) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bezier(pts) { | |
return function (t) { | |
for (var a = pts; a.length > 1; a = b) // do..while loop in disguise | |
for (var i = 0, b = [], j; i < a.length - 1; i++) // cycle over control points | |
for (b[i] = [], j = 0; j < a[i].length; j++) // cycle over dimensions | |
b[i][j] = a[i][j] * (1 - t) + a[i+1][j] * t; // interpolation | |
return a[0]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getColor() | |
{ | |
$tod = localtime(); | |
$now = $tod[1] + ($tod[2] * 60.0); | |
$now = $now * (1.0 / (24.0 * 60.0)); | |
$rgb_array = HSV_TO_RGB($now, 0.5, 0.5); | |
$rgb = dechex($rgb_array['R']) . dechex($rgb_array['G']) . dechex($rgb_array['B']); | |
return ($rgb); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* jQuery Favicon plugin | |
* http://hellowebapps.com/products/jquery-favicon/ | |
* | |
* Copyright (c) 2010 Volodymyr Iatsyshyn ([email protected]) | |
* Dual licensed under the MIT and GPL licenses: | |
* http://www.opensource.org/licenses/mit-license.php | |
* http://www.gnu.org/licenses/gpl.html | |
* | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Some_Class_To_Parse_Colors_From_Images | |
{ | |
function logo() | |
{ | |
$src = 'public/dummy/logo2.png'; | |
$im = imagecreatefrompng(ROOT . $src); | |
$w0 = imagesx($im); | |
$h0 = imagesy($im); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function hex2rgb( $col ) { | |
if ( $col[0] == '#' ) { | |
$col = substr( $col, 1 ); | |
} | |
if (strlen( $col ) == 6) { | |
list( $r, $g, $b ) = array( $col[0] . $col[1], $col[2] . $col[3], $col[4] . $col[5] ); | |
} elseif (strlen( $col ) == 3) { | |
list( $r, $g, $b ) = array( $col[0] . $col[0], $col[1] . $col[1], $col[2] . $col[2] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// Point the script to an image and get its dominant color. | |
$i = imagecreatefromjpeg("image.jpg"); | |
for ($x=0;$x<imagesx($i);$x++) { | |
for ($y=0;$y<imagesy($i);$y++) { | |
$rgb = imagecolorat($i,$x,$y); | |
$r = ($rgb >> 16) & 0xFF; | |
$g = ($rgb >> & 0xFF; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function HSL2HEX($h,$s,$l){ | |
function hue2rgb($v1, $v2, $vH){ | |
if($vH<0) $vH += 1; | |
if($vH>1) $vH -= 1; | |
if((6*$vH)<1) return $v1+($v2-$v1)*6*$vH; | |
if((2*$vH)<1) return $v2; | |
if((3*$vH)<2) return $v1+($v2-$v1)*((2/3)-$vH)*6; | |
return $v1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install a Webserver | |
apt-get -y install apache2 | |
# Target docroot to /home/satis/web/ | |
# Install PHP5 CLI and needed programs. | |
apt-get -y install php5-cli php5-curl php5-json git wget | |
# Add a specifix user for our task | |
adduser satis |
OlderNewer