Skip to content

Instantly share code, notes, and snippets.

@X-Raym
Created November 22, 2022 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save X-Raym/516dfe0a9a60a07dd07ab2421bc9d2c7 to your computer and use it in GitHub Desktop.
Save X-Raym/516dfe0a9a60a07dd07ab2421bc9d2c7 to your computer and use it in GitHub Desktop.
function pstring(str)
(
gfx_str_measure(str, txtw, txth);
gfx_x = (project_w-txtw)/2;
gfx_str_draw(str);
txth; // return text height
);
function domatch(fmt, txt)
(
ptr = 0;
strcpy(ptr, txt);
count = 0;
while
(
retval = match(fmt, ptr, ptr+2, ptr+1);
ptr += 2;
count += 1;
retval;
);
strcpy(ptr-1, ptr-2);
count; // return number of strings
);
#fmt = "%s\n%s";
#text="What do You think of that?\nAwesome!\nRight?"; // set to string to override
// match("%s\n%s",#text, #line1, #line2 ); // matches the LAST \n (not the first)
count = domatch(#fmt, #text);
gfx_r = 1;
gfx_y = 0;
loop(count,
gfx_y += pstring(2*count-1);
count -= 1;
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment