Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var xT = 20;
- var yT = 20;
- var W = 500;
- var H = 500;
- var backgroundColor = 'rgb(200,200,200)';
- 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);
- }
- //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){
- this.moveToT(x0, y0);
- this.lineToT(x1, y1);
- }
- tributary.moveToT = function(ctx, x, y){
- ctx.moveTo(x*W+xT, y*H+yT);
- }
- tributary.lineToT = function(ctx, x, y){
- ctx.lineTo(x*W+xT, y*H+yT);
- }
Add Comment
Please, Sign In to add comment