Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

How to Draw N-sided Regular Polygons [4/11]

4. Simplifying the Drawing of the Regular Triangle

On this page, the drawing procedure is much simpler. All three vertices p1 , p2 , p3 are now computed together in three consecutive statements. Then, those vertices are visualized by discs in the olive, azure and purple colors.
[Run the program by clicking the 'Run' button]

The center point still needs to exist, but there is no need to visualize the center point anymore. On the previous page, the center point was visualized in red, but now the visualization of the center point has been removed.
[Run the program by clicking the 'Run' button]

In the last statement of the source code, the call to the function trianglep is performed. It draws the blue triangle. The first three arguments of the function call are the three vertices. The last, fourth argument is the blue color.

If you like this tutorial, you can use the gray sharing buttons to share it with your friends. The sharing buttons create a link to the current page. The buttons for Twitter, Facebook, Pinterest, Reddit and LinkedIn are provided.

On the next page, the regular triangle is generated by using iteration.

Loading...