Guest User

Untitled

a guest
Nov 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. var xT = 20;
  2. var yT = 20;
  3. var W = 500;
  4. var H = 500;
  5.  
  6. var backgroundColor = "#F1F1F1";
  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. ctx.strokeStyle = 'black';
  24. ctx.beginPath();
  25. this.moveToT(ctx, 0,1);
  26. this.lineToT(ctx, 0,0);
  27. this.lineToT(ctx, 1,0);
  28. ctx.stroke();
  29. }
  30.  
  31.  
  32.  
  33. //drawing primitves
  34.  
  35. tributary.drawRectT = function(ctx, x, y, w, h){
  36. ctx.fillRect(x*W+xT, y*H+yT, w*W, h*H);
  37. }
  38. tributary.lineT = function(ctx, x0, y0, x1, y1){
  39. ctx.beginPath();
  40. this.moveToT(x0, y0);
  41. this.lineToT(x1, y1);
  42. ctx.stroke();
  43. }
  44. tributary.moveToT = function(ctx, x, y){
  45. ctx.moveTo(x*W+xT, (1-y)*H+yT);
  46. }
  47. tributary.lineToT = function(ctx, x, y){
  48. ctx.lineTo(x*W+xT, (1-y)*H+yT);
  49. }
Add Comment
Please, Sign In to add comment