Created
June 11, 2017 21:21
-
-
Save ejfox/e3409f05fd34c1531bd304fe77725a19 to your computer and use it in GitHub Desktop.
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 'fs' | |
d3 = require 'd3' | |
d3Node = require 'd3-node' | |
canvasModule = require 'canvas-prebuilt' | |
randGen = require 'random-seed' | |
rand = new randGen() | |
seed = Date.now() | |
rand.seed(seed) | |
d3n = new d3Node { canvasModule } | |
canvas = d3n.createCanvas 500,500 | |
ctx = canvas.getContext '2d' | |
width = canvas.width | |
height = canvas.height | |
data = d3.range(20).map -> | |
{ | |
x: rand(width) | |
y: rand(height) | |
} | |
data.forEach((d,i) -> | |
ctx.beginPath() | |
ctx.rect d.x, d.y, 10, 10 | |
ctx.fillStyle = 'red' | |
ctx.fill() | |
ctx.closePath() | |
) | |
require('../lib/output.js')(seed, d3n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment