Page loading

Share your opinion
What do you think about gambaslinux.fr?
 
Interesting
It miss some informations
Excellent website
Results
WIDGETS GAMBAS
GAMBAS 3 SOFTWARES
TUTORIALS
Library
Use picture - Draw small cube in drawarea

Draw small cubes in  drawarea


codeqr.jpg

Here one small application to learn how to draw cubes in drawarea
Theses picture produce random cube impossible to use for what you think maybe and it's hre only for tutorial.
There is not code or compressed code inside. it's only ramndomized cube.

Here code of this small tutorial :
 
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

Youi will notice, since gambas 3.5, drawing function is direclty done in draww event of drawarea.
Thanks for your attention.
wink

Creation date : 06/02/2022 @ 00:27
Last update : 06/02/2022 @ 00:28
Category : Use picture
Page read 1702 times


Print the article Print the article


react.gifReactions to this article

Nobody gave a comment yet.
Be the first one to do it!


QUICK MENU
SEARCH




LANGUAGE
COMPONENTS
Other
LANGUAGE
Where, who?
VISITS

   visitors

   visitors online

ARCHIVES GAMBAS 1/2
^ Top ^