|
|
|
03-28-2020, 09:19 AM
|
#1
|
Human being with feelings
Join Date: Oct 2018
Posts: 173
|
Quick gfx question
Hi
How do you make a line break in regular text in gfx?
thanks /danerius
|
|
|
03-28-2020, 09:51 AM
|
#2
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,622
|
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")
|
|
|
03-28-2020, 09:53 AM
|
#3
|
Human being with feelings
Join Date: Oct 2018
Posts: 173
|
Quote:
Originally Posted by mespotine
gfx.drawstr("One\nTwo")
|
Awesome. Thanks
/danerius
|
|
|
03-28-2020, 09:55 AM
|
#4
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,622
|
Added another code-snippet, in case you need to have line-breaks with multiple gfx.drawstr-functioncalls.
|
|
|
03-28-2020, 10:20 AM
|
#5
|
Human being with feelings
Join Date: Oct 2018
Posts: 173
|
Quote:
Originally Posted by mespotine
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");
|
|
|
03-28-2020, 10:33 AM
|
#6
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,622
|
In your case, just add gfx.texth to gfx.y after every gfx.drawstr-funcioncall and it should work.
|
|
|
03-28-2020, 12:11 PM
|
#7
|
Human being with feelings
Join Date: Oct 2018
Posts: 173
|
Quote:
Originally Posted by mespotine
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);
|
|
|
03-28-2020, 03:24 PM
|
#8
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,622
|
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
Last edited by Meo-Ada Mespotine; 03-28-2020 at 03:34 PM.
|
|
|
03-29-2020, 12:02 AM
|
#9
|
Human being with feelings
Join Date: Oct 2018
Posts: 173
|
Quote:
Originally Posted by mespotine
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
|
|
|
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 AM.
|