Font Sizes

Post Reply
User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Font Sizes

Post 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
<
Attachments
Screenshot (46).png
Screenshot (46).png (267.22 KiB) Viewed 2496 times
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Font Sizes

Post 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()
<

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Font Sizes

Post 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
image.PNG (435.32 KiB) Viewed 2492 times

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Font Sizes

Post 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.
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Font Sizes

Post 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.

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Font Sizes

Post by rbytes »

Thanks. That information will take some digesting. :geek:
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Font Sizes

Post by Mr. Kibernetik »

rbytes wrote:
Mon Sep 18, 2017 4:52 am
Thanks. That information will take some digesting. :geek:
Please don't hesitate to ask if something is not clear enough - I will explain.

Post Reply