Advertisement
PifyZ

Exercice du lundi n°4 en BootMonkey

Jul 15th, 2014
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.13 KB | None | 0 0
  1. use stdio as io
  2.  
  3. const SIZE = 20
  4.  
  5. # Saisie
  6. io.write("Saisie (ex : 3E 7F FC F8 F8 FC 7F 3E) : ")
  7.  
  8. drawing = io.read().upperCase()
  9.  
  10. # Valeur par défaut
  11. if drawing.length <> 23 {
  12.   drawing = "3E 7F FC F8 F8 FC 7F 3E"
  13. }
  14.  
  15. new_drawing = [ "" for i from 0 to 8 ]
  16.  
  17. y = 0
  18.  
  19. for i from 1 to drawing.length {
  20.   chr = drawing[i]
  21.  
  22.   new_drawing[y].add(switch chr {
  23.     when "0" { "0000" }
  24.     when "1" { "0001" }
  25.     when "2" { "0010" }
  26.     when "3" { "0011" }
  27.     when "4" { "0100" }
  28.     when "5" { "0101" }
  29.     when "6" { "0110" }
  30.     when "7" { "0111" }
  31.     when "8" { "1000" }
  32.     when "9" { "1001" }
  33.     when "A" { "1010" }
  34.     when "B" { "1011" }
  35.     when "C" { "1100" }
  36.     when "D" { "1101" }
  37.     when "E" { "1110" }
  38.     when "F" { "1111" }
  39.   })
  40. }
  41.  
  42. # Simplifié volontairement
  43.  
  44. # title, width, height
  45. win = new Window("Rendu graphique", SIZE * 8, SIZE * 8)
  46.  
  47. # x, y, width, height
  48. can = new Canvas(0, 0, SIZE * 8, SIZE * 8)
  49.  
  50. can.set_fill_color(0, 0, 0)
  51.  
  52. for y from 0 to 7 {
  53.   for x from 0 to 7 {
  54.     if new_drawing[y][x] == "1" {
  55.       can.fill_rect(x * SIZE, y * SIZE, SIZE, SIZE)
  56.     }
  57.   }
  58. }
  59.  
  60. win.add(can)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement