Is there an easy way to draw a triangular grid in C++?

I want to draw a grid of equilateral triangle using C++. Output suppose to be consist of multiple triangles.

Not like this type:
1
1 2
1 2 3

How do I proceed to make it from scratch?

My first priority is built from scratch, then the library.

Thank you in advance.
Output suppose to be consist of multiple triangles.
Not like this type:
1
1 2
1 2 3


So, like this then?
1
1 2
1 2 3


1
1 2
1 2 3


1
1 2
1 2 3
start with the math or the geometry.
you immediately see 3 or 4 useful ideas that might help:
3 series of lines will make such a grid. One sloped up, one down, and one flat.
a equilateral hexagon is made of 6 such triangles
the hexagon with 2 more triangles is a simple rhombus with 2 opposite 120 degree angles and 2 opposite 60 degree angles.
so you can cookie-cutter place any of {hexes, rhombi, or triangles} to make such a grid or you can draw a bunch of lines. The lines is the easy way. But any of it will work.
a slightly more advanced graphics approach can twist a pile of boxes into it.
Last edited on
@againtry, Yes it'll be lined.
Topic archived. No new replies allowed.