Skip to content

Instantly share code, notes, and snippets.

View andrewrcollins's full-sized avatar

Andrew Collins andrewrcollins

View GitHub Profile
@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){
@dwiash
dwiash / gist:764969
Created January 4, 2011 16:08
mixcolor.php
<style>
pre{
margin: 0;
padding: 7px 0;
}
</style>
<?php
function rgb2hsv ($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];
}
}
@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);
}
@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
*
*
<?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);
@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] );
@abbotto
abbotto / dominant_color.php
Created October 26, 2012 16:03
Get The Dominant Color Of Any Image.
<?
// 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;
@nkcmr
nkcmr / hsl2hex.php
Created December 11, 2012 14:51
HSL to HEX triplet algorithm
<?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;
@h4cc
h4cc / satis_install.sh
Last active February 13, 2024 16:39
Guide to install a satis server for composer. It can mirror packages and create a index for own packages.
# 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