Skip to content

Conversation

@Oso-Grande
Copy link

Added DrawRotatedStringDecal() and DrawRotatedStringPropDecal() which render text at any angle using any offset as the centre point.

@OneLoneCoder
Copy link
Owner

Heh, I was looking to implement this, and it never occurred to me to use the rotation offset.... duh... lol 😂

@Boltie
Copy link

Boltie commented Mar 24, 2021

I needed to add this function last year except I just copied DrawStringDecal and amended it to use DrawPartialRotatedDecal. I also named it DrawStringRotatedDecal as that seemed to fit the naming convention better. There are some differences to the commit here but I've no idea which would be better. I just know the below worked well for my use.

void PixelGameEngine::DrawStringRotatedDecal(const olc::vf2d& pos, const std::string& sText, const float fAngle, const olc::vf2d& center, const Pixel col, const olc::vf2d& scale)
{
olc::vf2d spos = { 0.0f, 0.0f };
for (auto c : sText)
{
if (c == '\n')
{
spos.x = 0; spos.y += 8.0f * scale.y;
}
else
{
int32_t ox = (c - 32) % 16;
int32_t oy = (c - 32) / 16;
DrawPartialRotatedDecal(pos + spos, fontDecal, fAngle, center, { float(ox) * 8.0f, float(oy) * 8.0f }, { 8.0f, 8.0f }, scale, col);
spos.x += 8.0f * scale.x;
}
}
}

@OneLoneCoder OneLoneCoder added the ACCEPTED A feature that will be implemented label Jun 3, 2021
OneLoneCoder added a commit that referenced this pull request Jun 3, 2021
FIX Emscripten JS formatting in VS IDE (thanks Moros)
+"Headless" Mode
+DrawLineDecal()
+Mouse Button Constants
+Move Constructor for olc::Renderable
+Polar/Cartesian conversion for v2d_generic
+DrawRotatedStringDecal()/DrawRotatedStringPropDecal() (thanks Oso-Grande/Sopadeoso (PR #209))
=Using olc::Renderable for layer surface
+Major Mac and GLUT Update (thanks Mumflr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ACCEPTED A feature that will be implemented NEEDS TESTING

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants