VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A Colorful Ball of Light Function

by SethMicah (1 Submission)
Category: Graphics
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

This code will allow you to make a ball of light of any size and color, ready to go in a module! Please vote.

Inputs
frm As Form, originx As Integer, originy As Integer, radius As Integer, red As Integer, green As Integer, blue As Integer
Code Returns
Returns a filled ball of light on your form that displays a white center that ascends to any color of your choice.
Side Effects
Somewhat slow.. the bigger/more balls of light the slower it will get.

Rate A Colorful Ball of Light Function

Public Function MakeLight(frm As Form, originx As Integer, originy As Integer, radius As Integer, red As Integer, green As Integer, blue As Integer)
For tiltx = -0.5 To 0.5 Step 0.5 ' offset it a tad to get the pixels not colored
For tilty = -0.5 To 0.5 Step 0.5 ' offset it a tad to get the pixels not colored
For tempradius = 0 To radius Step 1 ' colors multiple circles with origins from the origin to origin + radius
Randomize
circlecolor = Int(Rnd * (1 * (radius / 255))) + (tempradius / (radius / 255)) + 1 ' gets a random color in a specific range, give it the light effect
circlecolor = Abs(circlecolor - 255) ' inverts the colors from white outside to white inside
frm.Circle (originx + tiltx, originy + tilty), tempradius, RGB(circlecolor + red, circlecolor + green, circlecolor + blue) ' makes the circle
Next tempradius
Next tilty
Next tiltx
End Function

Download this snippet    Add to My Saved Code

A Colorful Ball of Light Function Comments

No comments have been posted about A Colorful Ball of Light Function. Why not be the first to post a comment about A Colorful Ball of Light Function.

Post your comment

Subject:
Message:
0/1000 characters