(x1,y1) (x,y) (x1,y1) (x2,y2) (x2,y2) (x3,y3) (x1,y1) (x4,y4) (x2,y2) (x3,y3) (x,y) width height (x,y) height width (x1,y1) (cx1,cy1) (x2,y2) (cx2,cy2) point(x, y) line(x1, y1, x2, y2) triangle(x1, y1, x2, y2, x3, y3) quad(x1, y1, x2, y2, x3, y3, x4, y4) rect(x, y, width, height) ellipse(x, y, width, height) bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2) Geometry primitives <strong>Processing</strong> has seven functions to assist in making simple shapes. These images show the format for each. Replace the parameters <strong>with</strong> numbers to use them <strong>with</strong>in a program. These functions are demonstrated in codes 2-04 to 2-22.
triangle(55, 9, 110, 100, 85, 100); triangle(55, 9, 85, 100, 75, 100); triangle(-1, 46, 16, 34, -7, 100); triangle(16, 34, -7, 100, 40, 100); The quad() function draws a quadrilateral, a four-sided polygon. The function has eight parameters, two for each point. quad(x1, y1, x2, y2, x3, y3, x4, y4) Changing the parameter values can yield rectangles, squares, parallelograms, and irregular quadrilaterals. quad(38, 31, 86, 20, 69, 63, 30, 76); quad(20, 20, 20, 70, 60, 90, 60, 40); quad(20, 20, 70, -20, 110, 0, 60, 40); Drawing rectangles and ellipses works differently than the shapes previously introduced. Instead of defi ning each point, the four parameters set the position and the dimensions of the shape. The rect() function draws a rectangle: rect(x, y, width, height) The fi rst two parameters set the location of the upper-left corner, the third sets the width, and the fourth sets the height. Use the same value for the width and height parameters to draw a square. rect(15, 15, 40, 40); // Large square rect(55, 55, 25, 25); // Small square rect(0, 0, 90, 50); rect(5, 50, 75, 4); rect(24, 54, 6, 6); rect(64, 54, 6, 6); rect(20, 60, 75, 10); rect(10, 70, 80, 2); 29 Shape 1: Coordinates, Primitives 2-14 2-15 2-16 2-17 2-18
- Page 2 and 3: Processing: a programming handbook
- Page 4 and 5: 29 34 45 57 67 72 91 99 113 121 131
- Page 6 and 7: 88 342 55 65 305 220 98 319 323 351
- Page 8 and 9: 29 30 44 55 63 70 88 97 113 124 128
- Page 10 and 11: 51 51 53 57 61 61 65 67 69 69 71 72
- Page 12 and 13: 237 237 238 239 242 243 245 245 249
- Page 14 and 15: 501 503 507 511 515 519 519 521 522
- Page 16 and 17: Processing… Processing relates so
- Page 18 and 19: Literacy Processing does not presen
- Page 20 and 21: languages suitable for different co
- Page 22 and 23: The Processing website, www.process
- Page 24 and 25: Using Processing Download, Install
- Page 26 and 27: Sketch_123.java The JAVA fi le gene
- Page 28 and 29: 13 Using Processing int x = 0; // S
- Page 30 and 31: 15 Using Processing } } diagonals(d
- Page 33 and 34: Shape 1: Coordinates, Primitives Th
- Page 35 and 36: A position on the screen is compris
- Page 37: While it’s possible to draw any l
- Page 41 and 42: Drawing order The order in which sh
- Page 43 and 44: ect(33, 20, 33, 60); fill(255, 204)
- Page 45 and 46: the width and the fourth parameter
- Page 47 and 48: also use this range. Setting the re
- Page 49 and 50: ackground(56, 90, 94); smooth(); st
- Page 51 and 52: RGB HSB HEX 255 0 0 360 100 100 #FF
- Page 53 and 54: Change the brightness, hue and satu
- Page 56 and 57: Synthesis 1: Form and Code This uni
- Page 58 and 59: Riley Waves. These images were infl
- Page 61 and 62: Substrate, 2004. Image courtesy of
- Page 63 and 64: 159 Interviews 1: Print
- Page 65 and 66: When a program starts, mouseX and m
- Page 67 and 68: 208 Input 1: Mouse I // Exponential
- Page 69 and 70: Using the mouseX and mouseY variabl
- Page 71 and 72: Mouse buttons Computer mice and oth
- Page 73 and 74: Draw an ellipse to show the positio
- Page 76 and 77: Rafael Lozano-Hemmer. Standards and
- Page 78 and 79: obtained, in this case, with the he
- Page 80 and 81: Example 1. Detects motion by compar
- Page 82 and 83: detecting people in videos of offi
- Page 84 and 85: trajectories in 2D space. EyesWeb
- Page 86 and 87: color currColor = video.pixels[i];
- Page 88 and 89:
Example 3: Detection through bright
- Page 90 and 91:
Resources Computer vision software
- Page 92 and 93:
map(), 81 mask(), 354 max(), 50 mil
- Page 94 and 95:
C, 7, 264, 515-517, 522-523, 592, 6
- Page 96 and 97:
Listening Post (Rubin, Hansen), 514
- Page 98:
Spark Fun Electronics, 640 SQL (Str