|
Post by alexfish on Nov 4, 2022 21:11:22 GMT 1
Hi all final test of Ubuntu 22.10(Wayland) Done, not going to far into that one as far as devs are concerned, possible post on another thread now aligning the lib bits as separate lib , so could be used as one wishes. as far as one test = HUG will it work, Image wise, yes and possible better than expected HUG has all the tools... so I leaving this bit of code , the bits are mixed but not the actual map, and yes it is hard coded , 'testmaps.bac
INCLUDE hug.bac HUGOPTIONS ("NOSCALING")
SUB DRAWBIT() PICTURE("/home/pi4/baconmaps/16/33551/21627.png", 0, 256,256,256) PICTURE("/home/pi4/baconmaps/16/33552/21627.png",256,256, 256,256) ' test image with alpha seamap/marks/ PICTURE("/home/pi4/baconmaps/S20690.png",80,80,256,256) CIRCLE("red", 256-8, 256-8 ,16, 16 ,TRUE) SYNC() END SUB
win = WINDOW("HugMaps",512, 560) gtk_window_set_resizable(win, TRUE) can = CANVAS(1920,512) ATTACH (win,can,1,1) but=BUTTON("draw",100,25) ATTACH (win,but,5,555-30) CALLBACK(but,DRAWBIT) PICTURE("/home/pi4/baconmaps/16/33551/21626.png",0,0, 256,256) PICTURE("/home/pi4/baconmaps/16/33552/21626.png",256,0, 256,256) DISPLAY the mixed is an alpha image + draw a circle to replicate your position Attachments:
|
|
|
Post by alexfish on Nov 6, 2022 21:36:36 GMT 1
No it does not
Oh 'Cairo'
it does now
'testmaps.bac
INCLUDE hug.bac HUGOPTIONS ("NOSCALING")
LibCairo$ = "libcairo.so.2" CONST CAIRO_FORMAT_ARGB32 = 0
IMPORT "cairo_image_surface_create(int,int,int)" FROM LibCairo$ TYPE long IMPORT "cairo_create (long) FROM LibCairo$" FROM LibCairo$ TYPE long IMPORT "cairo_set_source_rgb(long,double,double,double)" FROM LibCairo$ TYPE void IMPORT "cairo_fill(long)" FROM LibCairo$ TYPE void IMPORT "cairo_surface_flush(long)" FROM LibCairo$ TYPE void IMPORT "cairo_surface_write_to_png(long,char*" FROM LibCairo$ TYPE int IMPORT "cairo_destroy (long)" FROM LibCairo$ TYPE void IMPORT "cairo_save (long)" FROM LibCairo$ TYPE void IMPORT "cairo_paint (long)" FROM LibCairo$ TYPE void
Scr_W = SCREENSIZE(0) Scr_H = SCREENSIZE(1) Tile_W = 256 Tile_H= 256 Tiles_X = Scr_W/Tile_W+1 Tiles_Y = Scr_H/Tile_H+1
HOME$ = GETENVIRON$("HOME")
'================================================================== SUB DrawCairo cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 50, 50) c = cairo_create (cs) cairo_set_source_rgb (c, 0.1, 0.0, 0.7) cairo_paint (c) cairo_surface_flush (cs) cairo_surface_write_to_png(cs,HOME$ & "/test2.png") END SUB '==================================================================
'================================================================== SUB DRAWPAGE()
FOR tx = 0 TO Tiles_X FOR ty = 0 TO Tiles_Y PICTURE(HOME$ & "/baconmaps/16/33551/21627.png", \ tx*256, ty*256,256,256) NEXT NEXT
END SUB '==================================================================
SUB WINRESIZABLE(long hugwindow,int state) gtk_window_set_resizable(hugwindow, state)
END SUB
'================================================================== DrawCairo() win = WINDOW("HugMaps",512, 560) WINRESIZABLE(win, TRUE)
but=BUTTON("draw",100,35) ATTACH (win,but,3,3) CALLBACK(but,DRAWPAGE)
can = CANVAS(Scr_W ,Scr_H) ATTACH (win,can,0,40)
DISPLAY
BR Alex
|
|
|
Post by alexfish on Nov 7, 2022 12:54:11 GMT 1
How Do We make a geo/slippy canvas that can go n/s/e/w + add the widgets widgets need some thought. In Short lets set a stage:: BUTTONS a no go in this arena See below code kind of a goo canvas without the goo MenuList Not like a Drop Down Menu, OK OK Best I can do , but will have to click Cancel , before can Drop Down Again Updated Code INCLUDE hug.bac HUGOPTIONS ("NOSCALING")
'================================================================ LibCairo$ = "libcairo.so.2" CONST CAIRO_FORMAT_INVALID = -1 CONST CAIRO_FORMAT_ARGB32 = 0 CONST CAIRO_FORMAT_RGB24 = 1 CONST CAIRO_FORMAT_A8 = 2 CONST CAIRO_FORMAT_A1 = 3 CONST CAIRO_FORMAT_RGB16_565 = 4 CONST CAIRO_FORMAT_RGB30 = 5
IMPORT "cairo_image_surface_create(int,int,int)" FROM LibCairo$ TYPE long IMPORT "cairo_create (long) FROM LibCairo$" FROM LibCairo$ TYPE long IMPORT "cairo_set_source_rgb(long,double,double,double)" FROM LibCairo$ TYPE void IMPORT "cairo_fill(long)" FROM LibCairo$ TYPE void IMPORT "cairo_surface_flush(long)" FROM LibCairo$ TYPE void IMPORT "cairo_surface_write_to_png(long,char*" FROM LibCairo$ TYPE int IMPORT "cairo_destroy (long)" FROM LibCairo$ TYPE void IMPORT "cairo_save (long)" FROM LibCairo$ TYPE void IMPORT "cairo_paint (long)" FROM LibCairo$ TYPE void '================================================================ ' Needed For SlippyCanvas GTKLIB$ = HUGLIB$("gtk") IMPORT "gtk_fixed_move(long,long,int,int)" FROM GTKLIB$ TYPE void IMPORT "gtk_window_get_size(long,int*,int*)" FROM GTKLIB$ TYPE void '================================================================ HOME$ = GETENVIRON$("HOME") SEARCHDIR$ = HOME$ & "/baconmaps/" OSMDIR$ = SEARCHDIR$ & STR$(16) & "/" '================================================================ Scr_W = SCREENSIZE(0) Scr_H = SCREENSIZE(1) '================================================================ SUB WINRESIZABLE(long hugwindow,int state) gtk_window_set_resizable(hugwindow, state) END SUB '================================================================ SUB MoveCanvas() LOCAL new_width, new_height TYPE int LOCAL winsize$ gtk_window_get_size (win, &new_width, &new_height) winsize$=STR$(new_width) & ":" & STR$(new_height)
TEXT(ed,winsize$ & NL$) LOCAL layer1 layer1 = hug_widget_attach(STR$(win)) gtk_fixed_move(layer1,canvas,-100,0)
END SUB '============================================================== SUB DRAWPAGE()
FOR tx = 0 TO 8 FOR ty = 0 TO 8 PICTURE(HOME$ & "/baconmaps/16/33551/21627.png", \ tx*256, ty*256,256,256) NEXT NEXT
END SUB DECLARE MenuTog = 0 SUB SETSIZE(long hug_widget,hug_xsize,hug_ysize)
gtk_widget_set_size_request(hug_widget,hug_xsize,hug_ysize)
END SUB
'================================================================ SUB GetMenu()
LOCAL txt$ = GRAB$(menu_list) IF INSTR(txt$,"Menu") THEN MenuTog = NOT(MenuTog) IF MenuTog THEN SETSIZE(menu_list,120,150) END IF
END IF
IF INSTR(txt$,"Cancel") THEN SETSIZE(menu_list,120,45) END IF
IF INSTR(txt$,"ShowEdit") THEN SHOW(ed) SETSIZE(menu_list,120,45) END IF IF INSTR(txt$,"HideEdit") THEN HIDE(ed) SETSIZE(menu_list,120,45) END IF
IF INSTR(txt$,"MoveCanvas") THEN layer1 = hug_widget_attach(STR$(win)) gtk_fixed_move(layer1,canvas,0, Scr_H/4+50) SETSIZE(menu_list,120,45) END IF
END SUB
'MAIN ===========================================================
win = WINDOW("HugMaps",600, 400) WINRESIZABLE(win, TRUE) canvas = CANVAS(Scr_W*2,Scr_H*2)
ATTACH(win,canvas,0, Scr_H/4+50) CALLBACK(canvas,MoveCanvas)
menu_list = LIST(120,45) ATTACH (win,menu_list,0,0) TEXT(menu_list,"Menu_") TEXT(menu_list,"Cancel_") TEXT(menu_list,"ShowEdit_") TEXT(menu_list,"HideEdit_") TEXT(menu_list,"MoveCanvas_") CALLBACK (menu_list,GetMenu)
ed = EDIT(Scr_W/2, Scr_H/4) ATTACH(win,ed,120,0) TEXT(ed,OSMDIR$ & NL$) /* FOR tx = 0 TO 8 FOR ty = 0 TO 8 PICTURE(HOME$ & "/baconmaps/16/33551/21627.png", \ tx*256, ty*256,256,256) NEXT NEXT */ DISPLAY UPDATED to get window size/ click on the canvas Have Fun + BR Alex Attachments:
|
|
|
Post by alexfish on Nov 7, 2022 20:06:10 GMT 1
What we finally get is option to use legit osm GTK3 option to us own using own under the own = Hug Gtk2 A Geo-spacial Canvas Stand alone Can be used for games/adventure/etc: options here are as wide as it is long , can be use to display maps Add gpsd Add method to down load maps Add a bit of aptitude = a very versatile Navigation app Add seamap = a very versatile Sea-Navigation app SO: looking at the back-ends Possible looking at type of header '======== make Geocanvas + widgets INCLUDE hug.bac INCLUDE HugExtra.bac '== LibCairo.bac code taken from original navigation app X11== INCLUDE LibCairo.bac '==Geo.bac code taken from original navigation app X11 ======= INCLUDE Geo.bac '============================================================= '======== uses realime gpsd == general use = maps INCLUDE LibGps ' to get maps ' INCLUDE your httplib IE: libsoup , curl.bac , yourhttp '============================================================== HUGOPTIONS ("NOSCALING") '================================================================ HOME$ = GETENVIRON$("HOME") SEARCHDIR$ = HOME$ & "/baconmaps/" OSMDIR$ = SEARCHDIR$ & STR$(16) & "/" '================================================================ Scr_W = SCREENSIZE(0) Scr_H = SCREENSIZE(1) '================================================================
BR Alex ADDED as a side note RE Ubuntu 20.10(wayland) it used to be 10 things to do , now 100 possible things to do on the joke side of things they hijacked the beep , beep beep beep 'What beep' , agh' sudo apt install beep' beep beep beep hooray , now 101 things to do The Positive, those long standing Shaking Stevens windows are now gone , Hip Hip Hooray youtube shakey
|
|
|
Post by alexfish on Nov 13, 2022 4:45:52 GMT 1
Hi All
have had a fun day at the mill
getting the cairo surface to render in hug , one problem was getting data tyep to work the other was alpha
in short optimal and only solution at present
'testmaps.bac INCLUDE hug.bac HUGOPTIONS ("NOSCALING")
LibCairo$ = "libcairo.so.2" CONST CAIRO_FORMAT_INVALID = -1 CONST CAIRO_FORMAT_ARGB32 = 0 CONST CAIRO_FORMAT_RGB24 = 1 CONST CAIRO_FORMAT_A8 = 2 CONST CAIRO_FORMAT_A1 = 3 CONST CAIRO_FORMAT_RGB16_565 = 4 CONST CAIRO_FORMAT_RGB30 = 5
IMPORT "cairo_image_surface_get_data (long)" FROM LibCairo$ TYPE unsigned char * IMPORT "cairo_image_surface_get_format (long)" FROM LibCairo$ TYPE int IMPORT "cairo_image_surface_get_width (long)" FROM LibCairo$ TYPE int IMPORT "cairo_image_surface_get_height (long)" FROM LibCairo$ TYPE int IMPORT "cairo_image_surface_get_stride ()" FROM LibCairo$ TYPE int IMPORT "cairo_format_stride_for_width (int, int)" FROM LibCairo$ TYPE int IMPORT "cairo_image_surface_create_for_data(unsigned char*,int,int,int,int)" FROM LibCairo$ TYPE long IMPORT "cairo_image_surface_create(int,int,int)" FROM LibCairo$ TYPE long IMPORT "cairo_create (long) FROM LibCairo$" FROM LibCairo$ TYPE long IMPORT "cairo_set_source_rgb(long,double,double,double)" FROM LibCairo$ TYPE void IMPORT "cairo_set_source_rgba(long,double,double,double,double)" FROM LibCairo$ TYPE void IMPORT "cairo_fill(long)" FROM LibCairo$ TYPE void IMPORT "cairo_surface_flush(long)" FROM LibCairo$ TYPE void IMPORT "cairo_surface_write_to_png(long,char*)" FROM LibCairo$ TYPE int IMPORT "cairo_destroy (long)" FROM LibCairo$ TYPE void IMPORT "cairo_save (long)" FROM LibCairo$ TYPE void IMPORT "cairo_paint (long)" FROM LibCairo$ TYPE void IMPORT "cairo_set_line_width(long,double)" FROM LibCairo$ TYPE void IMPORT "cairo_rectangle(long,double,double,double,double)" FROM LibCairo$ TYPE void IMPORT "cairo_stroke(long)" FROM LibCairo$ TYPE void IMPORT "cairo_surface_destroy(long)" FROM LibCairo$ TYPE void IMPORT "cairo_restore(long)" FROM LibCairo$ TYPE void
IMPORT "gdk_pixbuf_get_width(int)" FROM "libgdk_pixbuf-2.0.so.0" TYPE int IMPORT "gdk_pixbuf_get_height(int)" FROM "libgdk_pixbuf-2.0.so.0" TYPE int IMPORT "gdk_pixbuf_save(long,char*,char*,void*,...)" FROM "libgdk_pixbuf-2.0.so.0" TYPE long IMPORT "gdk_pixbuf_composite(long,long,int,int,int,int,double,double,double,double, int,int)" FROM "libgdk_pixbuf-2.0.so.0" TYPE long IMPORT "gdk_pixbuf_new_from_data (const char* ,int ,int,int ,int,int ,int ,long,long)" FROM "libgdk_pixbuf-2.0.so.0" TYPE long
Scr_W = SCREENSIZE(0) Scr_H = SCREENSIZE(1) Tile_W = 256 Tile_H= 256 Tiles_X = Scr_W/Tile_W+1 Tiles_Y = Scr_H/Tile_H+1
HOME$ = GETENVIRON$("HOME") ' Not Used SUB cairo_rgba(long cr,char r,char g,char b,char a) LOCAL R,G,B,A TYPE double R = r/255.0 G = g/255.0 B = b/255.0 A = a/255.0 PRINT R , ":",G,":",B,":" ,A cairo_set_source_rgba(cr , R ,G ,B,A) END SUB
SUB cairo_rgb(long cr,char r,char g,char b) LOCAL R,G,B,A TYPE double R = r/255.0 G = g/255.0 B = b/255.0
PRINT R , ":",G,":",B cairo_set_source_rgb(cr , R ,G ,B) END SUB
SUB CAIRORENDER(long csr, int hug_xpos, int hug_ypos) cairo_surface_write_to_png(csr,HOME$ & "/hug.png") LOCAL pix, ebox, context, buf,w,h
REM Get the associated canvas pix = hug_gui_properties.canvas ebox = hug_widget_ebox(STR$(pix))
context = hug_widget_context(STR$(pix)) buf = gdk_pixbuf_new_from_file(HOME$ & "/hug.png", 0) w = gdk_pixbuf_get_width(buf) h = gdk_pixbuf_get_height(buf) gdk_draw_pixbuf(pix, context, buf, 0, 0, hug_xpos, hug_ypos, w,h, 0, 0, 0) gtk_widget_queue_draw(hug_widget_image(STR$(ebox)) ) DELETE FILE HOME$ & "/hug.png"
g_object_unref(buf)
END SUB '=================================================================== FUNCTION CAIRORECT(char rb,char gb,char bb,char r,char g, char b, \ int hug_width,int hug_height,line_width,int fill) TYPE long
LOCAL pix, ebox, context cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, hug_width, hug_height) c = cairo_create (cs) IF (fill) THEN cairo_rgb(c, rb, gb,bb) cairo_paint (c) END IF
cairo_set_line_width(c,line_width) cairo_rgb(c, r, g, b) cairo_rectangle(c,0,0,hug_width,hug_height) cairo_stroke(c) cairo_surface_flush (cs) RETURN cs END FUNCTION '================================================================== SUB DRAWPAGE()
LOCAL surf surf = CAIRORECT(255,0,0, 0,0,0,30,30,5,1) CAIRORENDER(surf,200,300) cairo_surface_destroy(surf)
END SUB '================================================================== SUB WINRESIZABLE(long hugwindow,int state) gtk_window_set_resizable(hugwindow, state) END SUB '==================================================================
win = WINDOW("HugMaps",512, 560) WINRESIZABLE(win, TRUE)
but=BUTTON("draw",100,35) ATTACH (win,but,3,3) CALLBACK(but,DRAWPAGE)
can = CANVAS(Scr_W ,Scr_H) ATTACH (win,can,0,40)
DISPLAY
can add own cairo draw function and have a bit of fun
Have Fun + BR Alex
|
|
|
Post by alexfish on Nov 13, 2022 14:30:54 GMT 1
After a fresh look at the get data
now have this + Added TEXT Note possible warning pointer cast , if someone can resolve this , I be a happy man
anyway Demo bits
'testmaps3.bac INCLUDE hug.bac HUGOPTIONS ("NOSCALING")
LibCairo$ = "libcairo.so.2" CONST CAIRO_FORMAT_INVALID = -1 CONST CAIRO_FORMAT_ARGB32 = 0 CONST CAIRO_FORMAT_RGB24 = 1 CONST CAIRO_FORMAT_A8 = 2 CONST CAIRO_FORMAT_A1 = 3 CONST CAIRO_FORMAT_RGB16_565 = 4 CONST CAIRO_FORMAT_RGB30 = 5
IMPORT "cairo_destroy (long)" FROM LibCairo$ TYPE void IMPORT "cairo_image_surface_get_data (long)" FROM LibCairo$ TYPE unsigned char * IMPORT "cairo_image_surface_get_format (long)" FROM LibCairo$ TYPE int IMPORT "cairo_image_surface_get_width (long)" FROM LibCairo$ TYPE int IMPORT "cairo_image_surface_get_height (long)" FROM LibCairo$ TYPE int IMPORT "cairo_image_surface_get_stride ()" FROM LibCairo$ TYPE int IMPORT "cairo_format_stride_for_width (int, int)" FROM LibCairo$ TYPE int IMPORT "cairo_image_surface_create_for_data(unsigned char*,int,int,int,int)" FROM LibCairo$ TYPE long IMPORT "cairo_image_surface_create(int,int,int)" FROM LibCairo$ TYPE long IMPORT "cairo_create (long) FROM LibCairo$" FROM LibCairo$ TYPE long IMPORT "cairo_set_source_rgb(long,double,double,double)" FROM LibCairo$ TYPE void IMPORT "cairo_set_source_rgba(long,double,double,double,double)" FROM LibCairo$ TYPE void IMPORT "cairo_fill(long)" FROM LibCairo$ TYPE void IMPORT "cairo_surface_flush(long)" FROM LibCairo$ TYPE void IMPORT "cairo_surface_write_to_png(long,char*)" FROM LibCairo$ TYPE int IMPORT "cairo_save (long)" FROM LibCairo$ TYPE void IMPORT "cairo_paint (long)" FROM LibCairo$ TYPE void IMPORT "cairo_set_line_width(long,double)" FROM LibCairo$ TYPE void IMPORT "cairo_rectangle(long,double,double,double,double)" FROM LibCairo$ TYPE void IMPORT "cairo_show_text(long,char*)" FROM LibCairo$ TYPE void IMPORT "cairo_set_font_size(long,double)" FROM LibCairo$ TYPE void IMPORT "cairo_stroke(long)" FROM LibCairo$ TYPE void IMPORT "cairo_surface_destroy(long)" FROM LibCairo$ TYPE void IMPORT "cairo_restore(long)" FROM LibCairo$ TYPE void IMPORT "cairo_move_to(long,double,double)" FROM LibCairo$ TYPE void IMPORT "gdk_pixbuf_get_width(int)" FROM "libgdk_pixbuf-2.0.so.0" TYPE int IMPORT "gdk_pixbuf_get_height(int)" FROM "libgdk_pixbuf-2.0.so.0" TYPE int IMPORT "gdk_pixbuf_save(long,char*,char*,void*,...)" FROM "libgdk_pixbuf-2.0.so.0" TYPE long IMPORT "gdk_pixbuf_composite(long,long,int,int,int,int,double,double,double,double, int,int)" FROM "libgdk_pixbuf-2.0.so.0" TYPE long IMPORT "gdk_pixbuf_new_from_data (const char* ,int ,int,int ,int,int ,int ,long,long)" FROM "libgdk_pixbuf-2.0.so.0" TYPE long
Scr_W = SCREENSIZE(0) Scr_H = SCREENSIZE(1) Tile_W = 256 Tile_H= 256 Tiles_X = Scr_W/Tile_W+1 Tiles_Y = Scr_H/Tile_H+1
HOME$ = GETENVIRON$("HOME") ' Not Used '======================================================================== SUB cairo_rgba(long cr,char r,char g,char b,char a) LOCAL R,G,B,A TYPE double R = r/255.0 G = g/255.0 B = b/255.0 A = a/255.0 PRINT R , ":",G,":",B,":" ,A cairo_set_source_rgba(cr , R ,G ,B,A) END SUB '======================================================================== SUB cairo_rgb(long cr,char r,char g,char b) LOCAL R,G,B,A TYPE double R = r/255.0 G = g/255.0 B = b/255.0
PRINT R , ":",G,":",B cairo_set_source_rgb(cr , R ,G ,B) END SUB '======================================================================== SUB CAIRORENDER(long csr, int hug_xpos, int hug_ypos) /* GdkPixbuf* gdk_pixbuf_new_from_data ( const guchar* data, GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height, int rowstride, GdkPixbufDestroyNotify destroy_fn, gpointer destroy_fn_data )
int cairo_format_stride_for_width () cairo_surface_t * cairo_image_surface_create () cairo_surface_t * cairo_image_surface_create_for_data () unsigned char * cairo_image_surface_get_data () cairo_format_t cairo_image_surface_get_format () int cairo_image_surface_get_width () int cairo_image_surface_get_height () int cairo_image_surface_get_stride ()
*/
LOCAL data TYPE unsigned char * data = cairo_image_surface_get_data (csr) 'cairo_surface_write_to_png(csr,HOME$ & "/hug.png") LOCAL pix, ebox, context, buf,w,h
REM Get the associated canvas pix = hug_gui_properties.canvas ebox = hug_widget_ebox(STR$(pix)) context = hug_widget_context(STR$(pix)) buf = gdk_pixbuf_new_from_data(data, 0,TRUE,8,cairo_image_surface_get_width(csr), \ cairo_image_surface_get_height(csr),cairo_image_surface_get_stride (csr),NULL,NULL) w = gdk_pixbuf_get_width(buf) h = gdk_pixbuf_get_height(buf) gdk_draw_pixbuf(pix, context, buf, 0, 0, hug_xpos, hug_ypos, w,h, 0, 0, 0) gtk_widget_queue_draw(hug_widget_image(STR$(ebox)) ) g_object_unref(buf)
END SUB '=================================================================== FUNCTION CAIRORECT(char rb,char gb,char bb,char r,char g, char b, \ int hug_width,int hug_height,line_width,int fill) TYPE long
LOCAL pix, ebox, context , cs,c cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, hug_width, hug_height) c = cairo_create (cs) IF (fill) THEN cairo_rgb(c, rb, gb,bb) cairo_paint (c) END IF
cairo_set_line_width(c,line_width) cairo_rgb(c, r, g, b) cairo_rectangle(c,0,0,hug_width,hug_height) cairo_stroke(c) cairo_surface_flush (cs) cairo_destroy(c) RETURN cs
END FUNCTION '======================================================================== FUNCTION CAIROTEXT(STRING txt$,char r,char g,char b, int hug_width, \ int hug_height,double fontsize) TYPE long /* cairo_text_extents_t te; cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); cairo_select_font_face (cr, "Georgia", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size (c, 15); cairo_text_extents (cr, "a", &te); cairo_move_to (cr, 0.5 - te.width / 2 - te.x_bearing, 0.5 - te.height / 2 - te.y_bearing); cairo_show_text (cr, "a"); */ LOCAL cs,c cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, hug_width, hug_height) c = cairo_create (cs) cairo_rgb(c, r, g, b) cairo_move_to (c,0,15) cairo_set_font_size (c, fontsize) cairo_show_text(c,txt$) cairo_stroke(c) cairo_surface_flush (cs) cairo_destroy(c)
RETURN cs
END FUNCTION '================================================================== SUB DRAWPAGE() LOCAL surf surf = CAIRORECT(255,0,0, 0,0,0,30,30,5,1) CAIRORENDER(surf,200,300) cairo_surface_destroy(surf) surf = CAIROTEXT("My Text",255,15,140,200,50,20) CAIRORENDER(surf,5,5) cairo_surface_destroy(surf) END SUB
'================================================================== SUB WINRESIZABLE(long hugwindow,int state) gtk_window_set_resizable(hugwindow, state) END SUB
'MAIN =============================================================
win = WINDOW("HugMaps",512, 560) WINRESIZABLE(win, TRUE)
but=BUTTON("draw",100,35) ATTACH (win,but,3,3) CALLBACK(but,DRAWPAGE)
can = CANVAS(Scr_W ,Scr_H) ATTACH (win,can,0,40)
DISPLAY
BR Alex
|
|