[SDL] triangles & aspects

Sanette sanette-linux at laposte.net
Thu Mar 23 23:58:11 PDT 2017

```Le 23/03/2017 à 22:19, speartip a écrit :
> Hi,  > > I am endeavoring to put some simple triangles in my screen. The
SDL wiki gives an example of - yes - connecting 3 drawlines. Am I
overlooking something or do these lines have to be arrived at
mathematically or hardcoded to know what anchoring coordinates they must
belong to form the triangle. I don't see a function to make the triangle
for you. This becomes rather labor intensive to create your triangle.
Also once made, if your aspect ratio changes the lines of the triangle
will have to be recalculated to maintain the equality of the angles. I
can make a function to correct, no prob. > > Before venturing out on
some crazy triangle project, just wanted to know whether I was missing
some piece of info. > > >
_______________________________________________ > SDL mailing list >
SDL at lists.libsdl.org > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi

your question is not terribly clear. Mathematically, a triangle is
just given by 3 points, so there is no problem. (By the way do you want
simple triangles or filled triangles ? Do you want anti-aliasing ?)

Maybe what you mean in fact is an equilateral triangle: all sides have
same length. Then, yes there is some math behind this. There are many
possibilities. Either you compute the position of the third point
given the first two.  Or it might be easier to draw a horizontal
segment (the base of the triangle), and then use SDL_RenderCopyEx to
copy+rotate by 60° to obtain the two other sides.

--
sanette -- full_time_linux

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20170324/02905a63/attachment.htm>
```