[SDL] triangles & aspects

Clangray clangray at fastmail.com
Fri Mar 24 14:03:33 PDT 2017


I know the math, its just if I want to place an equilateral triangle
in several different places on the screen I'd like to know what
anybody has done before me in this situation: are there any automated
functions in SDL2?


*Most importantly they need to be filled triangles. How do I fill
traingles?? : )*


--

  Gray Family

  clangray at fastmail.com







On Fri, Mar 24, 2017, at 02:58 AM, Sanette wrote:

> 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

> 

> 

> _________________________________________________

> SDL mailing list

> SDL at lists.libsdl.org

> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


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


More information about the SDL mailing list