Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Rendering a simple filled triangle with a flat color to the screen

Author
Message
jayandy
21
Years of Service
User Offline
Joined: 14th Sep 2004
Location:
Posted: 8th Jan 2011 00:00 Edited at: 8th Jan 2011 00:05
Sorry, Wrong Forum Place for me to post. This contains no code.

Hi,

I know 3d maths, but I'm stuck on the basics. I'm trying to start simple in graphics programming, I'd like to know how to draw a simple filled 2d triangle the screen.

I'd like to start with a triangle using "dot x,y" commands, then move to drawing it to memory then to the screen for preformance.

Also, drawing a correctly filled circle would be a great help too!

Thanks,

Jay
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Jan 2011 06:44
Right-triangle would be simple. Any kind of triangle would be slightly trickier, but shouldn't be too hard.

Given a triangle defined by the points ABC, you can figure out 3 line segments.

A
B C

In line AB, start at point A and traverse towards B. Plot a pixel on that line and move horizontally. Move onto the next line when you've reached line segment AC. Once you reach point B, do the same for BC again moving towards AC. This will fill any missing spots if the triangle happens to be rotated.

Hopefully that made sense.

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein

Login to post a reply

Server time is: 2026-07-18 05:06:06
Your offset time is: 2026-07-18 05:06:06