Browsing this Thread:
1 Anonymous Users
|
Re: Raster and filled circles in PortablE
|
||||
|---|---|---|---|---|
|
Just can't stay away
![]() |
any graphics optimization always is good especially for probably not very fast incoming Amiga netbook!
Posted on: 2011/10/25 17:30
|
|||
|
||||
|
Re: Raster and filled circles in PortablE
|
||||
|---|---|---|---|---|
|
Just can't stay away
![]() |
OK, I not check it - so PortablE need unfilled box - for completing possible simple graphics procedures. It should be coded like your circle modification - with "TRUE" options
Posted on: 2011/10/20 17:59
|
|||
|
||||
|
Re: Raster and filled circles in PortablE
|
||||
|---|---|---|---|---|
|
Home away from home
![]()
|
Quote:
For primitive graphics Box (filled) is still needed Sorry, I don't understand. DrawBox() already draws a filled rectangle.
Posted on: 2011/10/20 16:23
|
|||
|
||||
|
Re: Raster and filled circles in PortablE
|
||||
|---|---|---|---|---|
|
Just can't stay away
![]() |
OK,
It's good idea adding it in PortablE modules. Code start "living" after appear in documentation so I not worrying anymore how it is done and not see another, increasing my source, code. For primitive graphics Box (filled) is still needed. And maybe in future author should add something special - no existed in any language like "drawTriangle" :)
Posted on: 2011/10/20 13:08
|
|||
|
||||
|
Re: Raster and filled circles in PortablE
|
||||
|---|---|---|---|---|
|
Home away from home
![]()
|
Thanks for your code! I have taken the opportunity to make it smaller & clean it up:
<pre>/* Drawing Cirlce source wikipedia:http://en.wikipedia.org/wiki/Midpoint_circle_algorithm 19-10-2011 - PortablE code by mrdarek 20-10-2011 - Cleaned-up by Chris Handley */ MODULE 'std/cGfxSimple' PROC main() DEF quit:BOOL, type, subType, value, value2 ->open window IsDesktopApp() OpenWindow(800, 600) ->prepare the 'canvas' for drawing Clear(RGB_BLACK) SetColour(RGB_RED) drawCircle(300,300,30) ->empty circle SetColour(RGB_BLUE) drawCircle(500,500,50,TRUE) ->filled circle ->event loop quit := FALSE REPEAT ->wait for an event from the window WaitForGfxWindowEvent() type, subType, value, value2 := GetLastEvent() SELECT type CASE EVENT_WINDOW ->allow the user to close the program by pressing the window's close button IF subType = EVENT_WINDOW_CLOSE THEN quit := TRUE ENDSELECT UNTIL quit CloseWindow() FINALLY PrintException() ENDPROC PROC drawCircle(x, y, radius, filled=FALSE:BOOL) DEF f, ddF_x, ddF_y, xPos, yPos f := 1 - radius ddF_x := 1 ddF_y := -2 * radius xPos := 0 yPos := radius IF filled DrawLine(x, y + radius, x, y - radius) DrawLine(x + radius, y, x - radius, y) ELSE DrawDot(x, y + radius) DrawDot(x, y - radius) DrawDot(x + radius, y) DrawDot(x - radius, y) ENDIF WHILE xPos < yPos /* ddF_x == 2 * xPos + 1; ddF_y == -2 * yPos; f == xPos*xPos + yPos*yPos - radius*radius + 2*xPos - yPos + 1; */ IF (f >= 0) yPos-- ddF_y := ddF_y+2 f := f + ddF_y ENDIF xPos++ ddF_x := ddF_x+2 f := f+ddF_x IF filled DrawLine(x + xPos, y + yPos, x - xPos, y + yPos) DrawLine(x + xPos, y - yPos, x - xPos, y - yPos) DrawLine(x + yPos, y + xPos, x - yPos, y + xPos) DrawLine(x + yPos, y - xPos, x - yPos, y - xPos) ELSE DrawDot(x + xPos, y + yPos) DrawDot(x - xPos, y + yPos) DrawDot(x + xPos, y - yPos) DrawDot(x - xPos, y - yPos) DrawDot(x + yPos, y + xPos) DrawDot(x - yPos, y + xPos) DrawDot(x + yPos, y - xPos) DrawDot(x - yPos, y - xPos) ENDIF ENDWHILE ENDPROC</pre> I will also add this to PortablE's cGfx module. It should be a good "fall-back" until I can implement it directly with real Amiga Graphics+Intuition calls.
Posted on: 2011/10/20 10:41
|
|||
|
||||
|
Raster and filled circles in PortablE
|
||||
|---|---|---|---|---|
|
Just can't stay away
![]() |
because I need this procedures I "port" code from wikipedia. Here is my job - free for all:
<pre> /* Drawing Cirlce source wikipedia:http://en.wikipedia.org/wiki/Midpoint_circle_algorithm PortablE code: mrdarek */ MODULE 'std/cGfxSimple' PROC main() DEF quit:BOOL, type, subType, value, value2 ->open window IsDesktopApp() OpenWindow(800, 600) ->prepare the 'canvas' for drawing Clear(RGB_BLACK) SetColour(RGB_RED) rasterCircle(300,300,30) SetColour(RGB_BLUE) filledCircle(500,500,50) ->event loop quit := FALSE REPEAT ->wait for an event from the window WaitForGfxWindowEvent() type, subType, value, value2 := GetLastEvent() SELECT type CASE EVENT_WINDOW ->allow the user to close the program by pressing the window's close button IF subType = EVENT_WINDOW_CLOSE THEN quit := TRUE ENDSELECT UNTIL quit CloseWindow() FINALLY PrintException() ENDPROC PROC rasterCircle(x0:INT, y0:INT, radius:INT) DEF f:INT DEF ddF_x:INT DEF ddF_y:INT DEF x:INT DEF y:INT f:=1-radius ddF_x := 1 ddF_y := -2 * radius x := 0 y := radius DrawDot(x0, y0 + radius) DrawDot(x0, y0 - radius) DrawDot(x0 + radius, y0) DrawDot(x0 - radius, y0) WHILE (x < y) -> ddF_x == 2 * x + 1 -> ddF_y == -2 * y -> f == x*x + y*y - radius*radius + 2*x - y + 1 IF (f >= 0) y-- ddF_y := ddF_y+2 f := f + ddF_y!!INT ENDIF x++ ddF_x := ddF_x+2 f := f+ddF_x!!INT DrawDot(x0 + x, y0 + y) DrawDot(x0 - x, y0 + y) DrawDot(x0 + x, y0 - y) DrawDot(x0 - x, y0 - y) DrawDot(x0 + y, y0 + x) DrawDot(x0 - y, y0 + x) DrawDot(x0 + y, y0 - x) DrawDot(x0 - y, y0 - x) ENDWHILE ENDPROC PROC filledCircle(x0:INT, y0:INT, radius:INT) DEF f:INT DEF ddF_x:INT DEF ddF_y:INT DEF x:INT DEF y:INT f:=1-radius ddF_x := 1 ddF_y := -2 * radius x := 0 y := radius /* DrawDot(x0, y0 + radius) DrawDot(x0, y0 - radius) DrawDot(x0 + radius, y0) DrawDot(x0 - radius, y0) */ DrawLine(x0, y0 + radius, x0, y0 - radius) DrawLine(x0 + radius, y0, x0 - radius, y0) WHILE (x < y) -> ddF_x == 2 * x + 1; -> ddF_y == -2 * y; -> f == x*x + y*y - radius*radius + 2*x - y + 1; IF (f >= 0) y-- ddF_y := ddF_y+2 f := f + ddF_y!!INT ENDIF x++ ddF_x := ddF_x+2 f := f+ddF_x!!INT /* DrawDot(x0 + x, y0 + y) DrawDot(x0 - x, y0 + y) DrawDot(x0 + x, y0 - y) DrawDot(x0 - x, y0 - y) DrawDot(x0 + y, y0 + x) DrawDot(x0 - y, y0 + x) DrawDot(x0 + y, y0 - x) DrawDot(x0 - y, y0 - x) */ DrawLine(x0 + x, y0 + y, x0 - x, y0 + y) DrawLine(x0 + x, y0 - y, x0 - x, y0 - y) DrawLine(x0 + y, y0 + x, x0 - y, y0 + x) DrawLine(x0 + y, y0 - x, x0 - y, y0 - x) ENDWHILE ENDPROC </pre>
Posted on: 2011/10/19 16:49
|
|||
|
||||
You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.






