Skip to content

Instantly share code, notes, and snippets.

@ejfox
Created June 11, 2017 21:21
Show Gist options
  • Save ejfox/e3409f05fd34c1531bd304fe77725a19 to your computer and use it in GitHub Desktop.
Save ejfox/e3409f05fd34c1531bd304fe77725a19 to your computer and use it in GitHub Desktop.
= 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