Post Reply 
Custom Text Formatting (Previously: Getting long results in a program)
03-31-2024, 04:34 PM
Post: #27
RE: Getting long results in Program
The solution I mentioned utilizes the ICON object. A particular characteristic of ICON is that you can also draw on it exactly the same way as on G0-G9. The only limitation here is that you must specify the maximum buffer size in advance (or buffers, as it's often better to have several small ones instead of one large). By defining such a buffer, you assume that you will draw something on it, so during its definition, we can assume that it is entirely in a uniform color. This makes its size relatively small in the source code. Then it doesn't matter whether the buffer is 20x20 pixels or 320x240 pixels because it will occupy a similar amount of space in the source code.

Here is an example of using a buffer based on ICON for drawing transparent text:

Code:
EXPORT DRAWTEXT_P(text,x,y,font,alpha)
BEGIN
LOCAL size=TEXTSIZE(text,font);
RECT_P("buffer");
TEXTOUT_P(text,"buffer",1,1,7);
BLIT_P(x,y,"buffer",1,1,size[1],size[2],#FFFFFF,alpha);
END;

ICON buffer 89504E470D0A1A0A0000000D49484452000001400000001A0100000000EE89B822000000027​4524E5300010194FDAE0000001D494441547801EDCA31010000008230FA97D60AFEB27B6464341A8​F63015D3D0C2DD86ED4F60000000049454E44AE426082;

In this example, I used a buffer with a size of 320x28 pixels because that is sufficient to draw text at the maximum font size using TEXTOUT_P.

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Getting long results in Program - komame - 03-31-2024 04:34 PM
RE: Custom Text Formatting - Tyann - 04-15-2024, 06:55 PM
RE: Custom Text Formatting - komame - 04-15-2024, 07:42 PM
RE: Custom Text Formatting - Tyann - 04-16-2024, 04:38 AM
RE: Custom Text Formatting - komame - 04-16-2024, 06:02 AM



User(s) browsing this thread: 73 Guest(s)