xFazz

challenge1 Vers1

Oct 18th, 2020 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. RAPiDS
  2. Restate, (Find) Analogies, Plan a Solution, Divide Problem, Start where you Know
  3.  
  4. Problem: Build a stained glass window pattern. Start by splitting screen
  5.  
  6. Restate/Analogies: Use line() function to make 9 lines. Draw rectangles at certain intersectional points at the top, middle, and bottom of screen
  7.  
  8.  
  9. 1. drawLines() {
  10. -You need to make 3 sets of 3 lines (9 total)
  11. -Up strokeweight if need to
  12.  
  13. -3 lines per set: two outer and one center
  14. -Start with horizontal set by plotting the center line
  15. If it's size(500, 500), it should start 0, 250 and end 500, 250
  16. -Continue horizontal set by plotting outer lines
  17. Offset lines by 50
  18. Upper outer: Start 0, 200 and end 500, 200
  19. Lower outer: Start 0, 300 and end 500, 300
  20.  
  21. (-Decided horizontal lines were too offset so change offset by 10
  22. Upper outer: Start 0, 240, an end 500, 240
  23. Lower outer: Start 0, 260, and end 500, 260
  24.  
  25. Changing offset again by 25
  26. Upper outer: Start 0, 225 End 500, 225
  27. Lower outer: Start 0, 275 End 500, 275)
  28.  
  29. Now to plot first vertical set.
  30. Middle line:
  31. Half of half of the screen (125)
  32. Start 125, 0 End 125, 500
  33.  
  34. To plot second vertical set
  35. Middle line is half of half of the second part of the screen (375
  36. Start 375, 0, End 375, 500
  37. }
  38.  
  39. 2. Implementing ETC measures
  40. Change all line() arguments to be variation of width and height
  41. creation of offset variable to hold offset number
  42. 4 types of arguments: width, height, a change in width, a change in height
  43.  
  44. 3. Draw borders
  45.  
  46. line(
  47.  
  48. 4. drawShapes() {
  49.  
  50. First, write line to set color
  51.  
  52. Top:
  53. Next there are two rectangles at the top
  54. First: Empty space between start and upper line
  55. Y value is 25
  56. Then ETC these shapes
  57.  
  58. Middle:
  59. Shapes -> left of first intersection, middle, right of second intersection
  60. First
  61. Single rect with line passing through at the middle, x is
  62. Second:
  63.  
  64.  
  65.  
  66. Bottom:
  67. Shapes -> Between inner and outer lines, with middle line passing through for both vertical sets
  68.  
  69.  
  70. }
  71.  
  72. ----
  73. FIRST DRAFT
  74. What went wrong?
  75. I began adding too much complexity for no reason. Didn't separate the stages of programming (planning, coding, improving) As a result the program was haphazardly written
  76. How to improve for next time: Clearly separate each stage and plan first. Start out with a pseudocode of the program. Then work on adding complexity. Focus on reaching the minimum first before jumping ahead.
  77.  
  78. int offset = 25; //How much the lines in each set are offset by
  79.  
  80. void setup() {
  81. size(500, 500);
  82. background(255);
  83. }
  84.  
  85. void draw() {
  86. drawShapes();
  87. drawBordersAlongScreen();
  88. drawLines();
  89.  
  90. }
  91.  
  92. void drawLines() { // Draws the 3 sets of 9 lines that split up the stained glass
  93. strokeWeight(1);
  94.  
  95. //horizontal set
  96.  
  97. line(0, (height/2), width, (height/2)); //central
  98. line(0, ((height/2) - offset), width, ((height/2) - offset)); //upper outer
  99. line(0, ((height/2) + offset), width, ((height/2) + offset)); //lower outer
  100.  
  101. //first vertical set (left side)
  102.  
  103. line( (width/4), 0, (width/4), height ); //central
  104. line( ((width/4) + offset), 0, ((width/4) + offset), height ); //upper outer
  105. line( ((width/4) - offset), 0, ((width/4) - offset), height ); //lower outer
  106.  
  107. //second vertical set (right side)
  108.  
  109. line( ((width/2) + (width/4)), 0, ((width/2) + (width/4)), height ); //central
  110. line( ((((width/2) + (width/4)) + offset)), 0, ((((width/2) + (width/4)) + offset)), height ); //lower outer
  111. line( ((((width/2) + (width/4)) - offset)), 0, ((((width/2) + (width/4)) - offset)), height ); //upper outer
  112.  
  113. }
  114.  
  115. void drawShapes() { //Allows sections of the stained glass (top, middle, bottom) to be filled in with a transparent orange
  116. strokeWeight(1);
  117. fill(255, 165, 0, 175); //transparent orange
  118.  
  119. //top shapes
  120. rect(0, 0, ((width/4)-offset), offset);
  121. rect(((((width/2) + (width/4)) + offset)), 0, (width/4), offset);
  122.  
  123. //middle shapes
  124. rect(75, 225, 25, 50);
  125. rect(350, 225, 25, 50);
  126.  
  127. }
  128.  
  129. void drawBordersAlongScreen() {
  130. strokeWeight(5);
  131.  
  132. line(0, 0, width-1, 0); //along top
  133. line(width-1, 0, width-1, height-1); //right side
  134. line(width-1, height-1, 0, height-1);//bottom
  135. line(0, height-1, 0, 0); //left side
  136. }
Add Comment
Please, Sign In to add comment