|
-
Oct 18th, 2000, 03:02 PM
#1
I need to know how to make a shape go from the bottom of the a form to the top win a sin(?) curve(like a curvy line). heres a little diagram:
--Top of form---
/\
/
\
/
\
/
\
/
\
/
---Bottom Of Form---
thanks in advance
-
Oct 18th, 2000, 10:31 PM
#2
Fanatic Member
Yes, you can use the sine function to do that (or cosine, which is technically just a phase shifted sine... but that's enough trig). Here's a little sample.
Code:
Private Sub Form_Load()
Dim i As Single
Dim Pi As Single
'handy little expression for pi
Pi = 4 * Atn(1)
'these are just used to demonstrate
Me.ScaleWidth = 8
Me.ScaleHeight = 8 * Pi
Me.AutoRedraw = True
'by decreasing, it will appear to go upward
For i = Me.ScaleHeight to 0 Step -0.01
Me.PSet (Sin(i) + (Pi / 4), i), vbRed
Next i
End Sub
Sine functions have a general form of y = (A * sin(Bx)) + C (I didn't use the standard symbols because they don't exist in Courier New). Anyway, the shape of the graph can be changed by changing A B and C. Messing with A will change the amplitude, or how high and low it will go (in this case, how far to the right and left). Messing with B will change the period, and either squash or expand the curve itself (high B = highly squashed wave). Messing with C doesn't change the shape of the curve, but will move its position up or down (again, in this case to the left or right). The smaller the step gets, the smoother the curve will be, since it's just made of points. Since this is a trig function, using multiples of pi in setting the ScaleWidth/Height makes it look better. I'm sure that's more math than you wanted, but this should help. I love physics and chemistry btw.
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
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
|