Page en cours de chargement

Donnez votre avis..
Que pensez-vous de gambaslinux.fr?
 
Interessant
Il manque des rubriques
excellent site
Résultats
INTERFACE GAMBAS
LOGICIELS GAMBAS 3
TUTORIELS
=Bibliothèque
Manipuler les images - Dessiner des petits carrés alléatoires

Dessiner des petits carrés dans une draw area


codeqr.jpg


Voici une petite application pour apprendre à dessiner des carrés dans une drawarea.
Ces carrés produisent un code inexploitable par et pour ce que vous savez et n'est là qu'à titre de démonstration.
Il n'y a aucun codage , seulement une génération alléatoire.

Voici le code de l'application :
 
Private z As Integer = 5


Public Sub Button1_Click()
DrawingArea1.Clear()
DrawingArea1.Refresh
End

Public Sub DrawingArea1_Draw()
qr
corner(1, 1)
corner(58, 1)
corner(1, 58)
mire(30, 5) 'top
mire(30, 30) 'center
mire(30, 56) 'bottom
mire(5, 30) 'left
mire(56, 30) 'right
mire(56, 56) 'right
End

Private Sub corner(mx As Integer, my As Integer)
Draw.LineStyle = 1
Draw.LineWidth = 1
Draw.foreground = Color.White
Draw.FillColor = Color.White
draw.FillStyle = Fill.Solid
Draw.Rect(mx * z - z, my * z - z, 9 * z, 9 * z)
Draw.LineStyle = 1
Draw.LineWidth = 1
Draw.foreground = Color.Black
Draw.FillColor = Color.Black
draw.FillStyle = Fill.Solid
Draw.Rect(mx * z, my * z, 7 * z, 7 * z)
Draw.LineStyle = 1
Draw.LineWidth = 1
Draw.foreground = Color.White
Draw.FillColor = Color.White
draw.FillStyle = Fill.Solid
Draw.Rect(mx * z + z, my * z + z, 5 * z, 5 * z)
Draw.LineStyle = 1
Draw.LineWidth = 1
Draw.foreground = Color.Black
Draw.FillColor = Color.Black
draw.FillStyle = Fill.Solid
Draw.Rect(mx * z + 2 * z, (my * z) + 2 * z, 3 * z, 3 * z)
Draw.LineStyle = 1
Draw.LineWidth = 1
End

Private Sub mire(mx As Integer, my As Integer)
Draw.LineStyle = 1
Draw.LineWidth = 1
Draw.foreground = Color.Black
Draw.FillColor = Color.Black
draw.FillStyle = Fill.Solid
Draw.Rect(mx * z, my * z, 5 * z, 5 * z)
Draw.LineStyle = 1
Draw.LineWidth = 1
Draw.foreground = Color.White
Draw.FillColor = Color.White
draw.FillStyle = Fill.Solid
Draw.Rect(mx * z + z, my * z + z, 3 * z, 3 * z)
Draw.LineStyle = 1
Draw.LineWidth = 1
Draw.foreground = Color.Black
Draw.FillColor = Color.Black
draw.FillStyle = Fill.Solid
Draw.Rect(mx * z + 2 * z, (my * z) + 2 * z, z, z)
Draw.LineStyle = 1
Draw.LineWidth = 1
End

Private Sub qr()
Dim a As Integer
Dim b As Integer
Dim c As Integer
For a = 1 To 64
  For b = 1 To 64
  c = Rnd(0, 2.1)
  If c < 0.5 Then
  Pblack(a, b)
  Endif
  If c > 0.5 Then
  Pwhite(a, b)
  Endif
Next
Next
End

Private Sub Pblack(mx As Integer, my As Integer)
Draw.LineStyle = 1
Draw.LineWidth = 1
Draw.foreground = Color.Black
Draw.FillColor = Color.Black
draw.FillStyle = Fill.Solid
Draw.Rect(mx * z, my * z, z, z)
Draw.LineStyle = 1
Draw.LineWidth = 1
End


Private Sub Pwhite(mx As Integer, my As Integer)
Draw.LineStyle = 1
Draw.LineWidth = 1
Draw.foreground = Color.white
Draw.FillColor = Color.white
draw.FillStyle = Fill.Solid
Draw.Rect(mx * z, my * z, z, z)
Draw.LineStyle = 1
Draw.LineWidth = 1
End

Public Sub Timer1_Timer()
DrawingArea1.Clear()
DrawingArea1.Refresh
End

Public Sub Button2_Click()
Timer1.Start()
End

Public Sub Button3_Click()
Timer1.Stop()
End

Vous remarqurez que depuis gambas 3.5, le dessin se fait directement dans l'évènement draw de la drawarea.
merci pour votre attention

Date de création : 06/02/2022 @ 00:27
Dernière modification : 06/02/2022 @ 00:28
Catégorie : Manipuler les images
Page lue 1285 fois


Imprimer l'article Imprimer l'article


react.gifRéactions à cet article

Personne n'a encore laissé de commentaire.
Soyez donc le premier !


ACCES RAPIDE
RECHERCHE




LES INSTRUCTIONS
Divers
INSTRUCTIONS
Où ça, qui ça?
VISITES

   visiteurs

   visiteurs en ligne

ARCHIVES GAMBAS 1/2
^ Haut ^