Skip to content

Instantly share code, notes, and snippets.

@georules
Created September 1, 2015 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georules/3786a097f47196ebe119 to your computer and use it in GitHub Desktop.
Save georules/3786a097f47196ebe119 to your computer and use it in GitHub Desktop.
canvas arcs
{"description":"canvas arcs","endpoint":"","display":"canvas","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"inline-console":true}
var canvas = document.getElementsByClassName('tributary_canvas');
console.log(canvas)
canvas = canvas[0]
radius = 50
if (canvas.getContext){
var ctx = canvas.getContext('2d');
for(var i=0;i<4;i++){
for(var j=0;j<3;j++){
var path = new Path2D();
var x = radius+1+j*2*radius; // x coordinate
var y = radius+1+i*2*radius; // y coordinate
var radius = radius; // Arc radius
var startAngle = 0; // Starting point on circle
var endAngle = Math.PI+(Math.PI*j)/2; // End point on circle
var anticlockwise = i%2===0 ? false : true; // clockwise or anticlockwise
path.arc(x, y, radius, startAngle, endAngle, anticlockwise);
if (i>1){
ctx.fill(path);
} else {
ctx.stroke(path);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment