Hello again to whomever may see this discussion. I return to the forums again today wondering what would be the easiest way to simply draw a triangle(with inside filled too) without using a sprite. Plz help anyone I appreciate any answer that I can get. But please try and make the most simple way to simply draw a triangle. Thank you
You need to use a mesh. Look at the mesh documentation for help in making ons.
@Qtipit - see example below
function setup()
t = MakeTriangle(vec2(-50,70),vec2(80,40),vec2(10,-100),color(255,255,0))
end
function MakeTriangle(v1,v2,v3,c)
m=mesh()
m.vertices={v1,v2,v3}
m:setColors(c)
return m
end
function draw()
background(103, 118, 228, 255)
pushMatrix()
translate(400,400)
t:draw()
popMatrix()
end
When you make the triangle, centre it on (0,0). This allows you to move it (and rotate it) around the screen using translate
as shown above.
However, if your triangle is in a fixed position and will not move, you can simply pass the actual positions of the corners through to MakeTriangle, and the draw function becomes
function draw()
background(103, 118, 228, 255)
t:draw()
end
Thank you a ton @Ignatz and @CodeaNoob this is exactly what I was looking for I reall appreciate the help
If you haven’t seen it before, have a look at my ebook on Codea, it has a lot on meshes, which I strongly recommend you learn, they are very cool indeed.
https://www.dropbox.com/sh/mr2yzp07vffskxt/AACqVnmzpAKOkNDWENPmN4psa