class IleUI
Auteur:: Brabant Mano Version:: 0.1 Date:: 09/04/2020
Cette classe permet d'afficher une ile de la grille
Public Class Methods
creer(ile, taille = 40)
click to toggle source
Ce constructeur permet de créer un nouveau afficheur d'ile
- param
-
ile L'ile à afficher
-
taille La taille d'une case (40 par defaut)
-
# File UI/IleUI.rb, line 25 def IleUI.creer(ile, taille = 40) new(ile, taille) end
Public Instance Methods
draw(window)
click to toggle source
Cette méthode permet de dessiner l'ile
- param
-
window La fenetre sur laquelle l'ile va etre afficher
-
# File UI/IleUI.rb, line 43 def draw(window) cr = window.create_cairo_context positionY = @taille * @casee.posY() + @taille/2 positionX = @taille * @casee.posX() + @taille/2 choixCouleur(cr) cr.circle(positionY, positionX, @taille/2) 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