Method: IleUI#draw

Defined in:
lib/Hashiparmentier/UI/IleUI.rb

#draw(window) ⇒ Object

Cette méthode permet de dessiner l’ile

param
  • window La fenetre sur laquelle l’ile va etre afficher



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/Hashiparmentier/UI/IleUI.rb', line 39

def draw(window)

  super(window)

  cr = window.create_cairo_context

  positionY = @taille * @casee.posY() + @taille/2
  positionX = @taille * @casee.posX() + @taille/2

  cr.set_source_rgb(255, 255, 255)
  cr.circle(positionY, positionX, @taille/2)
  cr.fill()

  choixCouleur(cr)

  cr.circle(positionY, positionX, @taille/2-1)

  if(@casee.getCapaciteResiduelle() <= 0)
    cr.fill()
    cr.set_source_rgb(255, 255, 255)
  else
    cr.stroke()
  end

  text = @casee.valeur.to_s()

  cr.select_font_face "Serif", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL
  cr.set_font_size @taille/2

  width = cr.text_extents(text).width
  height = cr.text_extents(text).height #Centrer le texte

  cr.move_to(positionY - width/2, positionX + height/2)
  cr.show_text(text)

end