I found an issue with my FC SUB. Sometimes balls had stripes in them, when assigning cx/xy values that ended in .5, (like 100.5) and the radius didn't, (like 50). (It didn't happen if the radius also ended in .5)
I think it's because I was not using integer for those values. It was an easy fix - after declaring all three of those values as integers the balls will now always display without any artifacts no matter what values you give.
The program below shows the problem and fixed SUB (you may have to go fullscreen to see the stripes in the first set of balls.)
- Dav
I think it's because I was not using integer for those values. It was an easy fix - after declaring all three of those values as integers the balls will now always display without any artifacts no matter what values you give.
The program below shows the problem and fixed SUB (you may have to go fullscreen to see the stripes in the first set of balls.)
- Dav
Code: (Select All)
Screen _NewImage(1000, 800, 32)
'old one that shows stripes
fc.old 200.5, 200.5, 100, _RGB(255, 255, 255, 255), 0
fc.old 200.5, 400.5, 100, _RGB(255, 255, 255, 255), 1
'new one that shows normal
fc.new 400.5, 200.5, 100, _RGB(255, 255, 255, 255), 0
fc.new 400.5, 400.5, 100, _RGB(255, 255, 255, 255), 1
Sub fc.old (cx, cy, radius, clr~&, grad)
If radius = 0 Then Exit Sub ' safety bail
If grad = 1 Then
red = _Red32(clr~&)
grn = _Green32(clr~&)
blu = _Blue32(clr~&)
alpha = _Alpha32(clr~&)
End If
r2 = radius * radius
For y = -radius To radius
x = Sqr(r2 - y * y)
' If doing gradient
If grad = 1 Then
For i = -x To x
dis = Sqr(i * i + y * y) / radius
red2 = red * (1 - dis) + (red / 2) * dis
grn2 = grn * (1 - dis) + (grn / 2) * dis
blu2 = blu * (1 - dis) + (blu / 2) * dis
clr2~& = _RGBA(red2, grn2, blu2, alpha)
Line (cx + i, cy + y)-(cx + i, cy + y), clr2~&, BF
Next
Else
Line (cx - x, cy + y)-(cx + x, cy + y), clr~&, BF
End If
Next
End Sub
Sub fc.new (cx As Integer, cy As Integer, radius As Integer, clr~&, grad)
If radius = 0 Then Exit Sub ' safety bail
If grad = 1 Then
red = _Red32(clr~&)
grn = _Green32(clr~&)
blu = _Blue32(clr~&)
alpha = _Alpha32(clr~&)
End If
r2 = radius * radius
For y = -radius To radius
x = Sqr(r2 - y * y)
' If doing gradient
If grad = 1 Then
For i = -x To x
dis = Sqr(i * i + y * y) / radius
red2 = red * (1 - dis) + (red / 2) * dis
grn2 = grn * (1 - dis) + (grn / 2) * dis
blu2 = blu * (1 - dis) + (blu / 2) * dis
clr2~& = _RGBA(red2, grn2, blu2, alpha)
Line (cx + i, cy + y)-(cx + i, cy + y), clr2~&, BF
Next
Else
Line (cx - x, cy + y)-(cx + x, cy + y), clr~&, BF
End If
Next
End Sub