Everything works as expected just disappointed with the drawing quality. The problem is all the drawing functions use integer values not floats/doubles so you cannot use fractional poistioning (using Sin & Cos) to create smooth curves and fills.
There's always a way around things so I'll leave this for now and move on to the next widget (definitely going to came back to this, not a happy bunny, lol).
I'm new to GE and am hoping to learn stuff by sharing and experimenting. Feel free to alter and improve all my wiget codes. Hopefully, when I've completed the library with all the widgets I can get on with sharing actual games/apps that I make from using them (and add all the graphic frills and pretty colours for later advanced versions of these).
You can get the bar to flow anticlockwise (barFlow = 0) or clockwise (barFlow = 1). Add global code provided as arcBar and arcBar (your preferences here); code to the canvas that you are using for the arcBar. See my other widget posts for more details on usage ( http://game-editor.com/forum/viewtopic.php?f=8&t=12376 ).
If you manage to improve drawing quality please post here if you can. Here's the culprits, GE canvas drawing functions all use int.
SOURCE: http://game-editor.com/docs/script_reference.htm
setpen
Define the actual pen for the Event Actor
void setpen(int r, int g, int b, double transp, int pensize)
r: red component (0 - 255)
g: green component (0 - 255)
b: blue component (0 - 255)
transparency: (0.0 - 1.0)
pensize: size of pen
moveto
Move the Event Actor's pen to (x, y) coordinates.
void moveto(int x, int y)
lineto
Draw a line on Event Actor to (x, y) coordinates using actual pen
void lineto(int x, int y)
putpixel
Draw a single pixel on Event Actor in (x, y) coordinates using actual pen.
void putpixel(int x, int y)
GLOBAL CODE
- Code: Select all
void arcBar(int barValue, int barFlow, int barMax, int barStart, int barRadius, int barHeight, int border_R, int border_G, int border_B, int back_R, int back_G, int back_B, int fill_R, int fill_G, int fill_B)
{
int bar_i=0;
int itsCentre=barHeight+barRadius+1;
// --------------------------- Create background ----------------------
setpen(back_R, back_G, back_B, 0.0, 1);
for (bar_i=barStart; bar_i <= barStart+barMax; bar_i++)
{
moveto ((barRadius+1) * sin(degtorad(bar_i))+itsCentre, (barRadius+1) * cos(degtorad(bar_i))+itsCentre);
lineto ((barRadius+barHeight) * sin(degtorad(bar_i))+itsCentre, (barRadius+barHeight) * cos(degtorad(bar_i))+itsCentre);
}
// --------------------------- Create border ----------------------
setpen(border_R, border_G, border_B, 0.0, 1);
for (bar_i=barStart; bar_i <= barStart+barMax; bar_i++)
{
putpixel(barRadius * sin(degtorad(bar_i))+itsCentre, barRadius * cos(degtorad(bar_i))+itsCentre);
}
for (bar_i=barStart; bar_i <= barStart+barMax; bar_i++)
{
putpixel((barRadius+barHeight+1) * sin(degtorad(bar_i))+itsCentre, (barRadius+barHeight+1) * cos(degtorad(bar_i))+itsCentre);
}
moveto ((barRadius+barHeight+1) * sin(degtorad(barStart))+itsCentre, (barRadius+barHeight+1) * cos(degtorad(barStart))+itsCentre);
lineto (barRadius * sin(degtorad(barStart))+itsCentre, barRadius * cos(degtorad(barStart))+itsCentre);
moveto ((barRadius+barHeight+1) * sin(degtorad(barStart+barMax))+itsCentre, (barRadius+barHeight+1) * cos(degtorad(barStart+barMax))+itsCentre);
lineto (barRadius * sin(degtorad(barStart+barMax))+itsCentre, barRadius * cos(degtorad(barStart+barMax))+itsCentre);
// --------------------------- Create Value Bar ----------------------
if(barFlow==0)
{
// flow is Anti-clockwise
setpen(fill_R, fill_G, fill_B, 0.0, 1);
for (bar_i=barStart+1; bar_i <= barStart+barValue; bar_i++)
{
moveto ((barRadius+1) * sin(degtorad(bar_i))+itsCentre, (barRadius+1) * cos(degtorad(bar_i))+itsCentre);
lineto ((barRadius+barHeight-1) * sin(degtorad(bar_i))+itsCentre, (barRadius+barHeight-1) * cos(degtorad(bar_i))+itsCentre);
}
}
else
{
// flow is clockwise
setpen(fill_R, fill_G, fill_B, 0.0, 1);
for (bar_i=barStart+barMax-1; bar_i >= (barStart+barMax)-barValue; bar_i--)
{
moveto ((barRadius+1) * sin(degtorad(bar_i))+itsCentre, (barRadius+1) * cos(degtorad(bar_i))+itsCentre);
lineto ((barRadius+barHeight-1) * sin(degtorad(bar_i))+itsCentre, (barRadius+barHeight-1) * cos(degtorad(bar_i))+itsCentre);
}
}
}
More widgets to come...