|
|
|
11-09-2019, 04:42 AM
|
#1
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
gfx.drawstr flags???
Having difficulty figuring out these 'flags'.
Here's the official documentation:
Lua: gfx.drawstr("str"[,flags,right,bottom])
Draws a string at gfx.x, gfx.y, and updates gfx.x/gfx.y so that subsequent draws will occur in a similar place.
If flags, right ,bottom passed in:- flags&1: center horizontally
- flags&4: center vertically
- flags&256: ignore right/bottom, otherwise text is clipped to (gfx.x, gfx.y, right, bottom)
I want to center justify, w/o doing it manually...
I've tried a handful of different combinations of inputs into the function, without avail.
Last edited by Dafarkias; 11-09-2019 at 04:48 AM.
|
|
|
11-09-2019, 05:02 AM
|
#2
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,967
|
flags=1 centers the text between gfx.y and gfx.drawstr's right parameter. The bottom parameter must also be set for it to take effect.
Code:
-- https://i.imgur.com/Dht1Y7g.gif
local CENTER_H = 1
local CENTER_V = 4
function loop()
gfx.x = 0
gfx.drawstr("Hello World!", CENTER_H | CENTER_V, gfx.w, gfx.h)
if gfx.getchar() >= 0 then
reaper.defer(loop)
end
end
gfx.init("", 400, 100)
gfx.setfont(1, "sans-serif", 24)
gfx.r, gfx.g, gfx.b = 1, 1, 1
loop()
Last edited by cfillion; 11-09-2019 at 05:37 AM.
|
|
|
11-09-2019, 05:18 AM
|
#3
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
Thank you!
Sorry about the small mess I made trying to upload my project map to ReaTeam, I think my error was that I messed up the formatting for the 'documentation' segment of the Upload Tool..
Is there a way I can specifically name my script using the Upload Tool, in its entirety?
|
|
|
12-09-2019, 01:59 PM
|
#4
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
flags=0 seems to be left-justify (and clip to right/bottom):
|
|
|
12-11-2019, 09:52 PM
|
#5
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
That is pretty sweet.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 08:45 PM.
|