Skip to content

Instantly share code, notes, and snippets.

View andrewrcollins's full-sized avatar

Andrew Collins andrewrcollins

View GitHub Profile
@wayneashleyberry
wayneashleyberry / color.php
Created October 17, 2012 14:06
php color manipulation
<?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] );
<?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);
@blinkov
blinkov / jquery.favicon.js
Created April 6, 2012 15:22
jQuery Favicon Plugin
/**
* 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
*
*
@rogerlsmith
rogerlsmith / ColorTime.php
Created November 4, 2011 14:57
PHP Code that will convert time to RGB color using HSV
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);
}
@atomizer
atomizer / bezier.js
Created June 27, 2011 20:23
de Casteljau's algorithm in javascript
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];
}
}
@dwiash
dwiash / gist:764969
Created January 4, 2011 16:08
mixcolor.php
<style>
pre{
margin: 0;
padding: 7px 0;
}
</style>
<?php
function rgb2hsv ($RGB)
{
@cheeaun
cheeaun / color.php
Created October 2, 2009 08:30
Color class for Kohana
<?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){