├── .gitignore
├── example-001.pdf
├── README.md
├── LICENSE
└── RobotFaces
└── RobotFaces.pde
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 |
--------------------------------------------------------------------------------
/example-001.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raster/Robot-Faces/master/example-001.pdf
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Robot Faces
2 |
3 | This is a Processing sketch that creates a grid of rectangles.
4 |
5 | You can adjust some variables but basically you'll get randomly generated robot faces.
6 |
7 | The output is a vector PDF file.
8 |
9 | For my #PlotterTwitter friends, have fun!
10 |
11 | You can read more about this here:
12 |
13 | (oh yeah, I still need to write a blog post...)
14 |
15 | ---
16 |
17 | Pete Prodoehl
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Pete Prodoehl
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/RobotFaces/RobotFaces.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * RobotFaces.pde
3 | *
4 | * Pete Prodoehl
5 | *
6 | *
7 | *
8 | */
9 |
10 | import processing.pdf.*;
11 | import java.util.Date;
12 |
13 |
14 | // set width and height of canvas as well as border at edges
15 | int canvasWidth = 1280;
16 | int canvasHeight = 720;
17 |
18 | // most of the numbers below can be adjusted, play around with their values
19 |
20 | float xpos = 50; // x starting point in upper left
21 | float ypos = 50; // y starting point in upper left
22 | float wall = 150; // attempt to preserve whitespace on right side
23 |
24 | // step for each face,
25 | float step = 70;
26 |
27 |
28 | float mimn = xpos;
29 | float rowct = 0;
30 | float multiple = 0;
31 |
32 | /* ----------------------------------------------------------- */
33 |
34 | // get date to use for filename
35 | Date date = new Date();
36 | long currentTime = date.getTime()/1000;
37 |
38 |
39 | void settings() {
40 | size(canvasWidth, canvasHeight);
41 | }
42 |
43 | void setup() {
44 | background(255);
45 | stroke(0);
46 | strokeWeight(1);
47 | beginRecord(PDF, "output-" + currentTime + ".pdf");
48 | }
49 |
50 | void draw() {
51 |
52 | noFill();
53 | rectMode(CENTER);
54 | ellipseMode(CENTER);
55 |
56 | float randx = random(30,64);
57 | float randy = random(30,54);
58 | float randoff = random(0,4);
59 | float radius = random(1,50);
60 |
61 | // head
62 | fill(255);
63 | rect(xpos, ypos, randx, randy, radius);
64 |
65 | // eyes
66 | rect(xpos-8, ypos-5, randx/10, randy/10);
67 | rect(xpos+8, ypos-5, randx/10, randy/10);
68 |
69 | // mouth
70 | rect(xpos, (ypos+5)+randoff, randx/2, randy/10);
71 |
72 |
73 | // end of a row
74 | if (xpos > (canvasWidth-wall)) {
75 | xpos = mimn;
76 | ypos = ypos + step;
77 | rowct++;
78 | }
79 | else {
80 | xpos = xpos + step;
81 | }
82 |
83 | // last row, then we save the PDF and exit
84 | if (ypos > (canvasHeight-wall)) {
85 | ypos = step;
86 | endRecord();
87 | exit();
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------