Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. PImage img;
  2.  
  3.  
  4. void setup() {
  5. img= loadImage("imageback.jpg");
  6. img.resize(501,501);
  7. background(img);
  8. size(501, 501);
  9. smooth();
  10. }
  11. void draw() {
  12. scene7();
  13.  
  14. }
  15.  
  16. void arrow(int x1, int y1, int x2, int y2) {
  17. line(x1, y1, x2, y2);
  18. pushMatrix();
  19. translate(x2, y2);
  20. float a = atan2(x1-x2, y2-y1);
  21. rotate(a);
  22. line(0, 0, -10, -10);
  23. line(0, 0, 10, -10);
  24. popMatrix();
  25. }
  26.  
  27. void dottedline(float x1, float y1, float x2, float y2, float steps){
  28. for(int i=0; i<=steps; i++) {
  29. float x = lerp(x1, x2, i/steps);
  30. float y = lerp(y1, y2, i/steps);
  31. noStroke();
  32. ellipse(x, y,2,2);
  33. }
  34. }
  35.  
  36. void scene7(){
  37.  
  38.  
  39. line(250, 0, 250, 500);
  40. line(0, 250, 500, 250);
  41.  
  42.  
  43. for (int j = 250; j<= 500; j+=25) {
  44. for (int i =250; i>=0; i-=25) {
  45. line(240, i, 260, i);
  46. line(i, 240, i, 260);
  47. line(240, j, 260, j);
  48. line(j, 240, j, 260);
  49. }
  50. }
  51.  
  52.  
  53. fill(0);
  54. textSize(9);
  55. int b = 0;
  56. int b1=1;
  57. for (int k=250; k<=500; k+=25) {
  58.  
  59. text("-"+b, 230, k);
  60. text(""+b1, k+25, 240);
  61.  
  62. b=b+1;
  63. b1=b1+1;
  64. }
  65. int b2=0;
  66. int b3=1;
  67. for (int l=250; l>=0; l-=25) {
  68. text(""+b2, 230, l);
  69. text("-"+b3, l-25, 240);
  70. b2=b2+1;
  71. b3=b3+1;
  72. }
  73.  
  74.  
  75. fill(255);
  76. rect(290, 70, 190, 80);
  77. fill(0);
  78. textSize(10);
  79. text("Here we have a 2-dimensional grid.\n The dimensions are labelled X and Y.\n This is caled Cartesian coordinates\n or orthonganol coordinates!",295,90);
  80. textSize(12);
  81. fill(1);
  82. text("Y", 260,10);
  83.  
  84.  
  85.  
  86. arrow(290, 60, 260, 10);
  87.  
  88. dottedline(250, 50,60,50,20);
  89. dottedline(50, 250,50,50,20);
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement