BGRABitmap tutorial 6/fr: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: BGRABitmap tutorial 6/fr
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Ce tutoriel montre comment utiliser les différents styles de lignes et les formes. | |
| 2 | + | ||
| 3 | + | ### Création d'un nouveau projet | |
| 4 | + | ||
| 5 | + | Créez un nouveau projet et ajoutez la référence à [[BGRABitmap]], de la même façon que dans [[BGRABitmap tutorial/fr|le premier tutoriel]]. | |
| 6 | + | ||
| 7 | + | ### Ajout d'un dessin | |
| 8 | + | ||
| 9 | + | Avec l'inspecteur de projet, ajoutez un gestionnaire *OnPaint* : | |
| 10 | + | ||
| 11 | + | ``` pascal | |
| 12 | + | procedure TForm1.FormPaint(Sender: TObject); | |
| 13 | + | var image: TBGRABitmap; | |
| 14 | + | c: TBGRAPixel; | |
| 15 | + | begin | |
| 16 | + | image := TBGRABitmap.Create(ClientWidth, ClientHeight, clBtnFace); | |
| 17 | + | c := clWindowText; | |
| 18 | + | ||
| 19 | + | image.RectangleAntialias(80,80,300,200, c, 50); | |
| 20 | + | ||
| 21 | + | image.Draw(Canvas,0,0,True); | |
| 22 | + | image.free; | |
| 23 | + | end; | |
| 24 | + | ``` | |
| 25 | + | ||
| 26 | + | ### Exécution du programme | |
| 27 | + | ||
| 28 | + | Vous devriez obtenir un rectangle avec un pinceau noir épais : | |
| 29 | + | ||
| 30 | + | <figure> | |
| 31 | + | <img src="BGRATutorial6a.png" title="BGRATutorial6a.png" /> | |
| 32 | + | <figcaption>BGRATutorial6a.png</figcaption> | |
| 33 | + | </figure> | |
| 34 | + | ||
| 35 | + | ### Changer le style de jointures | |
| 36 | + | ||
| 37 | + | Si vous voulez des coins ronds, vous pouvez spécifier : | |
| 38 | + | ||
| 39 | + | ``` pascal | |
| 40 | + | image.JoinStyle := pjsRound; | |
| 41 | + | ``` | |
| 42 | + | ||
| 43 | + | ### Exécution du programme | |
| 44 | + | ||
| 45 | + | Le programme devrait dessiner à présent un rectangle avec des coins arrondis : | |
| 46 | + | ||
| 47 | + | <figure> | |
| 48 | + | <img src="BGRATutorial6b.png" title="BGRATutorial6b.png" /> | |
| 49 | + | <figcaption>BGRATutorial6b.png</figcaption> | |
| 50 | + | </figure> | |
| 51 | + | ||
| 52 | + | ### Mélanger les styles de jointures | |
| 53 | + | ||
| 54 | + | Vous pouvez mélanger les styles de jointures comme ceci : | |
| 55 | + | ||
| 56 | + | ``` pascal | |
| 57 | + | image.FillRoundRectAntialias(80,80,300,200, 20,20, c, [rrTopRightSquare,rrBottomLeftSquare]); | |
| 58 | + | ``` | |
| 59 | + | ||
| 60 | + | Cette fonction utilise des coins ronds par défaut, mais vous pouvez les remplacer par des coins carrés ou en biseau. Vous devriez obtenir l'image suivante : | |
| 61 | + | ||
| 62 | + | <figure> | |
| 63 | + | <img src="BGRATutorial6e.png" title="BGRATutorial6e.png" /> | |
| 64 | + | <figcaption>BGRATutorial6e.png</figcaption> | |
| 65 | + | </figure> | |
| 66 | + | ||
| 67 | + | ### Changer le style de ligne | |
| 68 | + | ||
| 69 | + | Vous pouvez dessiner une ligne en pointillés comme cela : | |
| 70 | + | ||
| 71 | + | ``` pascal | |
| 72 | + | image.JoinStyle := pjsBevel; | |
| 73 | + | image.PenStyle := psDot; | |
| 74 | + | image.DrawPolyLineAntialias([PointF(40,200), PointF(120,100), PointF(170,140), PointF(250,60)],c,10); | |
| 75 | + | ``` | |
| 76 | + | ||
| 77 | + | Notez que l'extrémité de la ligne est arrondie. | |
| 78 | + | ||
| 79 | + | <figure> | |
| 80 | + | <img src="Tutorial6c.png" title="Tutorial6c.png" /> | |
| 81 | + | <figcaption>Tutorial6c.png</figcaption> | |
| 82 | + | </figure> | |
| 83 | + | ||
| 84 | + | ### Changer les extrémités des lignes | |
| 85 | + | ||
| 86 | + | Vous pouvez dessiner une polyligne avec des extrémités carrées comme cela : | |
| 87 | + | ||
| 88 | + | ``` pascal | |
| 89 | + | image.JoinStyle := pjsBevel; | |
| 90 | + | image.LineCap := pecSquare; | |
| 91 | + | image.PenStyle := psSolid; | |
| 92 | + | image.DrawPolyLineAntialias([PointF(40,200), PointF(120,100), PointF(170,140), PointF(250,60)],c,10); | |
| 93 | + | ``` | |
| 94 | + | ||
| 95 | + | <figure> | |
| 96 | + | <img src="BGRATutorial6d.png" title="BGRATutorial6d.png" /> | |
| 97 | + | <figcaption>BGRATutorial6d.png</figcaption> | |
| 98 | + | </figure> | |
| 99 | + | ||
| 100 | + | ### Dessin d'une ligne ouverte | |
| 101 | + | ||
| 102 | + | Vous pouvez dessiner une ligne qui est ouverte, c'est-à-dire que la fin de la ligne est arrondie à l'intérieur. | |
| 103 | + | ||
| 104 | + | ``` pascal | |
| 105 | + | image.DrawPolyLineAntialias([PointF(40,200), PointF(120,100), PointF(170,140), PointF(250,60)],c,10,False); | |
| 106 | + | ``` | |
| 107 | + | ||
| 108 | + | <figure> | |
| 109 | + | <img src="BGRATutorial6f.png" title="BGRATutorial6f.png" /> | |
| 110 | + | <figcaption>BGRATutorial6f.png</figcaption> | |
| 111 | + | </figure> | |
| 112 | + | ||
| 113 | + | De cette façon, vous pouvez connecter des lignes les unes après les autres sans dessiner la jonction deux fois, ce qui est utile avec le dessin semi-transparent. Vous pouvez comparer comme cela : | |
| 114 | + | ||
| 115 | + | ``` pascal | |
| 116 | + | c := BGRA(0,0,0,128); | |
| 117 | + | ||
| 118 | + | image.DrawLineAntialias(40,150, 120,50, c, 10); | |
| 119 | + | image.DrawLineAntialias(120,50, 170,90, c, 10); | |
| 120 | + | image.DrawLineAntialias(170,90, 250,10, c, 10); | |
| 121 | + | ||
| 122 | + | image.DrawLineAntialias(40,250, 120,150, c, 10, False); | |
| 123 | + | image.DrawLineAntialias(120,150, 170,190, c, 10, False); | |
| 124 | + | image.DrawLineAntialias(170,190, 250,110, c, 10, True); | |
| 125 | + | ``` | |
| 126 | + | ||
| 127 | + | <figure> | |
| 128 | + | <img src="Tutorial6g.png" title="Tutorial6g.png" /> | |
| 129 | + | <figcaption>Tutorial6g.png</figcaption> | |
| 130 | + | </figure> | |
| 131 | + | ||
| 132 | + | [[BGRABitmap tutorial 5/fr|Tutoriel précédent (couches et masques)]] [[BGRABitmap tutorial 7/fr|Tutoriel suivant (splines)]] | |
| 133 | + | ||
| 134 | + | --- | |
| 135 | + | *From the Free Pascal wiki, page "BGRABitmap tutorial 6/fr", as it stood on 2024-02-15 after a change by Circular, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
