bigger alpha-numerics

new topic     » topic index » view thread      » older message » newer message

Just a little bit of software I'm playing with , might be of interest
 to someone.
   This simply produces larger letters , including digits , without loading
  a dedicated font from disk or memory. Useful , perhaps , in the higher
  resolution screen modes.



Net-Tamer V 1.11 - Test Drive

-------------------------------------------------------------------------

----| bfurniss at ihug.co.nz |----
----|    21 may 2000      |----


--                     General Character Enlargement.
--                                 and
--                    High Resolution Charts [ graphs ]

--                             Progress Bar  ?

-------------------------------------------------------------------------
include graphics.e
include machine.e
include get.e

integer MODE--,u
atom x1,x2,y1,y2,pi,SCALE_X,SCALE_Y,SPACE_X,SPACE_Y,radius
object gm,s,t,av

gm=255 t=repeat(repeat({},16),gm) av=repeat({},gm) s=repeat({},16)
gm=0
pi=4*arctan(1)

x1=1 x2=1 y1=1 y2=1 pi=4*arctan(1) radius=12

-------------------------------------------------------------------------
use_vesa(1)
MODE=259
MODE=261
----------------------
if MODE=259 then
    SCALE_Y=1.5
    SCALE_X=1.2

    SCALE_Y=1.8
    SCALE_X=1.4
    SPACE_X=12

elsif MODE=261 then
    SCALE_Y=2
    SCALE_X=2
    SPACE_X=14
    SPACE_Y=14

    SCALE_Y=2
    SCALE_X=2
    SPACE_X=17
    SPACE_Y=22
    radius=.2

    SCALE_Y=20
    SCALE_X=20
    SPACE_X=170
    SPACE_Y=220
    radius=8

end if
----------------------
gm=graphics_mode(MODE)
text_color(15) bk_color(1)
-------------------------------------------------------------------------
procedure bead(atom u1,atom v1,atom u2,atom v2,atom r)
--                            draw a string of beads.
atom x,y
     x=0 y=0
    for t=0  to  1 by 0.1  do
     x=u1+(u2-u1)*t
     y=v1+(v2-v1)*t
     ellipse(15,1,{x,y},{x+r,y+r})
      pixel(15,{x,y})
    end for

end procedure

-------------------------------------------------------------------------

function char_map(sequence a)
--                                character to sequence.
sequence w
 w=repeat({},16)

 position(1,1)
 printf(1,"%s",{a})
 for i=1  to 16  do
    w[i]=get_pixel({0,i-1,8})
 end for

    return w
end function
-------------------------------------------------------------------------
procedure char_show(sequence a)
--                             show character sequence.
for i=1  to 16  do
    pixel(a[i],{42,i-1})
end for

end procedure
-------------------------------------------------------------------------
procedure char_show2(integer h,integer j,sequence a)
--                             show character sequence.
for i=1  to 16  do
    pixel(a[i],{42+h,j+i-1})
end for

end procedure
-------------------------------------------------------------------------
function f1(atom g)
--                           j --> x
    return x2+SCALE_X*g
end function
----------------------------------------------------
function f2(atom g)
--                           i --> y
    return y2+SCALE_Y*g
end function
----------------------------------------------------

----------------------------------------------------------------------------



procedure char_line(sequence a,integer colour)

--                         connect lines between adjacent dots.
atom x,y,b,c,d,e
integer k,l,m,n
sequence status
sequence u,v

  b=0 c=0 d=0 e=0
  u=repeat(0,9) v=u
  status=repeat(0,9)

for i=1  to 16  do
   for j=1  to  8  do

    for p=1  to 9  do
     status[p]=0
    end for

    if a[i][j]!=0 then --                               a:
       --                                 1
       status[1]=1
       x=f1(j)
       y=f2(i)
     pixel(15,{x,y})

     k=i-1
       if k<1 then k=1 end if
     l=i+1
       if l>16 then l=16 end if
     m=j-1
       if m<1 then m=1 end if
     n=j+1
       if n>8 then n=8 end if

      if a[k][j]!=0 then
     --                                  2
       u[2]=f1(j)        v[2]=f2(k)
       status[2]=1
--     draw_line(15,{{x,y},{u[2],v[2]}})
       bead(x,y,u[2],v[2],radius)
      end if
      if a[i][m]!=0 then
     --                                  3
       u[3]=f1(m)        v[3]=f2(i)
       status[3]=1
       bead(x,y,u[3],v[3],radius)
--     draw_line(15,{{x,y},{u[3],v[3]}})
      end if
      if a[l][j]!=0 then
     --                                  4
       u[4]=f1(j)        v[4]=f2(l)
       status[4]=1
       bead(x,y,u[4],v[4],radius)
--     draw_line(15,{{x,y},{u[4],v[4]}})
      end if
      if a[i][n]!=0 then
     --                                   5
       u[5]=f1(n)        v[5]=f2(i)
       status[5]=1
       bead(x,y,u[5],v[5],radius)
--     draw_line(15,{{x,y},{u[5],v[5]}})
      end if
      if a[k][m]!=0 then
     --                                   6
       u[6]=f1(m)        v[6]=f2(k)
       status[6]=1
       bead(x,y,u[6],v[6],radius)
--       draw_line(15,{{x,y},{u[6],v[6]}})
      end if
      if a[k][n]!=0 then
     --                                   7
       u[7]=f1(n)        v[7]=f2(k)
       status[7]=1
       bead(x,y,u[7],v[7],radius)
--       draw_line(15,{{x,y},{u[7],v[7]}})
      end if
      if a[l][m]!=0 then
     --                                    8
       u[8]=f1(m)        v[8]=f2(l)
       status[8]=1
       bead(x,y,u[8],v[8],radius)
--       draw_line(15,{{x,y},{u[8],v[8]}})
      end if
      if a[l][n]!=0 then
     --                                    9
       u[9]=f1(n)        v[9]=f2(l)
       status[9]=1
       bead(x,y,u[9],v[9],radius)
--       draw_line(15,{{x,y},{u[9],v[9]}})
      end if
------------------------------------------
--    if status[3]=1 and status[4]=1  then
--        polygon(colour,1,{{x,y},{u[3],v[3]},{u[4],v[4]},{x,y}})
--    end if
--    if status[4]=1 and status[5]=1  then
--        polygon(colour,1,{{x,y},{u[4],v[4]},{u[5],v[5]},{x,y}})
--    end if
--    if status[2]=1 and status[3]=1  then
--        polygon(colour,1,{{x,y},{u[2],v[2]},{u[3],v[3]},{x,y}})
--    end if
--    if status[2]=1 and status[5]=1  then
--        polygon(colour,1,{{x,y},{u[2],v[2]},{u[5],v[5]},{x,y}})
--    end if
------------------------------------------
    end if  --                                             a'
   end for
end for

end procedure

----------------------------------------------------------------------------


procedure xchar_sized(sequence a,integer x1,integer y1,atom x_size,atom y_si

ze)
--                         character bigger/smaller
atom x,y,u,v,scale
     scale=.4
     scale=.2

--     scale=.39

     x=0 y=0 u=0 v=0

for i=1  to 16  do
     y=y1+y_size*(i-scale)
     v=y+y_size*scale*2
     y=floor(y) v=floor(v)
   for j=1  to  8  do
     x=x1+x_size*(j-scale)
     u=x+x_size*scale*2
     x=floor(x) u=floor(u)
   if a[i][j]!=0 then
     ellipse(12,0,{x,y},{u,v})
   end if
   end for
end for

for i=1  to 16  do
     y=y1+y_size*(i-scale)
     v=y+y_size*scale*2
     y=floor(y) v=floor(v)
   for j=1  to  8  do
     x=x1+x_size*(j-scale)
     u=x+x_size*scale*2
     x=floor(x) u=floor(u)
   if a[i][j]!=0 then
     ellipse(a[i][j],1,{x,y},{u,v})
   end if
   end for
end for

end procedure

-------------------------------------------------------------------------

procedure char_sized(sequence a,integer x1,integer y1,atom x_size,atom y_siz

e,
integer chrome)
--                         character bigger/smaller
atom x,y,u,v,scale
     scale=.4
--     scale=.39

    x=0 y=0 u=0 v=0
for i=1  to 16  do
    y=y1+y_size*i
    v=y+1
    y=floor(y) v=floor(v)
   for j=1  to  8  do
       x=x1+x_size*j
       u=x+1
       x=floor(x) u=floor(u)
    if a[i][j]!=0 then
--       pixel(15,{x-1,y})
--       pixel(15,{x,y-1})
--       pixel(15,{x+1,y})
       pixel(chrome,{x,y+1})
--     pixel(chrome,{x,y+.5})
       pixel(chrome,{x,y})
--       ellipse(a[i][j],1,{x,y},{u,v})
    end if
   end for
end for

end procedure

-------------------------------------------------------------------------

procedure generate()
--                             generate ASCII for av,
--                              and pixel map for s.

for p=1  to  length(av)  do
  av[p]=sprintf("%s", p-1)
   t[p]= char_map(av[p])
end for

end procedure

-------------------------------------------------------------------------

procedure show3(sequence ag,atom x2,atom y2,integer steel)
--
integer k
    k=0
    if sequence(ag) then
       for i=1  to  length(ag)  do
        k=find(ag[i..i],av)
--           char_sized(t[k],x2+10*i-10,y2,1,1.45)
        char_sized(t[k],x2+10*i-10,y2,1,1.6,steel)
--           char_sized(t[k],x2+10*i-10,y2,1,1.42)
       end for
    end if

end procedure

-------------------------------------------------------------------------

procedure ascii()

for j=1  to  5  do
  for i=1  to  length(av)/5  do
   char_show2(i*12-24,j*18,t[i+(j-1)*length(av)/5])
  end for
end for


end procedure

-------------------------------------------------------------------------

global procedure chart(sequence a,integer u1,integer v1,integer u_wide,
integer u_high,integer gold)

--                          chart function.
atom u,v
u=0 v=0
s={}
s="f(t)=x(t)+y(t)"
s=a

   x1=u1-19 x2=u1+u_wide+19 y1=v1-20 y2=v1+u_high+20
   x1=u1 x2=u1+u_wide y1=v1-2 y2=v1+u_high-80+2
   x1=u1 x2=u1+u_wide y1=v1 y2=v1+u_high-80
   show3(s,u1,v1+u_high-70,gold)
   x1=u1 x2=u1+u_wide y1=v1 y2=v1+u_high-80
---------------------
    u=x1 v=y1
    s=0.5*(1+sin(2*pi*(u-x1)/(x2-x1)))*(y2-y1)+y1
for x=x1  to x2   do
   gm=0.5*(1+sin(2*pi*(x-x1)/(x2-x1)))*(y2-y1)+y1
    draw_line(15,{{x,gm},{u,s}})
--  pixel(15,{x,s})
    u=x s=gm
end for
---------------------

end procedure

-------------------------------------------------------------------------

 procedure key_in()
  --                     type characters using settable fonts.
atom u1,v1,k,u

    u1=4 v1=40 k=0 u=0

       s=-1
    while k!=27 do
       s=get_key()

      if atom(s) then
     k=s
      end if

      if k=13 then
      v1=v1+SPACE_Y u1=4
       elsif k!=-1 then
      s=sprintf("%s",s)
--         show3(s,u1,v1)
      u=find(s,av)
--         char_sized(t[u],u1,v1,SCALE_X,SCALE_Y,15)
--       x2=u1 y2=v1
--         xchar_sized(t[u],u1,v1,SCALE_X,SCALE_Y)
      char_line(t[u],15)
      u1=u1+SPACE_X
       elsif k=27 then
     exit
       else
      end if

    end while

 end procedure

----------------------------------------------------------------------------

procedure m1()
 generate()
 x1=8 y1=80
 s="f(t)=x(t)+y(t)"
 chart(s,80,100,200,300,10)
 s="x(t)=sin(t)"
 chart(s,200,20,340,360,15)
end procedure
-------------------------------------------------------------------------
procedure m2()
 generate()
-- ascii()
------
x1=8 y1=80
-- s=sprintf("%s",s)
-- s="Z"
-- position(12,8)
-- printf(1,"%s",s)
-- u=find(s,av)
------
--x2=x1 y2=y1
--char_line(t[u],15)
--         char_sized(t[u],u1,v1,SCALE_X,SCALE_Y)

 s="f(t)=x(t)+y(t)"
 chart(s,80,100,200,300,10)
 s="x(t)=sin(t)"
-- chart(s,200,20,340,360,15)
 --key_in()
end procedure
-------------------------------------------------------------------------
-------------------------------------------------------------------------
 m1()
 use_vesa(0)

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu