improved rectangle
This commit is contained in:
@@ -57,7 +57,7 @@ namespace Render {
|
||||
_length(0),
|
||||
_rotation(0)
|
||||
{
|
||||
|
||||
setThickness(_thickness); // only to calc offset
|
||||
}
|
||||
|
||||
DrawableLine::~DrawableLine()
|
||||
@@ -82,7 +82,7 @@ namespace Render {
|
||||
res.x = t-(_thickness>>1);
|
||||
res.y = _rotation == 90 ? xx : _length-xx;
|
||||
} else {
|
||||
res = e->rotateXY(xx,t-(_thickness>>1),_rotation/180.0f*M_PI);
|
||||
res = e->rotateXY(xx,t-_ofst,_rotation/180.0f*M_PI);
|
||||
}
|
||||
e->setPixel(buf,res.x+o.x,res.y+o.y,getBlendMode());
|
||||
|
||||
@@ -113,15 +113,13 @@ namespace Render {
|
||||
void DrawableRectangle::createOutline(){
|
||||
auto e = engine();
|
||||
pos_t o = getOrigin();
|
||||
float cx,sx;
|
||||
auto rf = (_rotation % 360)/180.0f*M_PI;
|
||||
|
||||
if (l1 == nullptr) l1 = e->addDrawable<DrawableLine>();
|
||||
if (l2 == nullptr) l2 = e->addDrawable<DrawableLine>();
|
||||
if (l3 == nullptr) l3 = e->addDrawable<DrawableLine>();
|
||||
if (l4 == nullptr) l4 = e->addDrawable<DrawableLine>();
|
||||
|
||||
_rotation %= 360;
|
||||
sincosf(_rotation/180.0f*M_PI, &sx, &cx);
|
||||
|
||||
l1->setRotation(_rotation);
|
||||
l1->setLength(_dim.x);
|
||||
l1->setThickness(_thickness);
|
||||
@@ -135,10 +133,18 @@ namespace Render {
|
||||
l4->setLength(_dim.y);
|
||||
l4->setThickness(_thickness);
|
||||
|
||||
uint8_t of = l2->_ofst;
|
||||
pos_t res = {0,0};
|
||||
l1->setOrigin(o);
|
||||
l2->setOrigin({(p_t)(o.x+(_dim.x-_thickness+1)*cx), (p_t)(o.y+(_dim.x-_thickness+1)*sx)});
|
||||
l3->setOrigin({(p_t)(o.x-(_dim.y-_thickness+1)*sx), (p_t)(o.y+(_dim.y-_thickness+1)*cx)});
|
||||
l4->setOrigin(o);
|
||||
|
||||
res = e->rotateXY((_dim.x-of),0,rf);
|
||||
l2->setOrigin({(p_t)(o.x+res.x), (p_t)(o.y+res.y)});
|
||||
|
||||
res = e->rotateXY(0,(_dim.y-of),rf);
|
||||
l3->setOrigin({(p_t)(o.x+res.x), (p_t)(o.y+res.y)});
|
||||
|
||||
res = e->rotateXY(of,-of,rf);
|
||||
l4->setOrigin({(p_t)(o.x+res.x), (p_t)(o.y+res.y)});
|
||||
|
||||
l1->setDirty();
|
||||
l2->setDirty();
|
||||
|
||||
Reference in New Issue
Block a user