|
Post by alexfish on Aug 13, 2013 5:32:09 GMT 1
Hi @ Vovchik & All I tried the binary - great list widget - and customizable..... Can't wait to try the rest. Here is a screen shot of the starting to com together Did have some keyboard input problems RE: edit , Keycodes again , so have use Text buffer for the Edit , the list think every one should understand G-LIST , this now has load list on Boot , the G-EDIT : top bar sam as List , the edit area now has copy and paste , + Scroll , the scroll is implement by the shaded scroll area to to the right , No scoll button on this one yet , but still can scroll using the mouse scroll wheel. :: Also compatible colouring now add to the hug type widgets using same format. Screen shot below , will post a demo version soon , since have some signalling bits to sort out , BR Alex PS :: Some may recognize the Data Attachments:
|
|
|
Post by vovchik on Aug 15, 2013 16:03:23 GMT 1
Dear All, I managed to get GFX to display retro (PC-DOS-style) characters that were often used for line drawing in the days before graphics screens (yes, I remember those days well, as well as punched cards and perforated tape). This is a little maze. The archive maze_ascii_goo.tar.gz (3.46 KB)contains the sources for a terminal version as well as the much nicer GFX version. Have fun... Wth kind regards, vovchik
|
|
|
Post by Pjot on Aug 16, 2013 13:06:03 GMT 1
Hi vovchik,
It crashes with a segmentation error for me (64bit Linux). Further debugging shows that the crash happens at 695-698:
' Fill background with gradient bg = RECTANGLE(win, 1, 1, 1, 1, CLASS, ITEM_RECTANGLE, "can-focus", 1, \ "line-width", 0.0, "fill_pattern", fill_lin, "stroke-color", "none", \ "antialias", 3, 0)
This is probably a function from 'libgfx_import.bac'. Can you provide the latest version also so I can check it further?
Thx, Peter
|
|
|
Post by vovchik on Aug 16, 2013 13:44:19 GMT 1
Dear Peter, I have attached the lib and libimport sources, as well as the sources for maze and mandala, both of which work for me. I am puzzled by the segfault, too. With kind regards, vovchik Attachments:libgfx.tar.gz (16.07 KB)
|
|
|
Post by Pjot on Aug 16, 2013 15:10:41 GMT 1
Hi vovchik,
I found the error, there are a few problem lines in your code at 689-698:
' fill for text fill_text = LINEAR(0, 0, 0, canvas_h) ADD_HEX_STOP(fill_text, 0.0, "#FFA500", 0.8) ADD_HEX_STOP(fill_text, 0.2, "#FF4500", 0.8) : ' should be #FF4500 instead of '##FF4500' ADD_HEX_STOP(fill_text, 0.47, "#00FF00", 0.8) :' should be #00FF00 instead of 'OOFF00' ADD_HEX_STOP(fill_text, 0.8, "#FF4500", 0.8) : ' should be #FF4500 instead of '##FF4500' ' Fill background with gradient bg = RECTANGLE(win, 1, 1, 1, 1, CLASS, ITEM_RECTANGLE, "can-focus", 1, \ "line-width", 0.0, "fill_pattern", fill_lin, "stroke-color", "none", \ "antialias", 3, NULL) : ' Replaced last 0 for NULL
Now it works fine!
BR, Peter
|
|
|
Post by vovchik on Aug 16, 2013 15:18:10 GMT 1
Dear Peter, Sorry, and thanks. That was silly copy/paste stuff that I did not notice. With kind regards, vovchik PS. I have to watch my typing Here is a fixed version, I hope. Attachments:maze_fixed.tar.gz (3.46 KB)
|
|
|
Post by vovchik on Aug 18, 2013 11:15:35 GMT 1
Dear All, Continuing my recent obsession with "retro", here is an animated "Towers of Hanoi" demo. I think it isn't too bad. With kind regards, vovchik Attachments:hanoi2.tar.gz (2.82 KB)
|
|
|
Post by bigbass on Aug 18, 2013 15:10:34 GMT 1
Hey vovchik An excellent example of how to logically animate the movements using a known puzzle formula as a reference this helps demonstrates how to get mastery of goo and I believe paves the way for many more logical movement demos and a better understanding of whats needed for goo to become the next new wave for fresh ideas Thanks for doing this Joe
|
|
|
Post by alexfish on Aug 18, 2013 17:35:47 GMT 1
Hi Vovchik Another Nice Demo.. thought I would turn the Tower of Hanoi upside down , hoping Everything would still fall into place and defy gravity PRINT "Frame created" ' Create canvas for drawing canvas = AREA(win, 10, 10, canvas_w, canvas_h) '@ ROTATE the Tower 180 deg's ROTATE(canvas,180,canvas_w/2,canvas_h/2) PRINT "Canvas created" ' Create buttons and callbacks BR Alex
|
|
|
Post by Pjot on Aug 18, 2013 21:14:05 GMT 1
vovchik,
Very cool demo again! Compiles and runs without mods on my Linux Mint 64bit.
Thanks!! Peter
|
|
|
Post by alexfish on Aug 18, 2013 21:25:47 GMT 1
Hi @ All
This is some of the work been done in the next Beta
Here the FOCUS is on FOCUS + Grabbing the KEYBOARD Events + the CHARS
Click on the Widgets + type at key-board + use The key-board TAB key
Have Fun Alex
INCLUDE libgfx.bac Goo$=GFXLIB("goo") IMPORT "goo_canvas_item_get_canvas(long)" FROM Goo$ TYPE long
SUB on_focus_in(NUMBER item,NUMBER target,NUMBER event, NUMBER data) PRINT " ITEM FOCUS SET : ",item PRINT " ------------------------------" PRINT "" g_object_set(item,"stroke-color","red",NULL) END SUB
SUB on_focus_out(NUMBER item,NUMBER target,NUMBER event, NUMBER data) PRINT " ITEM FOCUS UN SET : " , item g_object_set(item,"stroke-color","grey",NULL) PRINT " ------------------------------" PRINT "" END SUB
FUNCTION on_button_press2 (NUMBER item,NUMBER target,NUMBER event, NUMBER data) LOCAL canvas canvas = goo_canvas_item_get_canvas (item) goo_canvas_grab_focus (canvas, item) RETURN TRUE END FUNCTION
' ---------------- FUNCTION G_STRING_UTF8(STRING myasc$) ' --------------- '@ based on PvE code 'Peter LOCAL t, b1, b2, c TYPE NUMBER LOCAL new$ TYPE STRING t = 1 WHILE t <= LEN(myasc$) DO c = ASC(MID$(myasc$, t, 1)) IF c > 127 THEN b1 = ((c & 192) >> 6) + 192 b2 = (c & 63) + 128 new$ = CONCAT$(new$, CHR$(b1)) new$ = CONCAT$(new$, CHR$(b2)) ELSE new$ = CONCAT$(new$, MID$(myasc$, t, 1)) END IF t = t + 1 WEND RETURN new$ END FUNCTION
SUB on_key_press(NUMBER item , NUMBER target , NUMBER event , NUMBER user_data) PRINT " ITEM : " , item LOCAL char$ LOCAL focus g_object_get(item,"can-focus",ADDRESS(focus),NULL) IF focus THEN a=KEY() IF (a > 0 ) & (a<225) THEN char$=G_STRING_UTF8(CHR$(a)) PRINT char$ ELSE PRINT " NULL STRING " END IF ELSE PRINT " focus : " , focus PRINT "Item Has no Focus" END IF
PRINT " ------------------------------" PRINT ""
END SUB
SUB TEST_BUT() PRINT " but tested" END SUB
' MAIN ----------------------------------------------------------------------------------------- root = WINDOW("Bacon GFX Focus & Key events", 300, 200, 1.0) win = GETROOT(root) '@ rectangle item1 item1 = goo_canvas_rect_new (win, 50, 50, 100, 50,"stroke-color", "grey", "radius-x",6.0,"radius-y",6.0 , \ "fill-color", "blue","line-width", 2.0,"can-focus", TRUE,NULL)
'@ use G_SIGNAL_CONNECT_DATA to set up this item for Focus + Key-board grab g_signal_connect_data (item1, "focus-in-event",on_focus_in, item1,0,0) g_signal_connect_data (item1, "focus_out_event",on_focus_out, item1,0,0) g_signal_connect_data (item1, "button-press-event",on_button_press2, 0,0,0) g_signal_connect_data (item1, "key-press-event",on_key_press, 0,0,0)
'@ rectangle item2 item2 = goo_canvas_rect_new (win, 160, 50, 100, 50,"stroke-color", "grey" , "radius-x",6.0,"radius-y",6.0 , \ "fill-color", "yellow","line-width", 2.0,"can-focus", TRUE,NULL)
'@ ADD CALLBACK + use G_SIGNAL_CONNECT_DATA to set up this item for Focus CALLBACK(item2,TEST_BUT) g_signal_connect_data (item2, "focus-in-event",on_focus_in, item2,0,0) g_signal_connect_data (item2, "focus_out_event",on_focus_out, item2,0,0)
but = BUTTON("test") ATTACH(win,but,50,120,100,50)
CALLBACK(but,TEST_BUT) DISPLAY ' END ALL THAT -----------------------------------------------------------------------------------
|
|
|
Post by vovchik on Aug 18, 2013 21:50:48 GMT 1
@ Peter, Joe = Thanks... @ Alex - Works great....!!! And also thanks. Onlz thing is that I am not getting Cyrillic chars or German umlauts (yet). With kind regards, vovchik
|
|
|
Post by alexfish on Aug 18, 2013 22:36:14 GMT 1
@ Peter, Joe = Thanks... @ Alex - Works great....!!! And also thanks. Onlz thing is that I am not getting Cyrillic chars or German umlauts (yet). With kind regards, vovchik What I only had a BASIC Education , Here be some food for Thought taut , If can do (PC-DOS-style) characters using those chars , then Nothing stopping same for Them Cyrillicy thingy ma jigs or what ever them Umlauts are meant to be BR Alex
|
|
|
Post by vovchik on Aug 19, 2013 19:43:18 GMT 1
Dear all, This is a little swinging-pendulums demo - more to come in terms of these things, I think, since gravity is fun to play with... (just ask Einstein). With kind regards, vovchik Attachments:
three_pendulums.tar.gz (2.04 KB)
|
|
|
Post by alexfish on Aug 20, 2013 22:30:46 GMT 1
Hi Vovckik
Another piece of Stunning Animation , Though post a one From Australia .
Nice to See most of this has bee Achieved with Bacon+ Hug commands + and great use of Property settings.
Hence posting This Code By Vovchik for Viewing.
BR Alex
' ***************************************************** ' PROGRAM: pendulums_3.bac ' PURPOSE: three swinging pendulums using goo gfx ' AUTHOR: vovchik (Puppy Linux forum) ' NOTES: ' DEPENDS: gcc, bacon, Alex's libgfx ' PLATFORM: Puppy Linux (actually, any *nix) ' DATE: 19-08-2013 ' *****************************************************
' *********************** ' INCLUDES ' ***********************
INCLUDE "libgfx_import.bac" INIT
' *********************** ' END INCLUDES ' ***********************
' *********************** ' INITIALIZATION ' ***********************
DECLARE canvas_w, canvas_h TYPE double canvas_w = 400 canvas_h = 340
' *********************** ' END INITIALIZATION ' ***********************
' *********************** ' SUBS & FUNCTIONS ' ***********************
' ------------------ SUB QUIT_PROG() ' ------------------ QUIT END SUB
' ------------------ SUB ADD_HEX_STOP(long item, double offset, STRING colour$, double alpha ) ' ------------------ LOCAL r, g, b TYPE double colour$ = UCASE$(colour$) r = (double)(DEC(MID$(colour$, 2, 2)) / 255.0) g = (double)(DEC(MID$(colour$, 4, 2)) / 255.0) b = (double)(DEC(MID$(colour$, 6, 2)) / 255.0) PRINT "rgb: ", (double)r, " ", (double)g, " ", (double)b ADD_COLOR_STOP(item, offset, r, g, b, alpha) END SUB
' ------------------ SUB PENDULUM() ' ------------------ LOCAL x, y, xw, yw, radii, psx, posy, posx2, posx3 TYPE double LOCAL cnt, cnt2 TYPE NUMBER LOCAL col1$, col2$ TYPE STRING x = 100 y = 0 radii = 10 cnt = 1 cnt2 = 0 WHILE cnt > 0 cnt2 = 0 x = 0 cnt = 0 WHILE cnt2 < 5010 INCR cnt2 xw = 200 * SIN(2 * PI + cnt2 / 50.0) yw = 200 * SIN(2 * PI + cnt2 / 50.0) col1$ = "#4A4A4A" HIDE(l1) HIDE(l2) HIDE(l3) HIDE(c1) HIDE(c2) HIDE(c3) l1 = LINE(canvas, col1$, 200, 100, posx, posy) col2$ = "#F0F000" c1 = CIRCLE (canvas, col2$, posx, posy, 20, 20, 1) SETPROPERTY(c1, "antialias", 3, "line-width", 2.0, "stroke-color-rgba", \ DEC(MID$(col2$, 2) & "FD"), "fill-color-rgba", DEC(MID$(col2$, 2) & "3D")) l2 = LINE(canvas, col1$, 200, 100, posx2, posy) col2$ = "#F00000" c2 = CIRCLE(canvas, col2$, posx2, posy, 20, 20, 1) SETPROPERTY(c2, "antialias", 3, "line-width", 2.0, "stroke-color-rgba", \ DEC(MID$(col2$, 2) & "FD"), "fill-color-rgba", DEC(MID$(col2$, 2) & "3D")) l3 = LINE(canvas, col1$, 200, 100, posx3, posy) col2$ = "#00F000" c3 = CIRCLE(canvas, col2$, posx3, posy, 20, 20, 1) SETPROPERTY(c3, "antialias", 3, "line-width", 2.0, "stroke-color-rgba", \ DEC(MID$(col2$, 2) & "FD"), "fill-color-rgba", DEC(MID$(col2$, 2) & "3D")) posx = 200 + (50 - x / 100.0) * SIN(2 * PI + x / 50.0) posx2 = 200 + (100 - x / 100.0) * SIN(2 * PI + x / 60.0) posx3 = 200 + (50 - x / 100.0) * SIN(2 * PI + x / 70.0) posy = 300 + 10 * SIN(2 * PI + x / 100.0) radii = 10 + 10 * SIN(2 * PI + x / 100.0) INCR x INCR cnt SHOW(l1) SHOW(l2) SHOW(l3) SHOW(c1) SHOW(c2) SHOW(c3) SLEEP 5 IF MOD(cnt, 10) = 9 THEN SYNC WEND WEND END SUB
' ------------------ SUB DRAW_OBJECT() ' ------------------ DISABLE(start_but) ' Information for user PRINT "Drawing..." TEXT(labl, "<span color='firebrick'><b>Drawing...</b></span>") SYNC ' Invoke draw routine PENDULUM() ' Information for user PRINT NL$, "Drawing done." TEXT(labl, "<span color='firebrick'><b>Drawing done.</b></span>") SYNC END SUB
' ------------------ SUB MK_GUI() ' ------------------ LOCAL col$ TYPE STRING ' Create GUI root = WINDOW("Three Pendulums - Bacon GFX", canvas_w + 20, canvas_h + 55, 1.0) ' Get root of window win = GETROOT(root) fill_lin = LINEAR(0, 0, 0, canvas_h + 50) ' light gray at top ADD_HEX_STOP(fill_lin, 0.0, "#000000", 0.8) ADD_HEX_STOP(fill_lin, 0.2, "#1E1A16", 0.8) ' change colour of next one for tint: ADD_HEX_STOP(fill_lin, 0.47, "#D0D0D0", 0.8) ' black at bottom ADD_HEX_STOP(fill_lin, 0.9, "#1E1A16", 0.8) ADD_HEX_STOP(fill_lin, 0.95, "#000000", 0.8) ' Fill background with gradient bg = RECTANGLE(win, 1, 1, 1, 1, CLASS, ITEM_RECTANGLE, "can-focus", 1, \ "line-width", 0.0, "fill_pattern", fill_lin, "stroke-color", "none", \ "antialias", 3, 0) DRAW(win, bg, 0, 0, canvas_w + 20, canvas_h + 55) ' Make frame frame = FRAME(NULL) ATTACH (win, frame, 5, 5, canvas_w + 10, canvas_h + 10) PRINT "Frame created" ' Create canvas for drawing canvas = AREA(win, 10, 10, canvas_w, canvas_h) ROTATE(canvas,180,canvas_w/2, canvas_h/2) PRINT "Canvas created" ' Create buttons and callbacks start_but = BUTTON("Go") SETPROPERTY(start_but, "tooltip-text", " Start drawing. ") ATTACH(win, start_but, 5, canvas_h + 20, 80, 30) CALLBACK (start_but, DRAW_OBJECT) labl = MARK("") SETPROPERTY(labl, "use-markup", TRUE) TEXT(labl, "<span color='firebrick'><b>GFX</b></span>") ATTACH(win, labl, ((canvas_w + 20)/2) - 75, canvas_h + 20, 150, 30) PRINT "Label created" quit_but = BUTTON("Quit") SETPROPERTY(quit_but, "tooltip-text", " Quit this program. ") ATTACH(win, quit_but, canvas_w - 65, canvas_h + 20, 80, 30) CALLBACK (quit_but, QUIT_PROG) PRINT "Buttons created" goo_label1 = PANGO_LABEL(canvas, "THREE PENDULUMS", 0, 25, canvas_w, 80, \ "font", "Sans Bold 25", "use-markup", TRUE, "fill_pattern", fill_lin, "alignment", 1) PRINT "Logo created" col$ = "#6A6A6A" ' create bar and pivot b = SQUARE(canvas, col$, 20, 95, 360, 10, 1) SETPROPERTY(b, "antialias", 3, "line-width", 2.0, "stroke-color-rgba", \ DEC(MID$(col$, 2) & "FD"), "fill-color-rgba", DEC(MID$(col$, 2) & "AD"), \ "radius-x", 10.0, "radius-y", 10.0) col$ = "#FAFAFA" c = CIRCLE(canvas, col$, 200, 100, 12, 12, 1) SETPROPERTY(c, "antialias", 3, "line-width", 2.0, "stroke-color-rgba", \ DEC(MID$(col$, 2) & "FD"), "fill-color-rgba", DEC(MID$(col$, 2) & "3D")) PRINT "Bar and pivot created." END SUB
' *********************** ' END SUBS & FUNCTIONS ' ***********************
' *********************** ' MAIN ' ***********************
MK_GUI DISPLAY
' *********************** ' END MAIN ' ***********************
|
|