Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who is Online
17 user(s) are online (15 user(s) are browsing Forum)

Members: 0
Guests: 17

more...


Browsing this Thread:   1 Anonymous Users






Re: Raster and filled circles in PortablE
#7
Just can't stay away
Just can't stay away


See User information
any graphics optimization always is good especially for probably not very fast incoming Amiga netbook!

Posted on: 2011/10/25 17:30
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Raster and filled circles in PortablE
#6
Home away from home
Home away from home


See User information
I've PARTIALLY implemented circle drawing natively (i.e. using direct Amiga calls). I have also added drawing of unfilled boxes.

So those will be in the (still not quite ready) next beta r6 release.

Posted on: 2011/10/24 17:04
ChrisH
--
Author of the PortablE programming language.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Raster and filled circles in PortablE
#5
Just can't stay away
Just can't stay away


See User information
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
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Raster and filled circles in PortablE
#4
Home away from home
Home away from home


See User information
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
ChrisH
--
Author of the PortablE programming language.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Raster and filled circles in PortablE
#3
Just can't stay away
Just can't stay away


See User information
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
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Raster and filled circles in PortablE
#2
Home away from home
Home away from home


See User information
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
ChrisH
--
Author of the PortablE programming language.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Raster and filled circles in PortablE
#1
Just can't stay away
Just can't stay away


See User information
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
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 







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.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4462
2 nikolaos
nikolaos
4206
3 magorium
magorium
4095
4 phoenixkonsole
phoenixkonsole
3942
5 deadwood
deadwood
2917
6 ncafferkey
ncafferkey
2810
7 mazze
mazze
2222
8 Kalamatee
Kalamatee
2212
9 clusteruk
clusteruk
2114
Powered by XOOPS © 2001-2025 The XOOPS Project