We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi I've been struggling along with the coding for this. The aims of the sketch are :
so heres my messy code,
float y = random(200);
float x = random(200);
float Sline = random(1);
float Rline =random(1);
float posx;
float posy;
float dis = random(20);
void setup(){
size(400,400);
background(255);
stroke(10);
strokeWeight(random (2));
posx = x;
posy = y;
}
void draw(){
//---------this should be the start line---
for(int i = 0; i < 1; i ++){
if( Sline<=0.25){
if (Rline<=0.25){
line (0,y,0+100,y);// right from left side
}else if (Rline<=0.5){
line(width,y,width-100,y);//left from left
}else if(Rline<=0.75){
line(0,y,0,y+100);//up on left
}else if(Rline>0.75){
line(0,y,0,y-100);//down on left
}
}else if (Sline<=0.50){
if (Rline<=0.25){
line (width,y,width+100,y);// right from right side
}else if (Rline<=0.5){
line(0,y,0-100,y);//left from right
}else if(Rline<=0.75){
line(width,y,width,y+100);//up on right
}else if(Rline>0.75){
line(width,y,width,y-100);//down on right
}
}else if (Sline<=0.75){
if (Rline<=0.25){
line (x,0,x,0+100);// down from up side
}else if (Rline<=0.5){
line(x,height,x,height-100);//up from up
}else if(Rline<=0.75){
line(x,0,x-100,0);//left on up
}else if(Rline>0.75){
line(x,0,x+100,0);
}
}else if (Sline>0.75){
if (Rline<=0.25){
line (x,height,x,height+100);// up from down side
}else if (Rline<=0.5){
line(x,0,x,0+100);//down from top
}else if(Rline<=0.75){
line(x,height,x-100,height);//left on bottom
}else if(Rline>0.75){
line(x,0,x+100,0);//right on bottom
}
}
}
//------------------next line values-----------
// these lines should connect to the startline.
//and the start line should not run again.
// the lines should be horizontal or vertical only.
// I can get the lines drawing but they don't connect and are not solely vertical or horizontal
float stepNum =random(20);
for(int j = 0; j < stepNum; j ++){
x = posx + random(-dis, dis);
y = posy + random(-dis, dis);
Rline=random(1);
if (Rline<=0.25){
line (posx, posy,x,(y-dis));
}else if (Rline<=0.5){
line(posx,posy,(x+dis), y);
}else if(Rline<=0.75){
line(posx,posy,x,(y+dis));
}else if(Rline>0.75){
line(posx,posy,(x-dis), y);
}
posx = x;
posy = y;
}
//-----end drawvoid----
}
I'd appreciate any help. I'm mainly a painter and I'm trying to incorporate processing into my work. It suits my procedural process. Sorry about the mess. Ta.
Answers
Honestly, I am not too keen on trying to understand your code. :-?
The start line should be:
You might want to re-compute dist on each frame.
You don't need a loop inside draw(): it is called regularly, it already acts like a loop.
Cool I'll have a look see and tidy the code based on that. It will get me out of the rut I'm in not tonight though as my eyes burn.
Cheerrs for replying to my query.
No problem, try to improve (and show) your code, we will criticize it and help you to improve it further. :-D
I've reduced what I've been trying to do downto just getting the startline working. It's not :((
There are a lot of problems with your code ... :-? :-? :-?
calling functions inside setup will run only once so you need to call it inside draw
Thanks alot. :)) I've coded the way I've coded because I don't really know what I'm doing. I'm trying to understand classes and I will be studying this, breaking it and getting what I need out of it. Thanks for the the time you spent on the code. I will be able to get stuff sorted a bit better I hope. I've only been at this about a week and can only grab an hour or two here and there. But this time next year I'll hopefully be helping people out (probably by asking them to ask you as I have no idea what they are on about.) ;)