Created
February 8, 2020 17:19
-
-
Save rgov/53d04a64f8a9894f8b03d8dad45e99ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| color bg = #CDE6D0; | |
| color red = #EB1C25; | |
| color yellow = #F7F100; | |
| color green = #20B25B; | |
| color dark_blue = #0072BC; | |
| color brown = #945539; | |
| color light_blue = #AADFFC; | |
| color purple = #D73998; | |
| color orange = #F5951F; | |
| color[][] colorseq = { | |
| {red, yellow}, | |
| {dark_blue, green}, | |
| {brown, light_blue}, | |
| {orange, purple}, | |
| }; | |
| //size(1920, 1080); | |
| size(800, 450); | |
| background(bg); | |
| float h = 50; // height of each space | |
| float b = h * 0.28; // height of color bar, when present, tweak with strokeWeight | |
| // non-corner pieces should hopefully be about w:h ratio 0.6:1 | |
| // figure out the ideal | |
| float wh = 1, wv = 1; | |
| int nh = 0, nv = 0; | |
| for (int i = 0; i < 100; i ++) { | |
| float bd = abs((wh / h) - 0.6); | |
| float d = abs((((width - h - h) / i) / h) - 0.6); | |
| if (d < bd) { | |
| wh = (width - h - h) / i; | |
| nh = i; | |
| } | |
| bd = abs((wv / h) - 0.6); | |
| d = abs((((height - h - h) / i) / h) - 0.6); | |
| if (d < bd) { | |
| wv = (height - h - h) / i; | |
| nv = i; | |
| } | |
| } | |
| stroke(0); | |
| strokeWeight(2); | |
| pushMatrix(); | |
| translate(h, 0); | |
| for (int j = 0; j < 4; j ++) { | |
| float w = (j == 0 || j == 2) ? wh : wv; | |
| int n = (j == 0 || j == 2) ? nh : nv; | |
| // top row | |
| for (int i = 0; i < n; i ++) { | |
| fill(#ffffff); | |
| rect(0, 0, wh, h); | |
| if (i % 6 == 0 || i % 6 == 2 || i % 6 == 3) { | |
| fill(colorseq[j][int(i < n / 2)]); | |
| rect(0, h-b, w, b); | |
| } | |
| translate(w, 0); | |
| } | |
| // top right | |
| fill(#ffffff); | |
| rect(0, 0, h, h); | |
| rotate(radians(90)); | |
| translate(h, -h); | |
| } | |
| popMatrix(); | |
| // jail | |
| fill(orange); | |
| rect(h * 1/3, height - h, h * 2/3, h * 2/3); | |
| // go | |
| textFont(createFont("Arial", 24)); | |
| textAlign(CENTER, CENTER); | |
| fill(#000000); | |
| pushMatrix(); | |
| translate(width - h/2, height - h/2); | |
| rotate(radians(-45)); | |
| text("GO", 0, 0); | |
| popMatrix(); | |
| save("monopoly.png"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment