Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 14:47:00 +0000



Post From: How to center text using sc.Graphics.DrawText?

[2023-11-25 19:43:16]
LudaTrades - Posts: 27
After some trial and error I got this to work with DrawTextInRectangle:

//int32_t (SCDLLCALL* DrawTextInRectangle)(const SCString& Text, const int32_t TextAnchorX, const int32_t TextAnchorY, const n_ACSIL::s_GraphicsRectangle& Rectangle, const uint32_t Options);

sc.Graphics.DrawTextInRectangle(TextToDraw, TextAnchorX, TextAnchorY, TextRectangle, 2);

Setting a 2 for the "Options" parameter filled the whole rectangle and I was able to center with custom X and Y anchors. The option must be set or the rectangle will only draw around the text and not the rectangle coordinates.