|
Post by vovchik on Nov 1, 2015 21:46:35 GMT 1
Dear Peter (and all), Here is a little spiral generator that uses the NINA algorithm. It is very compact and produces some nice results. The source of the algorithm is in the code. With kind regards, vovchik Attachments:nina.tar.gz (11.91 KB)
|
|
|
Post by Pjot on Nov 1, 2015 22:08:25 GMT 1
Thanks vovchik, Very nice! The latest canvas 2.7 can be found here. BR Peter
|
|
|
Post by alexfish on Nov 1, 2015 23:19:06 GMT 1
Hi All Looks like a result with latest Bacon + latest canvas.bac works with Rasberry PI2 For Info . if have followed the bits on the Rasberry PI2 threads , one then has to install the MESA UTILS.. including the devs then from the terminal use the BaCon Gui as root sudo bacongui put the gui into fullscreen mode else U will get print through here is a picky of the original code demo code Many thanks to Peter , once again + thanks to Vovchik for the noted Improvements of the canvas.bac Now looking forward to further testing Edit :: STRANGE things happen ;; did a reboot else can get problems with the permissions on the temp files etc , IE the bacon gui can crash out Now using the gui in user mode . but added a sync after the create window , now there is no print through BR Alex The code demo for Rasberry PI2 now looks like INCLUDE "canvas.bac"
WINDOW("Hello world", 640, 480) CALL SYNC() ' Pensize and anti-aliasing 'PEN(3, 1)
' Rotate line, circle, square ROTATION(45)
' Square INK(255,0,0,255) SQUARE(270, 130, 150, 80, 1) INK(0,0,0,255) SQUARE(270, 130, 150, 80, 0)
' Circle INK(0,255,0,255) CIRCLE(120, 120, 70, 190, TRUE) INK(0,0,0,255) CIRCLE(120, 120, 70, 190, FALSE)
' Some lines ROTATION(0) INK(0,0,255, 255) LINE(80, 30, 500, 40) LINE(500, 40, 350, 220) LINE(350, 220, 10, 250) LINE(10, 250, 80, 30)
' Triangle FOR x = 0 TO 360 STEP 10 ROTATION(x) INK(20+x, 50, 120, 255) TRIANGLE(100+x, 300, 100, 80, TRUE) INK(0,0,0,255) TRIANGLE(100+x, 300, 100, 80, FALSE) NEXT
' Paint irregular area INK(255,0,255, 255) PAINT(200, 200)
' Text INK(0,128,255,255) TEXT("Hello world! This is the High Performance Canvas based on OpenGL.", 20, 400)
' Paint rest of the screen INK(255, 255, 0, 255) PAINT(1, 1)
' Key ends WAITKEY Attachments:
|
|
|
Post by vovchik on Nov 2, 2015 8:10:19 GMT 1
Dear Alex,
I see that you are making great strides on PI. Great work!
With kind regards, vovchik
|
|
|
Post by alexfish on Nov 2, 2015 8:39:45 GMT 1
Hi Vovchik Well , have managed to get some bits working RE the Gl canvas yet have founds some basic bits need to be resolved , 1. the screen init size 2. the scaling factor if the above are not correct the hence , get a render fail + print through on the canvas to get a picture of the basic problem examine the code below , note the window size then the position of the SQUARE plus the width and height. along with the requested window size . Hence need to look further at the configs , etc the code + screen shot , also note my original screen shot + look at the position of the bits and note the text INCLUDE "canvas.bac"
WINDOW("Hello world",400, 400) CALL SYNC()
INK(255,0,214,255)
SQUARE(105,105, 100, 100, 1) SYNC() WAITKEY Attachments:
|
|
|
Post by vovchik on Nov 2, 2015 11:34:10 GMT 1
Dear Alex,
I see - there is some negative displacement from the outset in respect of SQUARE, so, somewhere along the line, the origin (0,0) is wrong. I wonder whether this isn't a TYPE issue. GL likes floats or doubles for some things and may be getting ints or longs. I wonder....
With kind regards, vovchik
|
|
|
Post by alexfish on Nov 2, 2015 16:34:52 GMT 1
Hi Vovchik
Think U may be correct esp when looking at the canvas.bac square , I assume from standard c casting the (x, y, xrad, yrad, fill) would be int
Maybe Peter could have a closer look at the functions etc in the canvas.bac
SUB SQUARE(x, y, xrad, yrad, fill)
CALL Draw_Prepare CALL Check_Scale(x-xrad, y-yrad, xrad, yrad) CALL Check_Rotation(x-xrad, y-yrad, xrad, yrad) CALL Check_Move()
IF fill THEN glBegin(GL_POLYGON) ELSE glBegin(GL_LINE_LOOP) ENDIF
glVertex2f(x-xrad, y-yrad) glVertex2f(x+xrad, y-yrad) glVertex2f(x+xrad, y+yrad) glVertex2f(x-xrad, y+yrad) glEnd
ENDSUB
BR Alex
|
|
|
Post by Pjot on Nov 2, 2015 20:57:59 GMT 1
Hi Alex,
Well, if it is a float/int issue what vovchik is hinting at, then the previous screenshot of the demonstration program "Hello world" would also show a wrong placement of the rectangle. But this is not the case.
I have seen similar problems in the old implementation of TEXT, which was using glTranslatef erroneously. This did impact other functions like PAINT and LINE.
So, which version of the canvas are you using?
Thanks Peter
|
|
|
Post by alexfish on Nov 2, 2015 21:39:20 GMT 1
Hi Alex, Well, if it is a float/int issue what vovchik is hinting at, then the previous screenshot of the demonstration program "Hello world" would also show a wrong placement of the rectangle. But this is not the case. I have seen similar problems in the old implementation of TEXT, which was using glTranslatef erroneously. This did impact other functions like PAINT and LINE. So, which version of the canvas are you using? Thanks Peter Hi Peter using the latest version of canvas.bac. Have done some further testing by inclusion of the glViewport , this positions and sizes correctly , so hence the glut window is correct have cross referenced the square with a my_square using floats , the square is at the same position . so yes , can rule out what i say about the float, yet can say at same time passing the correct type within a lib is important , esp when face with this type of problem. Now looking further , Raspberry PI Square wise , IE the text is at the correct position , but can say they are not the correct size IE:: do i need to change some defaults in the Scaling etc.. will update on success. BR Alex
|
|
|
Post by vovchik on Nov 3, 2015 8:12:10 GMT 1
Dear guys, Here are two little clocks made using canvas. Have fun. With kind regards, vovchik
|
|
|
Post by vovchik on Nov 3, 2015 8:21:13 GMT 1
Dear guys, And a few more demos... With kind regards, vovchik Attachments:
|
|
|
Post by alexfish on Nov 3, 2015 14:29:16 GMT 1
Hi Peter have look at the line loop for the square , have left the draw prepare as is this works on the Raspberry PI the SQUARE SUB SQUARE(x, y, xrad, yrad, fill)
CALL Draw_Prepare CALL Check_Scale(x-xrad, y-yrad, xrad, yrad) CALL Check_Rotation(x-xrad, y-yrad, xrad, yrad) CALL Check_Move()
IF fill THEN glBegin(GL_POLYGON) ELSE glBegin(GL_LINE_LOOP) ENDIF
glVertex2f(x, y) glVertex2f(x+xrad, y) glVertex2f(x+xrad, y+yrad) glVertex2f(x, y+yrad) glEnd
ENDSUB
demo code INCLUDE "canvas.bac"
WINDOW("Hello world",800,600) SYNC
INK(0,0,255,255)
SQUARE(5,5, 90, 90, 0)
INK(255,0,0,255)
SQUARE(95,95, 90, 90, 0)
SYNC
WAITKEY Line works as per lib . now looking further , have not checked for rotation etc as yet.. BR Alex A Picky of the demo Attachments:
|
|
|
Post by alexfish on Nov 3, 2015 14:54:05 GMT 1
The Rotation of the square where ROTATION = 45 INCLUDE "canvas.bac"
WINDOW("Hello world",800,600) SYNC
INK(0,0,255,255)
SQUARE(5,5, 90, 90, 1) ROTATION(45) INK(255,0,0,255)
SQUARE(95,95, 90, 90, 0)
SYNC
WAITKEY would it be possible to post a picky of same . code further to . the original lib as > the likes of square and triangle are been drawn around the centre of the start x start y . then the cords are to the left and right and top and bottom of the start x and start y BR Alex Added Looking at the original code base the perspective is correct , suppose here looking as in terms of CX & CY for the geometry functions as verses X and Y in the libs. Attachments:
|
|
|
Post by vovchik on Nov 3, 2015 15:44:11 GMT 1
Dear Alex, This is what I get with your SQUARE code (like your second pic) on Linux Mint 17. With kind regards, vovchik Attachments:
|
|
|
Post by alexfish on Nov 3, 2015 15:56:52 GMT 1
Hi Vovchik
Have updated the post above U..
have also tested the clock + nina plot . all looking good.
tested the clock for a purpose , since had what looked like a SQUARE , U used lines ?
At least can now see your square is same as the Raspy. on understanding the the geometric functions work CX & CY
will be interesting to test the rest . Size fo Size.
BR Alex
|
|