mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-28 02:09:59 +02:00
Fix spinner drawing
This commit is contained in:
@@ -13,21 +13,30 @@
|
|||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
Spinner::Spinner(Point position, Point size):
|
Spinner::Spinner(Point position, Point size):
|
||||||
Component(position, size), cValue(0)
|
Component(position, size), cValue(0),
|
||||||
|
tickInternal(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void Spinner::Tick(float dt)
|
void Spinner::Tick(float dt)
|
||||||
{
|
{
|
||||||
cValue += 0.05f;
|
tickInternal++;
|
||||||
|
if(tickInternal == 4)
|
||||||
|
{
|
||||||
|
cValue += 0.25f;//0.05f;
|
||||||
|
tickInternal = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Spinner::Draw(const Point& screenPos)
|
void Spinner::Draw(const Point& screenPos)
|
||||||
{
|
{
|
||||||
Graphics * g = ui::Engine::Ref().g;
|
Graphics * g = ui::Engine::Ref().g;
|
||||||
int baseX = screenPos.X+(Size.X/2);
|
int baseX = screenPos.X+(Size.X/2);
|
||||||
int baseY = screenPos.Y+(Size.Y/2);
|
int baseY = screenPos.Y+(Size.Y/2);
|
||||||
for(float t = 0.0f; t < 1.0f; t+=0.05f)
|
int lineInner = (Size.X/2);
|
||||||
|
int lineOuter = (Size.X/2)+3;
|
||||||
|
for(float t = 0.0f; t < 6.0f; t+=0.25f)
|
||||||
{
|
{
|
||||||
//g->drawblob(baseX+(sin(cValue+t)*(Size.X/2)), baseY+(cos(cValue+t)*(Size.X/2)), t*255, t*255, t*255);
|
//g->drawblob(baseX+(sin(cValue+t)*(Size.X/2)), baseY+(cos(cValue+t)*(Size.X/2)), t*255, t*255, t*255);
|
||||||
|
g->draw_line(baseX+(sin(cValue+t)*lineInner), baseY+(cos(cValue+t)*lineInner), baseX+(sin(cValue+t)*lineOuter), baseY+(cos(cValue+t)*lineOuter), (t/6)*255, (t/6)*255, (t/6)*255, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spinner::~Spinner()
|
Spinner::~Spinner()
|
||||||
|
@@ -16,6 +16,7 @@ namespace ui
|
|||||||
class Spinner: public Component
|
class Spinner: public Component
|
||||||
{
|
{
|
||||||
float cValue;
|
float cValue;
|
||||||
|
int tickInternal;
|
||||||
public:
|
public:
|
||||||
Spinner(Point position, Point size);
|
Spinner(Point position, Point size);
|
||||||
virtual void Tick(float dt);
|
virtual void Tick(float dt);
|
||||||
|
Reference in New Issue
Block a user