Advertisement
patricio_1979

Untitled

Mar 3rd, 2018
2,954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //Mapa de caracteres ASCII + Símbolo
  3. (
  4. var q,size = 20,font_general = ["Helvetica", 20];
  5. w = Window("Mapa de caracteres", Rect(20, Window.screenBounds.height - 500, 600, 400),scroll:true).front.alwaysOnTop_(true);
  6.  
  7. StaticText.new(w, Rect(5, 0, 30, 20)).string_("Font").align_(\right);
  8. m = PopUpMenu(w.view, Rect(40, 0, 250, 20));
  9. m.items = Font.availableFonts;
  10.  
  11. StaticText.new(w, Rect(290, 0, 28, 20)).string_("Size").align_(\right);
  12. y = PopUpMenu(w.view, Rect(322, 0, 50, 20));
  13. y.items = Array.series(100,20,2);
  14.  
  15. StaticText.new(w,Rect(10,30,300,30)).string_("Código ASCII / Símbolo asociado").font_(font_general);
  16.  
  17. //Iteraciones para el mapa de caracteres
  18. q=FlowLayout( w.view.bounds, 10@60, 20@5 );
  19. w.view.decorator = q;
  20.  
  21. 255.do{ |i|
  22.     var t, font = "Helvetica";
  23.     t=i.asAscii.asCompileString;
  24.     StaticText( w.view,(size*3)@(size) ).string_(i).font_(font_general);
  25.     StaticText( w.view,(size*3)@(size*3.5) ).string_(if (t.asString.contains(".asAscii")==true,{""},{(t.asString).replace("$","").replace("[","").replace("]","").replace("\,","").replace("\\","")})).font_(Font(font,size)).align_(\center);
  26.     q.nextLine;
  27. };
  28.  
  29. //Si le cambio al tipo de letra
  30. y.action = {
  31.     var nuevafont;
  32.     nuevafont = Font(m.items[m.value],y.items[y.value].asInteger);
  33.     510.do({|i| w.view.children[i+5].remove});
  34.     //q.remove;
  35.     q.reset;
  36.     255.do{ |i|
  37.     var t;
  38.     t=i.asAscii.asCompileString;
  39.         StaticText( w.view,((y.items[y.value].asInteger)*3)@(y.items[y.value].asInteger) ).string_(i).font_(font_general);
  40.         StaticText( w.view,((y.items[y.value].asInteger)*3)@((y.items[y.value].asInteger)*3.5) ).string_(if (t.asString.contains(".asAscii")==true,{""},{(t.asString).replace("$","").replace("[","").replace("]","").replace("\,","").replace("\\","")})).font_(nuevafont).align_(\center);
  41.     q.nextLine};
  42. };
  43.  
  44. //Si le cambio el tamaño
  45. m.action = y.action;
  46. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement