characters_example.anubis 2.67 KB

read tools/basis.anubis   

   
define String str = "Welcome to System Fonts !". 
   
   
define One
   draw_string
     (
       RGBAImage fond, 
       Rectangle clip, 
       String s, 
       Int32 x, 
       Int32 y,
       SystemCharacterSize size, 
       RGBA color,
       Int32 i
     ) =
   if nth(i,s) is 
     {
       failure then unique, 
       success(c) then 
         with w = draw_system_character(fond,clip,x,y,size,word8_to_int32(c),color),
         draw_string(fond,clip,s,x+w,y,size,color,i+1)
     }.
   
define RGBA black = rgba(0,0,0,255). 
   
define One
   try_draw_chars
     (
       RGBAImage fond, 
       Rectangle clip,
       RGBA bg, 
       RGBA lbg,
       RGBA dbg
     ) =
   forget(draw_system_character(fond,clip,10,50,_18pt,'A',rgba(0,0,0,255)));
   forget(draw_system_character(fond,clip,30,50,_18pt,'B',rgba(255,0,0,255)));
   forget(draw_system_character(fond,clip,50,50,_22pt,'C',rgba(255,255,0,255)));
   forget(draw_system_character(fond,clip,72,52,_38pt,'D',rgba(127,127,127,255)));
   forget(draw_system_character(fond,clip,70,50,_38pt,'D',rgba(0,0,255,255)));
   
   draw_string(fond,clip,str,11,71,_18pt,rgba(200,200,220,255),0);
   draw_string(fond,clip,str,10,70,_18pt,rgba(200,0,255,255),0);
   
   draw_string(fond,clip,str,13,102,_22pt,rgba(200,200,220,255),0);
   draw_string(fond,clip,str,10,100,_22pt,rgba(0,0,255,255),0);
   
   draw_string(fond,clip,str,11,151,_38pt,lbg,0);
   draw_string(fond,clip,str,9,149,_38pt,dbg,0);
   draw_string(fond,clip,str,10,150,_38pt,bg,0);
   
   draw_string(fond,clip,str,11,201,_38pt,dbg,0);
   draw_string(fond,clip,str,9,199,_38pt,lbg,0);
   draw_string(fond,clip,str,10,200,_38pt,bg,0);
   
   forget(draw_system_character(fond,clip,10,230,_18pt,35,black));
   forget(draw_system_character(fond,clip,20,230,_18pt,36,black));
   forget(draw_system_character(fond,clip,30,230,_18pt,37,black)).
   
   
global define One
   essai_characters
     (
       List(String) args
     ) =
   with clip = rect(0,0,500,400), 
        bg = rgba(255,190,100,255), 
        lbg = rgba(255,240,100,255), 
        dbg = rgba(255,140,100,255), 
        fond = create_rgba_image(500,400,bg),
      try_draw_chars(fond,clip,bg,lbg,dbg); 
   with host_fond = to_host_image(fond,1),
   forget(open_host_window(rect(0,0,500,400),
                           "Essai Caractères",
                           managed,
                           (HostWindow win, Rectangle r) |-> paint_image(win,r,0,0,host_fond),
                           (HostWindow win, HostWindowEvent(One) e) |-> 
                              if e is expose then [clip] else [],
                           (List(HostWindowEvent(One)) l) |-> l 
                          )).