We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone,
I am looking for a way to "build" a triangle shape (isosceles triangle) where I can specify the start point a (a1,a2), the length of the vertical direction towards the hypotenuse, and the length of the hypotenuse.
I then want to paste multiple triangles from that master shape into the sketch at positions I specify just with a point and the rotation of the triangle. For example 4 triangles in the middle of each side with the hypotenuse facing towards the middle of the sketch.
position1( 0 , height/2 ) with 90° rotation
position2( width/2 , 0 ) with 0° rotation
position3( width , height/2 ) with 180° rotation
position4( width/2 , height ) with 270° rotation
Any help is strongly appreciated.
Thanks a lot.
Answers
Here's what I got so far. It's a version where I manually put down the triangles. I marked all positions I want triangles in with lines first and added one triangle to start with. But it all is very non-responsive towards changes I want to do later on maybe.
Thanks again, TfGuy44.
For the sake of learning, are there other possible ways to achieve that? I was looking into pshapes and... I think it was vertex(?) but wasn't sure how to approach the problem with those two.
As for your solution, let me try to follow what your code does:
line 26: puts the current matrix in the stack, aka everything that has been drawn so far is gone, I got an empty sketch
line 27: Does translate(x,y) move the point of origin of the coordinate system to the new coordinates?
line 28: rotate the empty sketch
line 29: put a triangle down at ( 0, 0, hori, -vert, hori, vert)
line 30: puts the old sketch back with the newly triangle, is it put on top or underneath?
pushMatrix() merely saves current transformations (coord. system): :-B
https://Processing.org/reference/pushMatrix_.html
For "emptying" the canvas, call background() or clear(): ;)
If I want to make the background transparent, would
background(0,0,0,0);
work?
https://Forum.Processing.org/two/discussion/20499/moving-a-translucent-window-around-the-screen#Item_8