Skip to content

Instantly share code, notes, and snippets.

@moebio
Created June 22, 2012 15:22
Show Gist options
  • Save moebio/2973433 to your computer and use it in GitHub Desktop.
Save moebio/2973433 to your computer and use it in GitHub Desktop.
just another inlet to tributary
var xT = 20;
var yT = 20;
var W = 500;
var H = 500;
var backgroundColor = "#F1F1F1";
tributary.init = function(ctx) {
};
tributary.run = function(ctx,t) {
tributary.clear(); //helper function to clear the canvas
this.axisAndBackground(ctx);
};
//drawing functions
tributary.axisAndBackground = function(ctx){
ctx.fillStyle = backgroundColor;
this.drawRectT(ctx, 0, 0, 1, 1);
ctx.strokeStyle = 'black';
ctx.beginPath();
this.moveToT(ctx, 0,1);
this.lineToT(ctx, 0,0);
this.lineToT(ctx, 1,0);
ctx.stroke();
}
//drawing primitves
tributary.drawRectT = function(ctx, x, y, w, h){
ctx.fillRect(x*W+xT, y*H+yT, w*W, h*H);
}
tributary.lineT = function(ctx, x0, y0, x1, y1){
ctx.beginPath();
this.moveToT(x0, y0);
this.lineToT(x1, y1);
ctx.stroke();
}
tributary.moveToT = function(ctx, x, y){
ctx.moveTo(x*W+xT, (1-y)*H+yT);
}
tributary.lineToT = function(ctx, x, y){
ctx.lineTo(x*W+xT, (1-y)*H+yT);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment