Page 1 of 1
Font Sizes
Posted: Mon Sep 18, 2017 2:37 am
by rbytes
What a great addition - font names, styles and sizes! Here is a quick size demo from 10 to 140 point fonts in an attractive sans serif font named Candara
Code: Select all
z=10
t="The Quick Brown Fox"
#.fontname("Candara")
> y, 10..130, 10
#.drawcolor(#.hsv2rgb(y*3,1,1):3)
#.fontsize(y)
z *= 1.3
#.drawtext(20,y+z,t) 'draws text t at point x,y using current drawing
<
Re: Font Sizes
Posted: Mon Sep 18, 2017 3:20 am
by Mr. Kibernetik
Your example inspired me for this animated mess:
Code: Select all
w,h = #.scrsize()
#.angle(#.degrees)
lines = #.min(w,h)/20
iters = 200
> i, 1..lines
fx[i] = #.rnd(w)
fy[i] = #.rnd(h)
fs[i] = #.rnd(100)
fa[i] = #.rnd(360)
dx[i] = (#.rnd(1)-0.5)*3
dy[i] = (#.rnd(1)-0.5)*3
ds[i] = (#.rnd(1)-0.5)*3
da[i] = (#.rnd(1)-0.5)*2
r[i] = #.rnd(1)
g[i] = #.rnd(1)
b[i] = #.rnd(1)
<
#.scroff()
> j, 1..iters
#.scrclear()
> i, 1..lines
>> fs[i]<0
x = fx[i] ; y = fy[i]
#.drawreset()
#.drawrotate(x,y,fa[i])
#.fontsize(fs[i])
fs[i] += ds[i]
fx[i] += dx[i]
fy[i] += dy[i]
fa[i] += da[i]
#.drawcolor(r[i],g[i],b[i])
#.drawtext(x,y,"The Quick Brown Fox")
<
#.scr()
<
Re: Font Sizes
Posted: Mon Sep 18, 2017 3:38 am
by Mr. Kibernetik
Another animation - slight mod of your example:
Code: Select all
t="The Quick Brown Fox"
#.fontname("Candara")
z,n = 10
> y, 10..130, 10
#.fontsize(y)
z *= 1.3
> i, 1..n
#.drawcolor(#.hsv2rgb(y*3,i/n,i/n):3,i/n)
#.drawtext(20+i,y+z+i,t)
#.delay(0.04)
<
<
- image.PNG (435.32 KiB) Viewed 2491 times
Re: Font Sizes
Posted: Mon Sep 18, 2017 4:31 am
by rbytes
This animation is very impressive. Can you elaborate on exactly how the drawtext command creates the shadow effect? I am still unclear about the modifiers that follow the colon. I haven't found it in the manual.
Re: Font Sizes
Posted: Mon Sep 18, 2017 4:48 am
by Mr. Kibernetik
rbytes wrote: ↑Mon Sep 18, 2017 4:31 am
This animation is very impressive. Can you elaborate on exactly how the drawtext command creates the shadow effect? I am still unclear about the modifiers that follow the colon. I haven't found it in the manual.
This code:
Code: Select all
> i, 1..n
#.drawcolor(#.hsv2rgb(y*3 ,i/n ,i/n):3, i/n)
#.drawtext(20+i,y+z+i,t)
#.delay(0.04)
<
draws 10 lines of text shifted by i on x and y axis. Each line has its own color, defined by this code:
Code: Select all
#.drawcolor(#.hsv2rgb(y*3, i/n, i/n):3, i/n)
The function #.drawcolor can accept 4 arguments: R, G, B, A.
First 3 arguments (R, G, B) are submitted by #.hsv2rgb function which takes 3 values: H is y*3, S is i/n and V is i/n.
Number 3 after colon means that here we expect 3 values from #.hsv2rgb function. Alpha is 4th value and it is also i/n.
So, shadow is created by these 10 layers of text which become more bright, more saturated and more opaque each time.
Re: Font Sizes
Posted: Mon Sep 18, 2017 4:52 am
by rbytes
Thanks. That information will take some digesting.
Re: Font Sizes
Posted: Mon Sep 18, 2017 6:08 am
by Mr. Kibernetik
rbytes wrote: ↑Mon Sep 18, 2017 4:52 am
Thanks. That information will take some digesting.
Please don't hesitate to ask if something is not clear enough - I will explain.