-
Jan 13th, 2022, 11:21 AM
#1
Thread Starter
Lively Member
(vb6) - Concentric square in picturebox minimum/maximum and opposite
I have on the form
1 timer
1 picture1
Through this code I produce concentric squares from the center of the picture to the maximum of the picture. And it works well.
Code:
Dim increase As Integer
Dim ratio As Single
Dim X As Integer
Dim Y As Integer
Private Sub Form_Load()
Picture1.ScaleMode = 3
ratio = Picture1.ScaleHeight / Picture1.ScaleWidth
X = Picture1.ScaleWidth / 2
Y = Picture1.ScaleHeight / 2
increase = 0
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
increase = increase + 10
Picture1.Line (X - (increase), Y - (increase * ratio))-(X + (increase), Y + (increase * ratio)), vbRed, B
If X - increase < 0 Then
Picture1.Cls ' here the cycle starts again
X = Picture1.ScaleWidth / 2
Y = Picture1.ScaleHeight / 2
increase = 0
End If
End Sub
I would like to get the opposite now: that is, once the squares have reached the maximum they must do the opposite, from the outside to the central point of the picture. And continue from the inside to the maximum and from the maximum to the center. I tried with
Code:
increase = increase - 10
and maybe add a timer but it doesn't work. Where to modify to succeed in my intent?
Thanks
-
Jan 13th, 2022, 06:35 PM
#2
Re: (vb6) - Concentric square in picturebox minimum/maximum and opposite
Use INC as Increment amount
Code:
Dim increase As Integer
Dim ratio As Single
Dim X As Integer
Dim Y As Integer
Dim INC As Integer
Private Sub Form_Load()
INC = 10
Picture1.ScaleMode = 3
ratio = Picture1.ScaleHeight / Picture1.ScaleWidth
X = Picture1.ScaleWidth / 2
Y = Picture1.ScaleHeight / 2
increase = 0
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
increase = increase + INC
Picture1.Line (X - (increase), Y - (increase * ratio))-(X + (increase), Y + (increase * ratio)), vbRed, B
If X - increase < 0 Or X - increase > Picture1.ScaleWidth / 2 Then
INC = -INC ' Invert direction
Picture1.Cls ' here the cycle starts again
End If
End Sub
-
Jan 14th, 2022, 02:04 AM
#3
Thread Starter
Lively Member
Re: (vb6) - Concentric square in picturebox minimum/maximum and opposite
Reexre,
i immediately tested the tip. And... excellent and quick solution !
Now I integrate the routine into the program and the problem
is already solved at the first shot. Thank you.
Really fantastic this approach.
Thanks.
-
Jan 14th, 2022, 10:58 PM
#4
Lively Member
Re: (vb6) - Concentric square in picturebox minimum/maximum and opposite
Made a concentric Rectangle Program with mouse drag operation.
You can adjust the line width, gap size and change colour.
Its over here on GitHub: https://github.com/BoleeMan/Concentric-Rectangles
Click Code and then Download Zip
Enjoy.
Last edited by CreativeDreamer; Jan 14th, 2022 at 11:04 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|