Guest User

Untitled

a guest
Nov 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. var xT = 20;
  2. var yT = 20;
  3. var W = 500;
  4. var H = 500;
  5.  
  6. var backgroundColor = 'rgb(200,200,200)';
  7.  
  8.  
  9. tributary.init = function(ctx) {
  10. };
  11. tributary.run = function(ctx,t) {
  12. tributary.clear(); //helper function to clear the canvas
  13.  
  14. this.axisAndBackground(ctx);
  15. };
  16.  
  17. //drawing functions
  18.  
  19. tributary.axisAndBackground = function(ctx){
  20. ctx.fillStyle = backgroundColor;
  21. this.drawRectT(ctx, 0, 0, 1, 1);
  22. }
  23.  
  24.  
  25.  
  26. //drawing primitves
  27.  
  28. tributary.drawRectT = function(ctx, x, y, w, h){
  29. ctx.fillRect(x*W+xT, y*H+yT, w*W, h*H);
  30. }
  31. tributary.lineT = function(ctx, x0, y0, x1, y1){
  32. this.moveToT(x0, y0);
  33. this.lineToT(x1, y1);
  34. }
  35. tributary.moveToT = function(ctx, x, y){
  36. ctx.moveTo(x*W+xT, y*H+yT);
  37. }
  38. tributary.lineToT = function(ctx, x, y){
  39. ctx.lineTo(x*W+xT, y*H+yT);
  40. }
Add Comment
Please, Sign In to add comment