VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Generates randomly colored and randomly placed squares, lines, circles, boxes and all kinds of stuf

by VisualScope (20 Submissions)
Category: Graphics
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 7th July 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Generates randomly colored and randomly placed squares, lines, circles, boxes and all kinds of stuff! Would be great as a screen saver.

Rate Generates randomly colored and randomly placed squares, lines, circles, boxes and all kinds of stuf



'code takes care of the rest. To make it better set controlbox = false for form1
'
'
'=======================================================================================
'Well what can I say? This was just something I did cause
'I thought it would be fun and might teach people who didn't
'understand this stuff a lot. You can mess around a whole bunch
'with this code to make things go faster or slower. I only spent
'like 20 min on this so it might be uneffecent in some places but i really dont care.
'If you like this please go to my website at http://www.VisualScope.cjb.net
'and you can get others like it and more. You can contact me at
'[email protected] with suggestions, comments or such. Have fun with this
'and it would make a cool screensaver if I only knew how to make it one...
'And you cant take this section out of this code.
'
'Made By VisualScope
'======================================================================================


Public Sub drawline()
Dim x As Integer
Dim y As Integer
Dim linestart As Integer
Dim linefinish As Integer
Dim red As Integer
Dim blue As Integer
Dim green As Integer
red = 255 * Rnd 'randomize red color
blue = 255 * Rnd 'randomize blue color
green = 255 * Rnd 'randomize green color
x = Rnd * ScaleWidth
y = Rnd * ScaleHeight
linestart = Rnd * ScaleWidth
linefinish = Rnd * ScaleHeight
CurrentX = x
CurrentY = y
Line -(linestart, linefinish), RGB(red, blue, green)
End Sub
Public Sub drawsquare()
Dim red As Integer
Dim blue As Integer
Dim green As Integer
Dim xPos As Integer
Dim yPos As Integer
Dim x As Integer
Dim y As Integer
red = 255 * Rnd 'randomize red color
blue = 255 * Rnd 'randomize blue color
green = 255 * Rnd 'randomize green color
xPos = Rnd * ScaleWidth
yPos = Rnd * ScaleHeight
x = Rnd * ScaleWidth
y = Rnd * ScaleHeight
Line (x, y)-Step(xPos, yPos), RGB(red, blue, green), B
End Sub
Public Sub drawcircle()
Dim red As Integer
Dim blue As Integer
Dim green As Integer
Dim xPos As Integer
Dim yPos As Integer
Dim radius As Integer
red = 255 * Rnd 'randomize red color
blue = 255 * Rnd 'randomize blue color
green = 255 * Rnd 'randomize green color
xPos = Rnd * ScaleWidth
yPos = Rnd * ScaleHeight
radius = ((yPos * 0.99) + 1) * Rnd
Circle (xPos, yPos), radius, RGB(red, blue, green)
End Sub
Public Sub PixelSet() 'call pixelset
Dim red As Integer
Dim blue As Integer
Dim green As Integer
Dim randomx As Integer
Dim randomy As Integer
Dim x As Integer
Do Until x = 500 ' change the 999 to whatever you want to slow down or speed up the pixel change
x = x + 1
red = 255 * Rnd 'randomize red color
blue = 255 * Rnd 'randomize blue color
green = 255 * Rnd 'randomize green color
randomx = Rnd * ScaleWidth 'randomize x value
randomy = Rnd * ScaleWidth 'randomize y value
PSet (randomx, randomy), RGB(red, green, blue) 'set pixel color at (randomx, randomy) to RGB(red, green, blue)
Loop
End Sub
Private Sub Form_Click()
Unload Me
End
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
Form1.Cls 'clear the form
End Sub

Private Sub Form_Load()
Form1.Caption = ""
Form1.BorderStyle = 1
Form1.WindowState = 2
Form1.BackColor = &H0&
Timer1.Interval = 1
End Sub

Private Sub Timer1_Timer() 'you can change the timer speed to make things go slower
Call drawline
Call drawsquare
Call drawcircle
Call PixelSet
End Sub

Download this snippet    Add to My Saved Code

Generates randomly colored and randomly placed squares, lines, circles, boxes and all kinds of stuf Comments

No comments have been posted about Generates randomly colored and randomly placed squares, lines, circles, boxes and all kinds of stuf. Why not be the first to post a comment about Generates randomly colored and randomly placed squares, lines, circles, boxes and all kinds of stuf.

Post your comment

Subject:
Message:
0/1000 characters