We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, it's my first time using Processing and code to create images and despite the wealth of information out there (to which I am grateful!) I am having a difficult time tracking down the right code for certain things.
Below is the image I mocked up to know what I want my final code to look like.
This is what I have so far in terms of my code:
int numCols=10;
int numRows=10;
void setup () {
size(1000,1000);
background(175,191,183);
noStroke(); }
void draw () {
for (float x=width/numCols; x<width;x+=(width/numCols)) {
for (float y=height/numCols; y<height;y+=(height/numCols)) {
stroke(112,138,144);
arc(-100,-100, 150, 155, 0, PI);
strokeWeight(5);
strokeCap(SQUARE);
pushMatrix();
translate(x,y);
if (mousePressed) {
fill(random(255),random(255)); }
beginShape();
arc(0, 0, 80, 85, 0, PI);
endShape();
popMatrix(); }
} }
Which is progressing nicely I'd like to think (?? lol) I'd just like some help in figuring out how to:
1) Randomise the colours between 5 set shades (needed colours are below)
bright red(188,66,57) / dark grey(93,93,93) / offwhite(240,240,230) / yellow(226,172,75) / midpink(250,128,114)
2) How to shift every second row slightly to the left to create a motif-like pattern
3) How to make the arcs on every second column upside down
You don't necessarily have to write the code for me. I do kind of want to figure it out and manipulate it by myself as a learning experience. I just can't for the life of me find the needed code/commands.
Thank you
Answers
Thank you PhiLho! Had no idea I was supposed to use an array, and now I've discovered them as really useful! :)
So far I've managed to figure out that every time I click the mouse, all the arcs looped in my rows and columns will randomly change into one of my five colors. How do I make it so that it's a random color per arc (aka more individualised)?
This is what I was able to create so far.
You're gonna need to create a
class
to represent your WaterMelon w/ all its desired properties like: location, dimension, color, etc. :-Bhttps://processing.org/reference/class.html
Progress for you. Keep at it.
Ah! Thank you everyone! I'll use all the information you've given me so far and play around with it.
Thank you so much :) :) :) :)
Ok just an update on to how I'm progressing. I haven't gotten the hang of refining boolean or the way TfGuy44 has shown how to reverse shapes at every interval. This is ok, I'm still experimenting with it and am satisfied with the information I've received regarding that topic so far.
What I'd like to know how to do now is, in regards to my watermelon pattern, I do have some finicky seeds to put in. What is the best way to draw them in? As points?
This is my code so far again, now with random color ~
Sorry to double post but after a bit more tweaking, I've abandoned the use of intCols and Rows and floats to create a grid with my watermelons.
I feel like this is a better approach for what I want? Or should I go back to what I had before?