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.

Code Snippets / [DBP] Code to create any gradiated triangle in 2D

Author
Message
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 26th Sep 2007 09:38 Edited at: 26th Sep 2007 09:40


Origx,origy: offset position (also position of point 1)
abx,aby: position of point 2 relative to point 1
cdx,cdy: position of point 3 relative to point 1

origcol,abcol,cdcol: Colors of each corner of the triangle.

"I don't like it, and I'm sorry I ever had anything to do with it" - Erwin Schrodinger
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 26th Sep 2007 09:44
To draw a polygon(octagon in this example) set the centre as origx,origy

Set point 1 as abx,aby and point 2 to cdx,cdy
Draw triangle
Set point 2 as abx,aby and point 3 to cdx,cdy
Draw triangle
Set point 3 as abx,aby and point 4 to cdx,cdy
Draw triangle
Set point 4 as abx,aby and point 5 to cdx,cdy
Draw triangle
Set point 5 as abx,aby and point 6 to cdx,cdy
Draw triangle
Set point 6 as abx,aby and point 7 to cdx,cdy
Draw triangle
Set point 7 as abx,aby and point 8 to cdx,cdy
Draw triangle
Set point 8 as abx,aby and point 1 to cdx,cdy
Draw triangle

All point positions should be realtive to the centre

"I don't like it, and I'm sorry I ever had anything to do with it" - Erwin Schrodinger
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Sep 2007 10:11
"Trilinear interpolation" is a hint for ya.


BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Sep 2007 11:07
Moved to code snippets

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Sep 2007 19:23
DBC Version


In programming, nothing exists
da power pwnerer
18
Years of Service
User Offline
Joined: 28th Jul 2006
Location: Pittsburgh, PA
Posted: 29th Sep 2007 16:57 Edited at: 29th Sep 2007 16:58
Press 'SPACE' to form new triangle


ends after three spaces


http://Freewebs.com/noobisoft
Come to Noobisoft's website today!

Login to post a reply

Server time is: 2024-11-22 13:46:45
Your offset time is: 2024-11-22 13:46:45