|
Post by vovchik on May 19, 2013 18:06:12 GMT 1
Dear Alex et al., Now with skeleton legs With kind regards, vovchik
|
|
|
Post by bigbass on May 19, 2013 19:41:28 GMT 1
Hey alex and vovchik
great stuff! I had a laugh seeing the bones I thought about Micheal Jacksons' thiller theme song
EDITED to remove a failed example code
|
|
|
Post by vovchik on May 19, 2013 22:18:40 GMT 1
Dear guys, All very useful. We are getting closer to having a nice canvas framework that will make certain types of programming much easier. I like it that all of us are doing little bits here and there with one aim in mind ... making it easy later on. With kind regards, vovchik
|
|
|
Post by vovchik on May 20, 2013 10:35:30 GMT 1
Dear guys, More "skeletons in the closet" and real atmosphere, if you can call it that. I am waiting for Alex to work his "arm movement" magic and for Joe to figure out how we grab keystrokes. I'll also be looking at this. If you have any insights, please post them. With kind regards, vovchik Attachments:
|
|
|
Post by vovchik on May 20, 2013 13:43:07 GMT 1
Dear all (and especially Joe), I couldn't help myself. This is a thriller like version with hat - thanks to Joe . And to Alex for the infrastructure. With kind regards, vovchik PS. And the waveform is me clearing my throat Attachments:
|
|
|
Post by bigbass on May 20, 2013 14:47:09 GMT 1
Well Guys we have a way to read any keypress for goo canvas!we will be able to do many things with goo canvas and GTK notes just keep the focus on the window and you will see the title bar change reflecting the key press and the output goes to the terminal too vovchik the animation is looking great @alex suggested this fine conversion from C to bacon code 2lss I used your first proto example for goo canvas and added '---ADDED the needed code to get the keypress
PRAGMA INCLUDE goocanvas-1.0/goocanvas.h PRAGMA LDFLAGS `pkg-config --libs --cflags gtk+-2.0 goocanvas`
'---ADDED PROTO gtk_widget_show PROTO gtk_widget_show_all PROTO gtk_widget_hide PROTO gtk_window_new PROTO gtk_exit PROTO gtk_window_set_title
'---extras PROTO g_signal_connect_data PROTO g_printerr
'--- GDK PROTO gdk_keyval_name
'--- Declare variables DECLARE *window TYPE GtkWidget DECLARE *event TYPE GdkEventKey
'----------------------------------------------------------------
' goocanvas PROTO goo_canvas_get_root_item, goo_canvas_item_rotate, goo_canvas_item_request_update, goo_canvas_new PROTO goo_canvas_rect_new, goo_canvas_set_bounds, goo_canvas_text_new
' gtk PROTO gtk_container_add, gtk_init, gtk_main, gtk_scrolled_window_new, gtk_scrolled_window_set_shadow_type, gtk_set_locale PROTO gtk_widget_set_size_request, gtk_widget_show, gtk_window_new, gtk_window_set_default_size
' gobject PROTO g_signal_connect_data
'---ADDED FUNCTION key_event(GtkWidget *widget, GdkEventKey *event)
g_printerr("%s\n", gdk_keyval_name (event->keyval)) keypressed$ = gdk_keyval_name (event->keyval) gtk_window_set_title(GTK_WINDOW(window), keypressed$ ) RETURN FALSE END FUNCTION '----------------------------------------------------------------
'---ADDED '--- Callback for closing window SUB exit_prog PRINT "QUIT" gtk_exit(0) END SUB '----------------------------------------------------------------
SUB on_rect_button_press () PRINT "rect item received button press event" END SUB
SUB on_delete_event () END END SUB
GLOBAL *window, *scrolled_win, *canvas TYPE GtkWidget GLOBAL *root, *rect_item, *text_item TYPE GooCanvasItem
gtk_init(0, 0)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL) gtk_window_set_default_size (GTK_WINDOW(window), 640, 600) gtk_widget_show (window)
scrolled_win = gtk_scrolled_window_new (0, 0) gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(scrolled_win), GTK_SHADOW_IN) gtk_widget_show (scrolled_win)
gtk_container_add (GTK_CONTAINER(window), scrolled_win)
canvas = goo_canvas_new () gtk_widget_set_size_request (canvas, 600, 450) goo_canvas_set_bounds (GOO_CANVAS(canvas), 0, 0, 1000, 1000) gtk_widget_show (canvas) gtk_container_add (GTK_CONTAINER(scrolled_win), canvas)
root = goo_canvas_get_root_item (GOO_CANVAS(canvas))
rect_item = goo_canvas_rect_new (root, 100, 100, 400, 400, "line-width", 10.0, "radius-x", 20.0, "radius-y", 10.0, "stroke-color", "yellow", "fill-color", "red", 0)
text_item = goo_canvas_text_new (root, "Goo Canvas get key", 300, 300, -1, GTK_ANCHOR_CENTER, "font", "Sans 24", 0) goo_canvas_item_rotate (text_item, 45, 300, 300)
g_signal_connect_data (rect_item, "button_press_event", (GtkSignalFunc) on_rect_button_press, 0, 0, 0) g_signal_connect_data (window, "delete_event", (GtkSignalFunc) on_delete_event, 0, 0, 0)
'---ADDED
gtk_window_set_title(GTK_WINDOW(window), "get key press")
'--- Use as callback the defined SUB/FUNCTIONS g_signal_connect_data(window, "delete-event", exit_prog, 0, 0, 0) g_signal_connect_data(window, "key-release-event", G_CALLBACK(key_event) ,0, 0, 0) gtk_widget_show_all (window)
'----------------------------------------------------------------
gtk_main()
|
|
|
Post by alexfish on May 20, 2013 19:22:59 GMT 1
Hi all
Same theme of walking
Here the rectangle bits are put into a group , but can change code to fill-pixbuf , as demo'd by Vovchik Possibly add some sound to.
for the Demo the leg and arm movement is done static as regards the SPEED this is set to 0 . Super MJ style , as some would put it
the forward and back ward is implimented using bounce
Have Fun
Alex
By the Left Quick March :: The Code
'*******************************************' Program Purpose / goo animation tests ' Animate Walk / framework for animation ' .org Alexfish (Bacon Converter Forum) ' Walking / + arm movement '*******************************************
INCLUDE "hug.bac" HUGOPTIONS("NOSCALING") '@ use Goo Canvas HUGOPTIONS("CANVAS GOO")
IMPORT "goo_canvas_widget_new(long,long,double,double,double,double,...)" FROM HUGLIB$("goo") TYPE long IMPORT "goo_canvas_item_set_child_properties(long,long,...)" FROM HUGLIB$("goo") TYPE void IMPORT "goo_canvas_group_new(long,...)" FROM HUGLIB$("goo") TYPE long IMPORT "goo_canvas_item_remove_child(long,int)" FROM HUGLIB$("goo") TYPE void IMPORT "goo_canvas_item_add_child(long,long,int)" FROM HUGLIB$("goo") TYPE void IMPORT "goo_canvas_item_find_child(long,long)" FROM HUGLIB$("goo") TYPE int IMPORT "goo_canvas_item_get_parent(long)" FROM HUGLIB$("goo") TYPE long IMPORT "goo_canvas_table_new(long,...)" FROM HUGLIB$("goo") TYPE long IMPORT "goo_canvas_item_rotate(long,double,double,double)" FROM HUGLIB$("goo") TYPE void '@ Skew def IMPORT "goo_canvas_item_skew_x(long,double,double,double)" FROM HUGLIB$("goo") TYPE void IMPORT "goo_canvas_item_skew_y(long,double,double,double)" FROM HUGLIB$("goo") TYPE void
IMPORT "goo_canvas_image_new(long,long,double,double,...)" FROM HUGLIB$("goo") TYPE long '@ Animate IMPORT "goo_canvas_item_animate(long,double,double,double,double,int,int,int,int)" FROM HUGLIB$("goo") TYPE long
CONST GOO_CANVAS_ANIMATE_FREEZE = 0 CONST GOO_CANVAS_ANIMATE_RESET = 1 CONST GOO_CANVAS_ANIMATE_RESTART = 2 CONST GOO_CANVAS_ANIMATE_BOUNCE = 3 X1 = 0 X2 = 0 YY1 = -1 YY2 = 1
ANIMATE = 0
SUB START_CLICKED ANIMATE=NOT(ANIMATE) END SUB
SUB ANIMATE_BOUNCE 'GOO_CANVAS_ANIMATE_BOUNCE 'body x,y,scale,degrees ,true/false,duration,time-step,type of animation goo_canvas_item_animate(body,550,0,1,0,TRUE,14500,5,GOO_CANVAS_ANIMATE_BOUNCE) END SUB
FUNCTION MAKE_GUI()
win = WINDOW("Goo Canvas - Skew Walk", 600, 400) canvas1 = CANVAS(600, 400) ATTACH(win, canvas1,0,0)
'@ get the root of the CANVAS root_canvas1 = goo_canvas_get_root_item(hug_widget_image(STR$(canvas1))) body = goo_canvas_group_new(root_canvas1,NULL) road = goo_canvas_group_new(root_canvas1,NULL) rectangle3_5 = goo_canvas_rect_new(body, 0,0,10,100,"fill-color","blue", "radius-x", 6.0, "radius-y" ,6.0 ,NULL) goo_canvas_item_translate(rectangle3_5, 50,50) goo_canvas_item_skew_x(rectangle3_5,10,0,0) rectangle2 = goo_canvas_rect_new(body, 0,0,10,100,"fill-color","blue", "radius-x", 6.0, "radius-y" ,6.0 ,NULL) goo_canvas_item_translate(rectangle2, 50,100) goo_canvas_item_skew_x(rectangle2,-10,0,0) rectangle3 = goo_canvas_rect_new(body, 0,0,10,100,"fill-color","red","radius-x", 6.0, "radius-y" ,6.0 ,NULL) goo_canvas_item_translate(rectangle3, 50, 100) goo_canvas_item_skew_x(rectangle3,10,0,0) rect1=goo_canvas_rect_new(road, 0,200,600,40 ,"fill-color", "yellow",NULL) g_signal_connect_data(rect1, "button-press-event", START_CLICKED, 0, 0, 0) 'ANIMATE_BOUNCE g_signal_connect_data(rect1, "button-press-event", ANIMATE_BOUNCE, 0, 0, 0) rectangle2_5 = goo_canvas_rect_new(body, 0,0,10,100,"fill-color","red", "radius-x", 6.0, "radius-y" ,6.0 ,NULL) goo_canvas_item_translate(rectangle2_5, 50,50) goo_canvas_item_skew_x(rectangle2_5,-10,0,0)
RETURN FALSE END FUNCTION
FUNCTION walk
IF ANIMATE = 1 THEN
INCR X1 INCR X2 ' SET SPEED << NOTE HERE THE SPEED IS 0 Since going to animate the Whole body group SPEED1 = 0 SPEED2= 0 '@ Walk Right IF X2 < 321 THEN goo_canvas_item_skew_x(rectangle2,(double)YY1,(double)YY2*SPEED1,(double)YY2*SPEED1) goo_canvas_item_skew_x(rectangle3,(double)YY2,(double)YY1*SPEED2,(double)YY1*SPEED2) '@ arms goo_canvas_item_skew_x(rectangle2_5,(double)YY1,(double)YY2*SPEED1,(double)YY2*SPEED1) goo_canvas_item_skew_x(rectangle3_5,(double)YY2,(double)YY1*SPEED1,(double)YY1*SPEED1)
ELSE '@ Walk Left goo_canvas_item_skew_x(rectangle2,(double)YY1,(double)YY1*SPEED1,(double)YY1*SPEED1) goo_canvas_item_skew_x(rectangle3,(double)YY2,(double)YY2*SPEED2,(double)YY2*SPEED2) '@ arms goo_canvas_item_skew_x(rectangle2_5,(double)YY1,(double)YY1*SPEED1,(double)YY1*SPEED1) goo_canvas_item_skew_x(rectangle3_5,(double)YY2,(double)YY2*SPEED1,(double)YY2*SPEED1)
END IF IF X1 <21 THEN YY1= 1 YY2=-1 ELSE YY1= -1 YY2=1 END IF IF X1 = 40 THEN X1 = 0 IF X2 = 640 THEN X2 = 0 END IF
RETURN TRUE END FUNCTION
mk_gui = MAKE_GUI() TIMEOUT (50 , walk) DISPLAY
|
|
|
Post by vovchik on May 20, 2013 21:20:03 GMT 1
Dear guys, I have embellished a bit and introduced HIDE and SHOW for GOOITEMS. This allows me to control a streetlamp as if by motion sensor. And allows for a "hats off" With kind regards, vovchik PS. @ Alex: That last animate walk is very smooth and realistic. Great work. Attachments:
|
|
|
Post by alexfish on May 21, 2013 22:06:24 GMT 1
The V o g o n s are Comming
|
|
|
Post by alexfish on May 22, 2013 0:31:41 GMT 1
Hey Vovchik I think there in the Attachments BR Alex Attachments:
|
|
|
Post by vovchik on May 22, 2013 9:41:10 GMT 1
Dear Alex, Great stuff again - and the floating rotation looks very realistic. With kind regards, vovchik
|
|
|
Post by bigbass on May 22, 2013 15:49:01 GMT 1
vovchik talked to me about this before he was thinking about doing this (and would do a nice job at it ) and I just wanted to get in on the game with goo canvas with something as a demo Here is the raw idea it is quite tedious coding and making all the buttons with gimp one at a time but it would be nice to have some simple virtual keyboard in BaCon *there is a error warning in the terminal about the image I still havent figured out not the proper syntax but it does work ... being new to goo canvas pressing the images of the keys are hooked up to the callbacks and the key press is shown in the terminal the difficult keys could use the getkey function since all are detected Attachments:
|
|
|
Post by alexfish on May 22, 2013 17:44:40 GMT 1
Hi Joe
Normaly the .h files have the enumerations set
IMPORT is different
Hence can comment out the enumeration's but handy to see what they mean
'DECLARE GOO_CANVAS_ITEM_HIDDEN = 0 TYPE int 'DECLARE GOO_CANVAS_ITEM_INVISIBLE = 1 TYPE int 'DECLARE GOO_CANVAS_ITEM_VISIBLE = 2 TYPE int 'DECLARE GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD = 3 TYPE int
then in the "g_object_set" can try
EG:
g_object_set(ONE_KEY,"visibility", GOO_CANVAS_ITEM_VISIBLE, NULL)
PS: Nice key's
BR
Alex
|
|
|
Post by bigbass on May 22, 2013 18:46:18 GMT 1
Hey alex
Thank you ! That worked a clean compile and run
*This time I guessed at using a 0 ,1 -1 but it was a 2 as int
thanks for posting the declare values and the fix saves me from digging around in the headers
when I do the PROTO with no pointers I have to hunt down all the DECLARES can be a pain though
Joe
|
|
|
Post by bigbass on May 22, 2013 19:18:22 GMT 1
UPDATED with alex's fix added a white blank key Hey vovchik I miss your cat in the circle avatar how about using it here too Attachments:
|
|