[ Launch: zeffii default ] 6486880 by zeffii
[ Launch: zeffii default ] 5033869 by zeffii
-
-
Save zeffii/6486880 to your computer and use it in GitHub Desktop.
processing.js
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
{"description":"processing.js","endpoint":"","display":"canvas","public":true,"require":[{"name":"processing","url":"http://cloud.github.com/downloads/processing-js/processing-js/processing-1.4.1.min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data2.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"util.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"index.html":{"default":true,"vim":false,"emacs":false,"fontSize":12},"indlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/Ne1Yclw.png"} |
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
// Simple way to attach js code to the canvas is by using a function | |
function sketchProc(processing) { | |
// Override draw function, by default it will be called 60 times per second | |
processing.draw = function() { | |
// determine center and max clock arm length | |
var centerX = processing.width / 2, centerY = processing.height / 2; | |
var maxArmLength = Math.min(centerX, centerY); | |
function drawArm(position, lengthScale, weight) { | |
processing.strokeWeight(weight); | |
processing.line(centerX, centerY, | |
centerX + Math.sin(position * 2 * Math.PI) * lengthScale * maxArmLength, | |
centerY - Math.cos(position * 2 * Math.PI) * lengthScale * maxArmLength); | |
} | |
// erase background | |
processing.background(224); | |
var now = new Date(); | |
// Moving hours arm by small increments | |
var hoursPosition = (now.getHours() % 12 + now.getMinutes() / 60) / 12; | |
drawArm(hoursPosition, 0.5, 5); | |
// Moving minutes arm by small increments | |
var minutesPosition = (now.getMinutes() + now.getSeconds() / 60) / 60; | |
drawArm(minutesPosition, 0.80, 3); | |
// Moving hour arm by second increments | |
var secondsPosition = now.getSeconds() / 60; | |
drawArm(secondsPosition, 0.90, 1); | |
}; | |
} | |
// var canvas = d3.select("tributary_canvas"); | |
var canvas = document.getElementById("tributary_canvas"); | |
// attaching the sketchProc function to the canvas | |
var p = new Processing(canvas, sketchProc); | |
//p.exit();// to detach it |
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
.cm-s-lesser-dark.CodeMirror { background: #1e2426; color: #696969; } | |
.cm-s-lesser-dark div.CodeMirror-selected {background: #064968 !important;} /* 33322B*/ | |
.cm-s-lesser-dark span.cm-variable { color:#22EFFF; } | |
.cm-s-lesser-dark span.cm-variable-2 { color: #FFCCB4; } | |
.cm-s-lesser-dark span.cm-variable-3 { color: white; } | |
.cm-s-lesser-dark span.cm-string { color: Chartreuse; } | |
.cm-s-lesser-dark span.cm-string-2 {color: Chartreuse;} | |
.cm-s-lesser-dark span.cm-def {color: #FFCCB4; opacity: 1.0} | |
.cm-s-lesser-dark span.cm-bracket { color: #EBEFE7; } | |
.cm-s-lesser-dark pre { color:#FFF; } | |
.cm-s-lesser-dark span.cm-comment { color: #AFB4B4;} | |
.cm-s-lesser-dark span.cm-property {color: #FDA676;} | |
.cm-s-lesser-dark span.cm-number { color: #FF92EE;} | |
.cm-s-lesser-dark span.cm-keyword { color: #FFFF18; } | |
.cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white !important; } | |
.cm-s-lesser-dark .CodeMirror-gutters {background: #505050;} | |
.cm-s-lesser-dark .CodeMirror-linenumber {color: #D3D3D3;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment