We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Cheers, as I've been introducing, I'm a goddamn total noob to this science. I started because I have a simple(?) clear idea for a graphic design project. I'd like to make processing load an image, reproduce it a random number of times, cropping it randomly and finally repeat the process as the last crop will be repeated right next to the last one for a random number of times. The result should be a random pattern of cropped and modulated parts of the original image.
As I could understand, the ingredients of this code should be: - PImage ; - get (); - random ();
but how I should mix them? I tried to follow and mix different tutorials about those issues, but I couldn't figure out how to make it work.
Do you know da wae?
Answers
What is the problem?
It seems simple
Make
Show your attempt, your code
Well a good first step would be to load and display the image.
https://processing.org/reference/image_.html
Then you want to get a part of the image:
https://processing.org/reference/get_.html
Where from? How big? Well, the values will be random, so you will need to generate some random numbers:
https://processing.org/reference/random_.html
Once you have a random part of the image, you can draw it using image() as before.
Yay! Examples!
Attempt to write this yourself and POST the CODE of your attempt.
this is the better get, for an image
https://processing.org/reference/PImage_get_.html
e.g.
Until now, this is what I could experiment.
As you can see, I'm far away from what I'm imagining.
The code loads the image (which is very big) also as background and then generates as an animation random crops of the image. The matter is: as the size of the crop changes, the image is also scaled. And I don't want it to be an animation. I will link an image as vague example of what I meant in the first post.
Ooo, close. You are 80% of the way to us maybe helping you (because you have code now, and you posted it). The last 20% is here:
https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text#latest
This idea:
must better be like:
you haven't done my advice with two for-loops yet
Hey there, first of all THANK YOU SO MUCH. I appreciate your patience. So, I started getting a little bit more and this is what I wrote:
But there's a problem: I get an error message -> The function width() does not exist
help!
oh, it seems that
get()
can copy an area from the image that exceeds the borders of the right and lower side.Then there is a black area in image
c
(right and lower side).Let me explain:
Let's say this
got these random results PImage c = Casa.get( 500 , 300, 200, 200 );
and casa is only 600x400, then c would still be 200x200 but but the right part (100 px) and the lower part (100 px) would be black (since we make c 200x200 but copy a part from casa that doesn't exist / is too small into it)
to avoid this, we could store the position where we start copying (500,300) and make our random w and h of
get()
in a way it cannot be bigger than 100,100 in that case:so width and height with reduced maximum for random
Ok this is getting tricky. Where should I put this part of code?
The longer 1st code I posted 10:04 is replacing the old section
My 2nd post 10:19 belongs after that section
So, more or less, this is the code it should come out, right?
It's just I get an error saying "Cannot find anything named âcâ" :/
Delete lines 14 and 16
Keep line 15
Also please note that I use noLoop
Guys this is great. Here it is, the code of my dreams. Anyway there's still a small issue I can't figure out: as the image is reeeaaaally big, how I tell the code to use it as a smaller version? I'm trying to mess up everywhere adding a "/4" to the width and height lines but still I can't reduce the sizes of the crops.
directly after loadImage use resize
Casa.resize(600,400);
Thank you so much, you've been kind and patient. This is priceless!
It was an honor, Sir.
that's cool. But how do I say to the code to repeat the crop modularly not only on the left lower corner but randomly on the whole image?
I don’t understand
Which line Numbers are you referring to?
In my sketch he uses the whole image (randomly)
In line 39 to 42 he just uses the last c from the previous for loops. Those are always different randomly
Let me show you an example:
As you pointed out, the bottom left corner is going to generate the pattern I'm interested to. But how I make this pattern repeat many times in the whole image and not only in the corner? And how can I make the pattern repeat less times?
Please, be patient. I can barely understand what is a line of code...
crop takes a part of the image Casa, like a rect
The first two parameter are x,y of the upper left corner (Apologies, I had that wrong) and width and height of the rectangle (cut out of Casa).
Lines 23 and 24
Now there are Two parts in the code, the first for loop where we make new crops and distribute them randomly (lines 33-34).
The second part is doing the long repetition on the lower part (lines 39-42).
They look always different depending on the last c.
This long row you can move up by changing y value in line 41
The distance between the images is done by what we add to x at the end of line 39. at the moment that’s the width of c.
But you can also have 2x c.width
Please please play with the code and try out the things I pointed out
I obviously did! It's just I couldn't figure out what did what :) This last answer explained everything! Thank you so much!!!
Apologies for my mistake with the upper left corner.