Modifications

Sauter à la navigation Sauter à la recherche
194 octets ajoutés ,  9 février 2018 à 12:08
Ligne 193 : Ligne 193 :     
{{traduction}}
 
{{traduction}}
The next bit of code will initialize the display library with <code>begin()</code> and clear the display with <code>clear()</code>and <code>display()</code>.
+
La portion de code ci-dessus, initialise la bibliothèque d'affichage avec {{fname|begin()}} et efface le contenu avec {{fname|clear()}} et {{fname|display()}} .
   −
Then it will configure a PIL drawing class to prepare for drawing graphics. Notice that the image buffer is created in 1-bit mode with the <code>'1'</code> parameter, this is important because the display only supports black and white colors.
+
Ensuite, nous configurons une classe PIL drawing pour dessiner des graphiques. La mémoire tampon de l'image est crée avec un bit de profondeur (mode avec paramètre {{fname|'1'}}. Ce mode est important puisque l'afficheur ne propose que deux couleurs noir et blanc.
   −
We then re-draw a large black rectangle to clear the screen. In theory we don't have to clear the screen again, but its a good example of how to draw a shape!
+
Ensuite nous redessinons un grand rectangle noir pour effacer effacer le contenu de l'écran (éteindre tous les pixels). En théorie, il n'est pas nécessaire d'effacer une seconde fois l'écran... mais c'est toujours un bonne idée de savoir comment dessiner une forme!
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
# Load default font.
+
# Charger la font par défaut.
 
font = ImageFont.load_default()
 
font = ImageFont.load_default()
   −
# Alternatively load a TTF font.
+
# Chargement d'une autre font TTF.
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
+
# D'autres fonts sont disponibles sur: http://www.dafont.com/bitmap.php
 
#font = ImageFont.truetype('Minecraftia.ttf', 8)
 
#font = ImageFont.truetype('Minecraftia.ttf', 8)
 
</syntaxhighlight>
 
</syntaxhighlight>
   −
Once the display is initialized and a drawing object is prepared, you can draw shapes, text and graphics using <a href="http://effbot.org/imagingbook/imagedraw.htm">PIL's drawing commands</a>. Here we are loading the <code>default</code> font, which works fine, but there's other fonts you can load.
+
Une fois l'afficheur initialisé et un objet dessin (ImageDrawing) préparé, vous pouvez dessiner des formes, du texte et des graphiques en utilisant [http://effbot.org/imagingbook/imagedraw.htm des commandes de dessin PIL]. Here we are loading the <code>default</code> font, which works fine, but there's other fonts you can load.
    
Next the code loads a built-in default font and draws a few lines of text. You can also load your own TrueType font and use it to render fancy text in any style you like
 
Next the code loads a built-in default font and draws a few lines of text. You can also load your own TrueType font and use it to render fancy text in any style you like
29 917

modifications

Menu de navigation