made with requirebin
Last active
August 29, 2015 14:05
-
-
Save tmcw/236aaf7b579e3ecbf961 to your computer and use it in GitHub Desktop.
requirebin sketch
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
var color = require('fischer-color'); | |
var canvas = document.createElement('canvas'); | |
document.body.appendChild(canvas); | |
var w = 314, h = 100; | |
canvas.width = w; | |
canvas.height = h; | |
var ctx = canvas.getContext('2d'); | |
canvas.style.cssText = 'width:400px;height:200px;'; | |
var image = ctx.getImageData(0, 0, w, h); | |
for (var i = 0, j = -1, c; i < w * h; ++i) { | |
c = color.interpolate((i % w)/100, 1, Math.floor(i/w)/100); | |
image.data[++j] = c[0]; | |
image.data[++j] = c[1]; | |
image.data[++j] = c[2]; | |
image.data[++j] = 255; | |
} | |
ctx.putImageData(image, 0, 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
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({"fischer-color":[function(require,module,exports){module.exports.interpolate=function interpolate(h,c,l){"use strict";if(Array.isArray(h)){c=h[1];l=h[2];h=h[0]}h=h+(Math.PI/2-(Math.PI-2));if(c>1-2*Math.abs(l-.5)){c=1-2*Math.abs(l-.5)}var r1=Math.sin(h+Math.PI-2)*.417211*c+l,g1=Math.sin(h+Math.PI+1.5)*.158136*c+l,b1=Math.sin(h+Math.PI)*.455928*c+l;return[Math.exp(Math.log(r1*.923166+.0791025)*1.25)*255,Math.exp(Math.log(g1*.923166+.0791025)*1.25)*255,Math.exp(Math.log(b1*.923166+.0791025)*1.25)*255]}},{}]},{},[]);var color=require("fischer-color");var canvas=document.createElement("canvas");document.body.appendChild(canvas);var w=314,h=100;canvas.width=w;canvas.height=h;var ctx=canvas.getContext("2d");canvas.style.cssText="width:400px;height:200px;";var image=ctx.getImageData(0,0,w,h);for(var i=0,j=-1,c;i<w*h;++i){c=color.interpolate(i%w/100,1,Math.floor(i/w)/100);image.data[++j]=c[0];image.data[++j]=c[1];image.data[++j]=c[2];image.data[++j]=255}ctx.putImageData(image,0,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
{ | |
"name": "requirebin-sketch", | |
"version": "1.0.0", | |
"dependencies": { | |
"fischer-color": "0.0.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
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; } | |
body, html { height: 100%; width: 100%; }</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment