I'm trying to make something that is chosing random colors from an array of colors but once it chooses one it will remove it from the array to not be chosen again.
From what I know there is no simple way of removing indexes from arrays but with arraylists is possible. The problem I'm having is that I don't know how to get the data out of the arraylist properly do be used as colors.
Where I have cor = mycolours[int(rand1)]; I'd like to have something like cor = colors.get(int(rand1)); but I get this error " Cannot convert Object to int"
can someone tell me how to access it?
color[] mycolours = { #F9EC31, #37B34A, #1B75BB, #652D90, #EB008B, #BE1E2D}; PShape a, b, c, d, e, f, g, r_emote, drawing; color cor, cor2, cor3, cor4, cor5, cor6; float rand1; float rand2; float rand3; float rand4; float rand5; float rand6; ArrayList colors; void setup(){ size(400,600); smooth(); noStroke(); drawing = loadShape("r-emote.svg"); a = drawing.getChild("a"); b = drawing.getChild("b"); c = drawing.getChild("c"); d = drawing.getChild("d"); e = drawing.getChild("e"); f = drawing.getChild("f"); r_emote = drawing.getChild("r"); drawing.disableStyle(); shapeMode(CENTER); background(255); colors = new ArrayList(); colors.add(mycolours[0]); colors.add(mycolours[1]); colors.add(mycolours[2]); colors.add(mycolours[3]); colors.add(mycolours[4]); colors.add(mycolours[5]); // println(colors.get(3));
So, I've been using processing for the purpose of making random and generative illustrations based on svgs for a bit now but I've been always using and trying to improve the original way I learnt how to do it.
I normaly create a string array ( or more than one, depending on the drawings and what i want to do with them) of the names of the files and then I use it to load the files in the draw.
This brings me to a performance issue that, in most cases, since what I'm interested is in the still image, doesn't really make a diference.
Now I want to make something that is "live" and it's going to be projected so I need fluidity in the movement of my graphics.
The problem is, since I'm always calling different drawings each time the draw() loops I'm actualy loading the svgs in live time. Is there a possibility of loading them in the setup and them choosing which to use in the draw?
I'm going to post an example… this case only has 2 SVGs being loaded, but sometimes it has a lot more.…
I'd like to know if there is a way of making a embeded (in a website) processing sketch respond to Html links.
to use like some kind of GUI for the sketch.
Hey. I'm new to this forum. I was using the other one and I just wasn't( and aren't ) getting used to this new one. Dumb of me ... took me a long time to figure out how to post this.
Let's cut to the chase
I have a program that loads several svg files and then on the draw it just pick up those vector files randomly to place them somewhere. The problem is. I've used getChild before on svg's but one at a time.
This time i wanted to do something like having several Svg and each svg has a number of childs ( 4) and I wanted it to find those childs and apply them so i can color each one of them individualy. So when i call tulipaAdesenhar they find what ever child's it has ( since being a random choice every frame) and apply them.
In all the files I've given the same name to the layers so I could call the same same with the tulipaAdesenhar. (I thought it could make things easier.
I thought something like this would work ( but it doesn't)