Old 11-09-2019, 04:42 AM   #1
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default 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&2: right justify
  • flags&4: center vertically
  • flags&8: bottom justify
  • 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.
__________________

Support my feature request!

Last edited by Dafarkias; 11-09-2019 at 04:48 AM.
Dafarkias is offline   Reply With Quote
Old 11-09-2019, 05:02 AM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,967
Default

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.
cfillion is offline   Reply With Quote
Old 11-09-2019, 05:18 AM   #3
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

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?
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 12-09-2019, 01:59 PM   #4
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

flags=0 seems to be left-justify (and clip to right/bottom):

spk77 is offline   Reply With Quote
Old 12-11-2019, 09:52 PM   #5
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

That is pretty sweet.
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.