Polygon() Function- Textured, Colored, Rotatable Shapes

Previous topic - Next topic


This is something i whipped up today..

You can texture a circular polyvector with color masks for the center and edge of the circle.
It will blend nicely, and you can animate the colors, instead of animating with multiple textures.

Really, its a simple function to use, however, I attached a simple button project here also.
You can use a radius collision instead of boxcoll for better accuracy...it is just a quick sample.
To make a circle, you need to set the function to use 36 sides.
If you use the angle input, keep in mind, this rotates the shape, not the image.

Code (glbasic) Select

FUNCTION DRAWPOLYGON: TextureBMP, X, Y, Radius, EdgeColor, CenterColor, Sides, Angle
//Function creates a filled polygon of specified radius
// Where:
// xy = center of image
// radius = width from center, ie you make this the width of image divided by 2, width/2
// triangles = # of Sides for polygon
// angle = rotate the shape, not the image.

LOCAL Tstep=360.0/Sides
FOR Cir = 0 TO 359 STEP Tstep
CirXS = X + Radius * COS( Cir + Angle )
CirYS = Y + Radius * SIN( Cir + Angle )
CirXE = X + Radius * COS( Cir + Angle - Tstep )
CirYE = Y + Radius * SIN( Cir + Angle - Tstep )
POLYVECTOR CirXS, CirYS, CirXS - X - Radius, CirYS - Y - Radius, EdgeColor
POLYVECTOR CirXE, CirYE, CirXE - X - Radius, CirYE - Y - Radius, EdgeColor
POLYVECTOR X, Y, -Radius, -Radius, CenterColor


Here is the sample button project(screenshot is below the link):

[attachment deleted by admin]
Bing ChatGpt is pretty smart :O


I <3 DGArray's :D

AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard


Thanks F

I optimized the function, it had redundant math in the texuring part:

Bing ChatGpt is pretty smart :O

Kitty Hello