We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I'm trying to draw a triangle made of lines using a for loop, but all I can get are triangles with sides that are not equilateral. How do I do this? I've attached my code below:
void setup(){
size(500,500);
}
void draw(){
background(0);
float positionHeight = 200;
float forAdjust = 10;
float forAdjustLeft = -forAdjust;
for (int xPos = 409; xPos <width; xPos += 8, positionHeight += forAdjust, positionHeight -= forAdjustLeft) {
stroke(random(0, 255), random(255), random(255));
strokeWeight(3);
line(xPos, 0, xPos, positionHeight );
}
}
Answers
https://processing.org/reference/triangle_.html
Nice try, but its not that simple. Did you even look at what I was trying to do?
see if this can help you
I thought the example would be equil.
it's not
oups nvm
that's almost:
_vk, this is very helpful, however I'm trying to fill the triangle full of ellipses instead of just drawing an ellipse at each corner. I believe I need a nested for loop to do this, just unsure how to execute it.
To clarify, I'm trying to draw a triangle made of lines with for loops. See the image below:
??
homework?
I only referenced ellipses because he _vk used them in his sketch
look at
lerp()
pleasehttps://processing.org/reference/
Back in the day we used to call this 'rasterisation' or 'scanline algorithm' only the lines were horizontal. Googling brings up useful stuff.
A hard-coded way to go about it. As koogs mentioned, looking into rasterization is probably what you want to generalize the process: