Bitmap/Midpoint circle algorithm: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added/changed comments and whitespace, changed indentations, simplified some code.) |
m (→{{header|FreeBASIC}}: minor change) |
||
Line 844: | Line 844: | ||
end subroutine draw_circle_sc</lang> |
end subroutine draw_circle_sc</lang> |
||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
<lang FreeBASIC>' version |
<lang FreeBASIC>' version 15-10-2016 |
||
' compile with: fbc -s |
' compile with: fbc -s gui |
||
' OR compile with: fbc -s gui |
|||
' Variant with Integer-Based Arithmetic from Wikipedia page: |
' Variant with Integer-Based Arithmetic from Wikipedia page: |
||
' Midpoint circle algorithm |
|||
Sub circle_(x0 As Integer, y0 As Integer , radius As Integer, Col As Integer) |
Sub circle_(x0 As Integer, y0 As Integer , radius As Integer, Col As Integer) |
||
Dim As Integer x = radius |
|||
Dim As Integer y |
|||
' Decision criterion divided by 2 evaluated at x=r, y=0 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
If decisionOver2 <= 0 Then |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
End Sub |
End Sub |
||
' ------=< MAIN >=------ |
' ------=< MAIN >=------ |
||
ScreenRes |
ScreenRes 600, 600, 32 |
||
Dim As Integer w, h, depth |
Dim As Integer w, h, depth |
||
Randomize Timer |
Randomize Timer |
||
Line 882: | Line 884: | ||
ScreenInfo w, h |
ScreenInfo w, h |
||
For i As Integer = |
For i As Integer = 1 To 10 |
||
circle_(Rnd * w, Rnd * h , Rnd * 200 , Int(Rnd *&hFFFFFF)) |
|||
Next |
Next |
||
'save screen to BMP file |
'save screen to BMP file |
||
BSave "Name.BMP", 0 |
|||
' empty keyboard buffer |
' empty keyboard buffer |
||
While |
While Inkey <> "" : Wend |
||
WindowTitle "hit any key to end program" |
|||
Sleep |
Sleep |
||
End</lang> |
End</lang> |