Old 03-28-2020, 09:19 AM   #1
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default Quick gfx question

Hi

How do you make a line break in regular text in gfx?

thanks /danerius
danerius is offline   Reply With Quote
Old 03-28-2020, 09:51 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,622
Default

gfx.drawstr("One\nTwo")

If you want to draw multiple lines with multiple gfx.drawstr, you need to "reset" gfx.x to the start-position of the text and change the gfx.y-position by textheight.

So if the text starts at x=20, you write:

Code:
gfx.drawstr("One")
gfx.x=0 -- go to the startposition
gfx.y=gfx.y+gfx.texth -- move y position by textheight
gfx.drawstr("Two")
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is online now   Reply With Quote
Old 03-28-2020, 09:53 AM   #3
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default

Quote:
Originally Posted by mespotine View Post
gfx.drawstr("One\nTwo")
Awesome. Thanks

/danerius
danerius is offline   Reply With Quote
Old 03-28-2020, 09:55 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,622
Default

Added another code-snippet, in case you need to have line-breaks with multiple gfx.drawstr-functioncalls.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is online now   Reply With Quote
Old 03-28-2020, 10:20 AM   #5
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default

Quote:
Originally Posted by mespotine View Post
Added another code-snippet, in case you need to have line-breaks with multiple gfx.drawstr-functioncalls.
Excellent. I was just gonna ask... It works in the example you provided but not when I put the ”\n” where I wanted a line break. This is the code I tried. Im want a line break after ”(srate, 0);”

Code:
gfx_drawstr("Samplerate: \n"); gfx_drawnumber(srate, 0); 
gfx_drawstr(" RMS: "); gfx_drawnumber(rmsDB,1);
gfx_drawstr(" 1/4 Note: "); gfx_drawnumber(wholenote,1);
gfx_drawstr(" One\n Two");
danerius is offline   Reply With Quote
Old 03-28-2020, 10:33 AM   #6
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,622
Default

In your case, just add gfx.texth to gfx.y after every gfx.drawstr-funcioncall and it should work.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is online now   Reply With Quote
Old 03-28-2020, 12:11 PM   #7
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default

Quote:
Originally Posted by mespotine View Post
In your case, just add gfx.texth to gfx.y after every gfx.drawstr-funcioncall and it should work.
Thanks Is the gfx a part of C code? Or is it strictly JSFX?

Im trying to make a simple info box that converts note lengths to milliseconds based on the project tempo. So a grid layout would look good. Is there a way to make grids/tabels or do I simply set gfx_x + gfx_y to where I want the text?

/danerius

The code Ive ended up with so far...

Code:
@gfx
gfx_setfont(1,"candara",18);

gfx_x = gfx_y = 20; //x, y position
gfx_r = gfx_g = gfx_b = 1; gfx_a = 1; //RGB plus alpha

gfx_drawstr("Samplerate: "); gfx_drawnumber(srate, 0);
gfx_x = 20; gfx_y = gfx_y + gfx_texth;

gfx_drawstr(" RMS: "); gfx_drawnumber(rmsDB,1);
gfx_x = 20; gfx_y = gfx_y + gfx_texth;

gfx_drawstr(" 1/4 Note: "); gfx_drawnumber(wholenote,1);
danerius is offline   Reply With Quote
Old 03-28-2020, 03:24 PM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,622
Default

EEL(though JSFX uses EEL as well).

I can't really help you with EEL, as I only code in Lua, but setting gfx_x and gfx_y the way you want is the way to go.

So if you want tables, you need to code the whole thing from scratch, but AFAIK, you can limit the space needed by gfx_drawstr, so it doesn't go over a certain area, which could be helpful for coding cells.

If you want to go that far
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...

Last edited by Meo-Ada Mespotine; 03-28-2020 at 03:34 PM.
Meo-Ada Mespotine is online now   Reply With Quote
Old 03-29-2020, 12:02 AM   #9
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default

Quote:
Originally Posted by mespotine View Post
EEL(though JSFX uses EEL as well).

I can't really help you with EEL, as I only code in Lua, but setting gfx_x and gfx_y the way you want is the way to go.

So if you want tables, you need to code the whole thing from scratch, but AFAIK, you can limit the space needed by gfx_drawstr, so it doesn't go over a certain area, which could be helpful for coding cells.

If you want to go that far
Ive never worked in Lua. It might be easier to this in Lua. I wouldnt know

Gonna check a tutorial for it. Thanks for all your help. /danerius
danerius 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 AM.


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