|
Post by alexfish on Nov 19, 2022 0:30:35 GMT 1
Hi Peter Well , not sure if there are any posts or threads with direct render using pixbuf although elementary,elementary my dear Watson if you know the answers yes can draw a pixel , a square , a circle outline what about a filled circle rgb that is easy , a one with alpha , anyone tried Anyway this is my first attempt , but if some one can improve on it I have no objections since my algo is not a 'Vovchik' 100 percent correct My First attempt CONST GDK_INTERP_HYPER = 3 GDK$ = "libgdk_pixbuf-2.0.so.0" IMPORT "gdk_pixbuf_new (int,int,int ,int ,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_get_width(int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_get_height(int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_save(long,char*,char*,void*,...)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_composite(long,long,int,int,int,int,double,double,double,double, int,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_data (unsigned char * ,int ,int,int ,int,int ,int ,long,long)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_scale_simple(long,int,int,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_loader_new()" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_loader_write(long,unsigned char*, long int, int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_loader_close(long,int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_loader_get_pixbuf(long)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_get_byte_length(long)" FROM GDK$ TYPE unsigned long IMPORT "gdk_pixbuf_fill(long,unsigned int32)" FROM GDK$ TYPE void IMPORT "g_object_unref(long)" FROM "libgobject-2.0.so.0" TYPE void
DECLARE dest,scr,scr2 LOCAL a,x=320,y=240,r=100,c,lx,ly TYPE float LOCAL dest = gdk_pixbuf_new (0,TRUE,8,850,850) gdk_pixbuf_fill(dest,0x000000ff) scr = gdk_pixbuf_new (0,TRUE,8,2,2) gdk_pixbuf_fill(scr,0xff000006) scr2= gdk_pixbuf_new (0,TRUE,8,1,1) gdk_pixbuf_fill(scr2,0xff0000ff)
FOR t = 1 TO r FOR a=0 TO 360 STEP 1/r lx = SIN(RAD(a+c))*t ly = COS(RAD(a+c))*t gdk_pixbuf_composite(scr,dest, 400 + lx, 400 + ly, 2, 2, 0,0, 1,1, 0,100) NEXT NEXT
FOR a=0 TO 360 STEP 1/r lx = SIN(RAD(a+c))*t ly = COS(RAD(a+c))*t gdk_pixbuf_composite(scr2,dest, 400 + lx, 400 + ly, 1, 1, 0,0, 1,1, 0,100) NEXT gdk_pixbuf_save(dest,"circle.png","png",0,NULL)
g_object_unref(dest) g_object_unref(scr) g_object_unref(scr2) PRINT "Done"
Have Fun + BR Alex how smooth is the alpha , See picky Attachments:
|
|
|
Post by alexfish on Nov 19, 2022 4:33:10 GMT 1
And Then
this got addictive and staggered at the results
thought smaller the width , height & less steps = refined , not here and do not know why
yet there are some limits to this R wise , yet here 400 diameter alpha circle
5x5 draw , strange stuff this pixbuf composit
CONST GDK_INTERP_HYPER = 3 GDK$ = "libgdk_pixbuf-2.0.so.0" IMPORT "gdk_pixbuf_new (int,int,int ,int ,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_get_width(int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_get_height(int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_save(long,char*,char*,void*,...)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_composite(long,long,int,int,int,int,double,double,double,double, int,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_data (unsigned char * ,int ,int,int ,int,int ,int ,long,long)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_scale_simple(long,int,int,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_loader_new()" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_loader_write(long,unsigned char*, long int, int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_loader_close(long,int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_loader_get_pixbuf(long)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_get_byte_length(long)" FROM GDK$ TYPE unsigned long IMPORT "gdk_pixbuf_fill(long,unsigned int32)" FROM GDK$ TYPE void IMPORT "g_object_unref(long)" FROM "libgobject-2.0.so.0" TYPE void
LOCAL a,x=320,y=240,r=200,c,lx,ly TYPE float LOCAL dest1,scr,scr2
dest1 = gdk_pixbuf_new (0,TRUE,8,850,850) gdk_pixbuf_fill(dest1,0x00000000) scr3 = gdk_pixbuf_new (0,TRUE,8,1,1) gdk_pixbuf_fill(scr3,0xff000006) scr4= gdk_pixbuf_new (0,TRUE,8,1,1) gdk_pixbuf_fill(scr4,0xffff00ff)
FOR t = 1 TO r FOR a=0 TO 360 STEP 10/r lx = SIN(RAD(a+c))*t ly = COS(RAD(a+c))*t gdk_pixbuf_composite(scr3,dest1, 400 + lx, 400 + ly, 5, 5, 0,0, 1,1, 0,256/2) NEXT NEXT
FOR a=0 TO 360 STEP 1/r lx = SIN(RAD(a+c))*t ly = COS(RAD(a+c))*t
'gdk_pixbuf_composite(scr4,dest1, 400 + lx, 400 + ly, 10, 10, 0,0, 1,1, 0,100) NEXT gdk_pixbuf_save(dest1,"circle.png","png",0,NULL)
g_object_unref(dest1) g_object_unref(scr3) g_object_unref(scr4) PRINT "DONE"
BR Alex
Time for zzzzzzzzzzzzzzzz
|
|
|
Post by alexfish on Nov 20, 2022 0:11:47 GMT 1
Hi All And to some pixbuf rendering the bit = gobject :: bits are reusable Can have some fun with basic constructs line , circle Have Fun INCLUDE hug.bac
CONST GDK_INTERP_HYPER = 3 GDK$ = "libgdk_pixbuf-2.0.so.0" IMPORT "gdk_pixbuf_new (int,int,int ,int ,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_get_width(int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_get_height(int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_save(long,char*,char*,void*,...)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_composite(long,long,int,int,int,int,double,double,double,double, int,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_data (unsigned char * ,int ,int,int ,int,int ,int ,long,long)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_scale_simple(long,int,int,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_loader_new()" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_loader_write(long,unsigned char*, long int, int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_loader_close(long,int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_loader_get_pixbuf(long)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_get_byte_length(long)" FROM GDK$ TYPE unsigned long IMPORT "gdk_pixbuf_fill(long,unsigned int32)" FROM GDK$ TYPE void IMPORT "gdk_pixbuf_rotate_simple(long,int)" FROM GDK$ TYPE long 'IMPORT "g_object_unref(long)" FROM "libgobject-2.0.so.0" TYPE void 'Rotate by none =copy CONST GDK_PIXBUF_ROTATE_NONE = 0 'Rotate by 90 degrees. CONST GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE = 90 'Rotate by 180 degrees. CONST GDK_PIXBUF_ROTATE_UPSIDEDOWN = 180 'Rotate by 270 degrees CONST GDK_PIXBUF_ROTATE_CLOCKWISE =270
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 SCROLL_X = 0 SCROLL_Y = 0
FUNCTION PIXBUF_NEW(int hug_xsize,hug_ysize) LOCAL pixy pixy = gdk_pixbuf_new (0,TRUE,8,hug_xsize,hug_ysize) RETURN pixy END FUNCTION
SUB PIXBUF_PAINT_BG(long pixbuf,unsigned int col)
gdk_pixbuf_fill(pixbuf,col)
END SUB
SUB PIXBUF_PAINT_PIXBUF(long pixbuf,unsigned int col)
gdk_pixbuf_fill(pixbuf,col)
END SUB
SUB PIXBUF_PAINT(long pixbuf,int hug_xpos,int hug_ypos)
LOCAL pix, ebox, context LOCAL w,h pix = hug_gui_properties.canvas ebox = hug_widget_ebox(STR$(pix)) context = hug_widget_context(STR$(pix))
w = gdk_pixbuf_get_width(pixbuf) h = gdk_pixbuf_get_height(pixbuf) gdk_draw_pixbuf(pix, context, pixbuf, 0, 0, hug_xpos, hug_ypos, w,h, 0, 0, 0) gtk_widget_queue_draw(hug_widget_image(STR$(ebox)) )
END SUB
FUNCTION PIXBUF_LINE_RGBA(unsigned int col ,int xx1,int yy1,int xx2,int yy2,int px_size,int alpha) LOCAL dx,dy,yy TYPE double LOCAL wd,hd LOCAL pixy , scr IF xx1 >= xx2 THEN wd = xx1 + px_size ELSE wd= xx2 + px_size END IF
IF yy1 >= yy2 THEN hd = yy1 + px_size ELSE hd= yy2 + px_size END IF
pixy = PIXBUF_NEW (wd ,hd ) PIXBUF_PAINT_BG(pixy,0x00000000) scr = PIXBUF_NEW (2 ,2) PIXBUF_PAINT_BG(scr,col)
dx = xx2 - xx1 dy = yy2 - yy1
FOR xt = xx1 TO xx2 yy = yy1+ dy * (xt-xx1) / dx gdk_pixbuf_composite(scr,pixy, xt,yy, px_size,px_size, 0,0, 1,1, 0,alpha) NEXT g_object_unref(scr) RETURN pixy END FUNCTION
FUNCTION PIXBUF_CIRCLE_RGBA (unsigned int col, int radius, int px_size,int alpha,int FILL) LOCAL pixy ,scr LOCAL t,a ,c TYPE float LOCAL lx,ly TYPE float 'dest = PIXBUF_NEW ((radius*2)+px_size +1 ,(radius*2)+px_size +1 ) pixy = PIXBUF_NEW ((radius*2)+px_size +1 ,(radius*2)+px_size +1 ) PIXBUF_PAINT_BG(pixy,0x00000000)
scr = PIXBUF_NEW (2,2) PIXBUF_PAINT_BG(scr,col) IF FILL THEN radius = radius - (px_size/2) FOR t = 1 TO radius FOR a=0 TO 360 STEP radius/(t*10)
lx = SIN(RAD(a+c))*t ly = COS(RAD(a+c))*t gdk_pixbuf_composite(scr,pixy, radius+1+lx,radius+1+ly, px_size,px_size, 0,0, 1,1, 0,alpha)
NEXT NEXT ELSE FOR a=0 TO 360 STEP 0.5
lx = SIN(RAD(a+c))*radius ly = COS(RAD(a+c))*radius gdk_pixbuf_composite(scr,pixy, radius+1+lx,radius+1+ly, px_size,px_size, 0,0, 1,1, 0,alpha)
NEXT END IF g_object_unref(scr) RETURN pixy END FUNCTION
SUB WINRESIZABLE(long hugwindow,int state) gtk_window_set_resizable(hugwindow, state) END SUB
SUB CLS(STRING col$) SQUARE(col$, 0,0, Scr_W , Scr_W , TRUE) END SUB
SUB DRAWPAGE() CLS("#090909") LOCAL surf, changed
surf = PIXBUF_CIRCLE_RGBA (0xff0000ff, 100, 2,255,1) PIXBUF_PAINT(surf,50,50) g_object_unref(surf)
surf = PIXBUF_CIRCLE_RGBA (0xff00ff0f, 100, 10,50,1) PIXBUF_PAINT(surf,100,50) g_object_unref(surf)
surf = PIXBUF_CIRCLE_RGBA (0xfffffff, 100, 2,255,0) PIXBUF_PAINT(surf,150,50) g_object_unref(surf)
surf = PIXBUF_LINE_RGBA(0xfffffff,0,0,200,200,1,255) PIXBUF_PAINT(surf,0,0)
changed = gdk_pixbuf_rotate_simple(surf,GDK_PIXBUF_ROTATE_CLOCKWISE)
PIXBUF_PAINT(changed,100,0) g_object_unref(changed) g_object_unref(surf)
surf = PIXBUF_LINE_RGBA(0xff00fff,0,0,500,0,1,255)
FOR N = 50 TO 500 STEP 10 PIXBUF_PAINT(surf,50,N) NEXT
g_object_unref(surf) END SUB
win = WINDOW("HugMaps",600, 400) 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) CLS("#090909") DISPLAY BR Alex Attachments:
|
|
|
Post by alexfish on Nov 21, 2022 6:00:14 GMT 1
Lib Updated beta testing
Post #1
file list
Have Fun + BR Alex
|
|
|
Post by alexfish on Nov 24, 2022 12:43:34 GMT 1
Hi All Found a elementary bug RE HEX2RGB HEX2RGBA , in short HEX size limitation So have a function SUB PUT_PIXEL_RGBA(GdkPixbuf *pixbuf,int x,int y,unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha) Does what it says on the tin Also added sprite from string + explains the above FUNCTION SPRITER(STRING spr$) TYPE long /* STRING example for SPRITER w h bg fg 38:7:0x00000000:Oxff0000ff x x xxxx xxx xxx xxxx xx xx xxxxx xxxxxxxxxxxxxx xx xx xxxxxxx xxxxxxxxxxxxxx x x xxxxx xxxxxxxxxxxxxxxxxx xxx xxx xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */ Now adding save functions BR Alex Picky and no its not the same as above, change of color + added some x's ADDED + make easy parse like 38:7:00,00,FF,FF:FF,FF,00,FF xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx xxx xxxx xx xx xxxxx xxxxxxxxxxxxxx xx xx xxxxxxx xxxxxxxxxxxxxx x x xxxxx xxxxxxxxxxxxxxxxxx xxx xxx xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Attachments:
|
|
|
Post by alexfish on Nov 26, 2022 23:36:10 GMT 1
Hi All Progress Update back ends complete Now working on how do we compose the bits & save Well, it be very elementary , put your commands in the entry box , press enter make a mistake , CLS it, start again The Save is working Now looking at file open "for loading images & save, have the in another app , the parser needs to be done for open BR Alex Picky, with EDITOR, as can see format, can edit the bits+ can be saved as a project,and loaded as a project Attachments:
|
|
|
Post by alexfish on Nov 27, 2022 21:26:50 GMT 1
Hi All Got first stage of compositor done for Image the project is auto saved on changes in the editor can copy,paste, edit,on close edit the project is auto saved, format is same as hug canvas without the () as mention image is done, now starting with rest of the API functions Picky of progress, reloaded project + the saved project Image as png this proved be a Testy job Excuse the green background , normal that would alpha ,hence green to see better BR Alex Attachments:
|
|
|
Post by alexfish on Nov 28, 2022 13:48:43 GMT 1
And So To Possible Vovchiks Dream Canvas ,'Calex' The CANVAS is attach at 0,0 , hence can see the widgets as a foot note:: until the lib is ready as final beta testing RE: pixbuf, has exernal resorces IE /usr/bin/gdk-pixbuf-csource /usr/bin/gdk-pixbuf-pixdata /usr/bin/gdk-pixbuf-thumbnailer
use man gdk-pixbuf-* BR Alex Attachments:
|
|
|
Post by alexfish on Nov 28, 2022 21:40:00 GMT 1
And to the final draw method Here we need hex string into 0xffffffff ALPHA Pixel Most of lib to date + some bits to play with, bring those two circles closer & increase the from 200 to 360 HAVE FUN + BR Alex GDK$ = "libgdk_pixbuf-2.0.so.0"
'IMPORT "gdk_pixbuf_new_from_file ( const char* , void** ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_data (unsigned char* ,int ,int,int ,int,int ,int ,long,long)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_scale_simple(long,int,int,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new (int,int,int ,int ,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_get_width(int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_get_height(int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_loader_new()" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_loader_write(long,unsigned char*, long int, int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_loader_close(long,int)" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_loader_get_pixbuf(long)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_file_at_scale ( const char* , int , int , int , void** ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_file_at_size ( const char* , int , int , void** ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_inline ( int , const unsigned int , int , void** ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_resource ( const char* , void** ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_resource_at_scale ( const char* , int , int , int , void** ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_stream ( long , long , void** ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_stream_at_scale ( long , int , int , int , long , void** ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_stream_finish ( long , void** ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_new_from_xpm_data ( const char** ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_add_alpha ( const long , int , unsigned char , unsigned char , unsigned char ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_apply_embedded_orientation ( long ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_composite ( const long , long , int , int , int , int , double , double , double , double , int , int ) " FROM GDK$ TYPE void IMPORT "gdk_pixbuf_composite_color ( const long , long , int , int , int , int , double , double , double , double , int , int , int , int , int , unsigned int , unsigned int ) " FROM GDK$ TYPE void IMPORT "gdk_pixbuf_composite_color_simple ( const long , int , int , int , int , int , unsigned int , unsigned int ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_flip ( const long , int ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_copy ( const long ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_copy_area ( const long , int , int , int , int , long , int , int ) " FROM GDK$ TYPE void IMPORT "gdk_pixbuf_copy_options ( long , long ) " FROM GDK$ TYPE int IMPORT "gdk_pixbuf_fill ( long , unsigned int ) " FROM GDK$ TYPE void IMPORT "gdk_pixbuf_new_subpixbuf ( long , int , int , int , int ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_read_pixel_bytes ( const long ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_read_pixels ( const long ) " FROM GDK$ TYPE const unsigned int IMPORT "gdk_pixbuf_ref ( long ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_rotate_simple ( const long , int ) " FROM GDK$ TYPE long IMPORT "gdk_pixbuf_save ( long , const char* , const char* , void** , ... ) " FROM GDK$ TYPE int IMPORT "gdk_pixbuf_save_to_buffer ( long , char** , unsigned int* , const char* , void** , ... ) " FROM GDK$ TYPE int IMPORT "gdk_pixbuf_save_to_stream ( long , long , const char* , long , void** , ... ) " FROM GDK$ TYPE int IMPORT "gdk_pixbuf_save_to_stream_async ( long , long , const char* , long , long , void* , ... ) " FROM GDK$ TYPE void IMPORT "gdk_pixbuf_get_byte_length(long)" FROM GDK$ TYPE unsigned long IMPORT "gdk_pixbuf_get_n_channels" FROM GDK$ TYPE int IMPORT "gdk_pixbuf_get_pixels(long)" FROM GDK$ TYPE unsigned char* IMPORT "gdk_pixbuf_get_rowstride" FROM GDK$ TYPE int IMPORT "g_object_unref(long)" FROM "libgobject-2.0.so.0" TYPE void
CONST GDK_INTERP_HYPER = 3 ' copy CONST GDK_PIXBUF_ROTATE_NONE = 0 'Rotate by 90 degrees. CONST GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE = 90 'Rotate by 180 degrees. CONST GDK_PIXBUF_ROTATE_UPSIDEDOWN = 180 'Rotate by 270 degrees CONST GDK_PIXBUF_ROTATE_CLOCKWISE =270
SUB PUT_PIXEL_RGBA(long pixbuf,int x,int y,unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
LOCAL pixels,p TYPE unsigned char* LOCAL width,height,rowstride,n_channels
' check x y fits width & heigh before getting to here 'width = gdk_pixbuf_get_width (pixbuf) 'height = gdk_pixbuf_get_height (pixbuf)
rowstride = gdk_pixbuf_get_rowstride (pixbuf) n_channels = gdk_pixbuf_get_n_channels (pixbuf) pixels = gdk_pixbuf_get_pixels (pixbuf) ' // The pixel we wish to modify p = pixels + y * rowstride + x * n_channels
p[0] = red p[1] = green p[2] = blue p[3] = alpha
END SUB '=================================================================================================
'=================================================================================================
LOCAL t,j ,c TYPE float LOCAL lx,ly TYPE float pixy = gdk_pixbuf_new(0,TRUE,8,800,800)
radius = 25 bluealpha$ ="0000FFFF" LOCAL r,g,b,a TYPE unsigned char r = DEC(MID$(bluealpha$,1,2)) g = DEC(MID$(bluealpha$,3,2)) b = DEC(MID$(bluealpha$,5,2)) a = DEC(MID$(bluealpha$,7,2))
FOR t=1 TO 360 STEP 0.5
lx = SIN(RAD(t+c))*radius ly = COS(RAD(t+c))*radius 'gdk_pixbuf_composite(scr,pixy, radius+1+lx,radius2+1+ly, px_size,px_size, 0,0, 1,1, 0,alpha) PUT_PIXEL_RGBA(pixy, 200+lx,200+ly,r,g,b,a) PUT_PIXEL_RGBA(pixy, 210+lx,200+ly,0,0,255,255)
NEXT FOR t = 0 TO 100 STEP 2 FOR j=0 TO 360 PUT_PIXEL_RGBA(pixy, j,t,DEC("FF"),DEC("FF"),DEC("00"),DEC("FF")) NEXT NEXT
LOCAL angle TYPE double LOCAL hug_xsize = 200, hug_ysize = 100 LOCAL hug_x = 0,hug_y=0
FOR i = 1 TO 360 angle = 2 * PI * i / 360 x = (hug_xsize/2)*COS(angle) y = (hug_ysize/2)*SIN(angle) PUT_PIXEL_RGBA(pixy,hug_x+(hug_xsize/2)+x, hug_y+(hug_ysize/2)+y,DEC("FF"),DEC("00"),DEC("00"),DEC("FF")) NEXT
gdk_pixbuf_save (pixy,"/home/pi/testall.png", "png", 0, NULL, NULL, NULL) g_object_unref(pixy)
/code]
|
|
|
Post by alexfish on Nov 29, 2022 12:02:55 GMT 1
Hi All
as poor luck would have it
main rpi4 m.2card is down .
any way did a install latest pi os on usb stick.
Installing BaCon , gtk2 , in short not holding much hope for its future
However 3 hours in on configuring, now compiling bacon
gtk2 + dev = a long road of bits required,
as a matter of consequence Ubuntu 20.10 need same
Back soon Back on bacon :: in end had to do fresh install on m.2 card , rather fishy, agh well BR Alex
|
|
|
Post by alexfish on Nov 29, 2022 15:29:36 GMT 1
Hi All TESTING method 'gdk_pixbuf_new_subpixbuf'
LOCAL t,j ,c TYPE float LOCAL lx,ly TYPE float pixy = gdk_pixbuf_new(0,TRUE,8,800,800)
radius = 25 bluealpha$ ="0000FFFF" LOCAL r,g,b,a TYPE unsigned char r = DEC(MID$(bluealpha$,1,2)) g = DEC(MID$(bluealpha$,3,2)) b = DEC(MID$(bluealpha$,5,2)) a = DEC(MID$(bluealpha$,7,2))
FOR t=1 TO 360 STEP 0.5
lx = SIN(RAD(t+c))*radius ly = COS(RAD(t+c))*radius 'gdk_pixbuf_composite(scr,pixy, radius+1+lx,radius2+1+ly, px_size,px_size, 0,0, 1,1, 0,alpha) PUT_PIXEL_RGBA(pixy, 200+lx,200+ly,r,g,b,a) PUT_PIXEL_RGBA(pixy, 210+lx,200+ly,0,0,255,255)
NEXT FOR t = 0 TO 100 STEP FOR j=0 TO 360 PUT_PIXEL_RGBA(pixy, j,t,DEC("FF"),DEC("FF"),DEC("00"),DEC("FF")) NEXT NEXT
LOCAL angle TYPE double LOCAL hug_xsize = 200, hug_ysize = 100 LOCAL hug_x = 0,hug_y=0 newpix = gdk_pixbuf_new_subpixbuf (pixy,hug_x,hug_y,hug_xsize,hug_xsize) FOR i = 1 TO 360 angle = 2 * PI * i / 360 x = (hug_xsize/2)*COS(angle) y = (hug_ysize/2)*SIN(angle) PUT_PIXEL_RGBA(newpix,hug_x+(hug_xsize/2)+x, hug_y+(hug_ysize/2)+y,DEC("FF"),DEC("00"),DEC("00"),DEC("FF")) NEXT
gdk_pixbuf_save (pixy,"/home/pi/testall.png", "png", 0, NULL, NULL, NULL) g_object_unref(pixy) g_object_unref(newpix)
BR Alex
|
|
|
Post by alexfish on Nov 29, 2022 15:45:14 GMT 1
one more with fill
LOCAL t,j ,c TYPE float LOCAL lx,ly TYPE float pixy = gdk_pixbuf_new(0,TRUE,8,800,800)
radius = 25 bluealpha$ ="0000FFFF" LOCAL r,g,b,a TYPE unsigned char r = DEC(MID$(bluealpha$,1,2)) g = DEC(MID$(bluealpha$,3,2)) b = DEC(MID$(bluealpha$,5,2)) a = DEC(MID$(bluealpha$,7,2))
FOR t=1 TO 360 STEP 0.5
lx = SIN(RAD(t+c))*radius ly = COS(RAD(t+c))*radius 'gdk_pixbuf_composite(scr,pixy, radius+1+lx,radius2+1+ly, px_size,px_size, 0,0, 1,1, 0,alpha) PUT_PIXEL_RGBA(pixy, 200+lx,200+ly,r,g,b,a) PUT_PIXEL_RGBA(pixy, 210+lx,200+ly,0,0,255,255)
NEXT FOR t = 0 TO 100 STEP FOR j=0 TO 360 PUT_PIXEL_RGBA(pixy, j,t,DEC("FF"),DEC("FF"),DEC("00"),DEC("FF")) NEXT NEXT
LOCAL angle TYPE double LOCAL hug_xsize = 200, hug_ysize = 100 LOCAL hug_x = 0,hug_y=0 newpix = gdk_pixbuf_new_subpixbuf (pixy,hug_x,hug_y/2,hug_xsize,hug_xsize/2) gdk_pixbuf_fill(newpix,0xff00ff90) FOR i = 1 TO 360 angle = 2 * PI * i / 360 x = (hug_xsize/2)*COS(angle) y = (hug_ysize/2)*SIN(angle) PUT_PIXEL_RGBA(newpix,hug_x+(hug_xsize/2)+x, hug_y+(hug_ysize/2)+y,DEC("FF"),DEC("00"),DEC("00"),DEC("FF")) NEXT
gdk_pixbuf_save (pixy,"/home/pi/testall.png", "png", 0, NULL, NULL, NULL) g_object_unref(pixy) g_object_unref(newpix)
BR Alex
|
|
|
Post by alexfish on Nov 29, 2022 18:08:59 GMT 1
Circle Filled: possible not size correct. it be hot off the press SUB PUT_PIXEL_RGBA(long pixbuf,int x,int y,unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
LOCAL pixels,p TYPE unsigned char* LOCAL width,height,rowstride,n_channels
' check x y fits width & heigh before getting to here 'width = gdk_pixbuf_get_width (pixbuf) 'height = gdk_pixbuf_get_height (pixbuf)
rowstride = gdk_pixbuf_get_rowstride (pixbuf) n_channels = gdk_pixbuf_get_n_channels (pixbuf) pixels = gdk_pixbuf_get_pixels (pixbuf) ' // The pixel we wish to modify p = pixels + y * rowstride + x * n_channels
p[0] = red p[1] = green p[2] = blue p[3] = alpha
END SUB pixy = gdk_pixbuf_new(0,TRUE,8,400,400) LOCAL angle TYPE double LOCAL hug_xsize = 200, hug_ysize = 100 LOCAL hug_x = 0,hug_y=0 FOR i = 1 TO 360 angle = 2 * PI * i / 360 x = (hug_xsize/2)*COS(angle) y = (hug_ysize/2)*SIN(angle) FOR t = hug_x+(hug_xsize/2)-x TO hug_x+(hug_xsize/2)+x PUT_PIXEL_RGBA(pixy,t, hug_y+(hug_ysize/2)+y,DEC("FF"),DEC("00"),DEC("00"),DEC("FF")) NEXT NEXT
gdk_pixbuf_save (pixy,"/home/pi/testall.png", "png", 0, NULL, NULL, NULL) g_object_unref(pixy) Put over solid color then use alpha, have a Window or a hole or what ever you want a hole for BR Alex
|
|
|
Post by alexfish on Nov 29, 2022 19:53:44 GMT 1
Posting this Gtk3 bit as a one off will start a gtk3 pixbuf thread Draw Solid Circle 400x400' gtk3 image/pixbuf test demo '========gtk3 PRAGMA LDFLAGS `pkg-config gtk+-3.0 --libs` PRAGMA OPTIONS `pkg-config gtk+-3.0 --cflags` PRAGMA INCLUDE <gtk-3.0/gtk/gtk.h> '========pixbuff PRAGMA LDFLAGS `pkg-config gdk-pixbuf-2.0 --libs` PRAGMA OPTIONS `pkg-config gdk-pixbuf-2.0 --cflags` PRAGMA INCLUDE <gdk-pixbuf/gdk-pixbuf.h> '========gobject PRAGMA LDFLAGS `pkg-config gobject-2.0 --libs` PRAGMA OPTIONS `pkg-config gobject-2.0 --cflags` PRAGMA INCLUDE <glib-object.h> ' 'C headers glib-object.h 'pkg-config files gobject-2.0 ' OPTION PARSE FALSE
DECLARE window , image TYPE GtkWidget * DECLARE pixy TYPE GdkPixbuf* DECLARE layer TYPE GtkWidget * '============================================================================ SUB PUT_PIXEL_RGBA(GdkPixbuf* pixbuf,int xpos,int ypos,unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
LOCAL pixels,p TYPE unsigned char* LOCAL width,height,rowstride,n_channels
' check x y fits width & heigh before getting to here 'width = gdk_pixbuf_get_width (pixbuf) 'height = gdk_pixbuf_get_height (pixbuf)
rowstride = gdk_pixbuf_get_rowstride (pixbuf) n_channels = gdk_pixbuf_get_n_channels (pixbuf) pixels = gdk_pixbuf_get_pixels (pixbuf) ' // The pixel we wish to modify p = pixels + ypos * rowstride + xpos * n_channels
p[0] = red p[1] = green p[2] = blue p[3] = alpha
END SUB LOCAL workarea = {0} TYPE GdkRectangle '============================================================ gtk_init (&argc, &argv) gdk_monitor_get_workarea(gdk_display_get_primary_monitor(gdk_display_get_default()),&workarea)
'IMPORT "gtk_fixed_new" FROM hug_Gtk$ TYPE long 'IMPORT "gtk_fixed_put(long,long,int,int)" FROM hug_Gtk$ TYPE void window = gtk_window_new (GTK_WINDOW_TOPLEVEL)
gtk_window_set_title (GTK_WINDOW (window), "BaCon Rules") layer = gtk_fixed_new() g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL)
gtk_container_add(GTK_CONTAINER(window), layer)
pixy = gdk_pixbuf_new(0,TRUE,8,800,800) gdk_pixbuf_fill(pixy,0xa0a0a02f) 'gdk_pixbuf_new (GdkColorspace colorspace,gboolean has_alpha,int bits_per_sample,int width,int height) image = gtk_image_new_from_pixbuf (pixy) 'GtkFixed* gtk_fixed_put(GTK_FIXED(layer),image,0,0) 'gtk_widget_set_size_request(GTK_WIDGET (layer),600,400)
gtk_widget_show (GTK_WIDGET(image)) gtk_widget_show_all (window) gtk_window_set_resizable(GTK_WINDOW (window), FALSE)
LOCAL angle TYPE double
wt = gdk_pixbuf_get_width(pixy) LOCAL hug_xsize = 400, hug_ysize = 400 TYPE double LOCAL x,y,t,i TYPE double LOCAL hug_x = 0,hug_y=0 FOR i = 0 TO 360 STEP .05 angle = 2 * PI * i / 360 x = (hug_xsize/2)*COS(angle) y = (hug_ysize/2)*SIN(angle) FOR t = (hug_xsize/2)-x TO hug_x+(hug_xsize/2)+x PUT_PIXEL_RGBA(pixy,t, hug_y+(hug_ysize/2)+y,DEC("FF"),DEC("Ff"),DEC("00"),DEC("FF")) NEXT NEXT
gtk_main () Get size of screen PRAGMA LDFLAGS `pkg-config gtk+-3.0 --libs` PRAGMA OPTIONS `pkg-config gtk+-3.0 --cflags` PRAGMA INCLUDE <gtk-3.0/gtk/gtk.h>
OPTION PARSE FALSE
LOCAL window TYPE GtkWidget * LOCAL workarea = {0} TYPE GdkRectangle
gtk_init (&argc, &argv) gdk_monitor_get_workarea(gdk_display_get_primary_monitor(gdk_display_get_default()),&workarea) PRINT "Width Height ", workarea.width, ": " ,workarea.height window = gtk_window_new (GTK_WINDOW_TOPLEVEL) gtk_window_set_title (GTK_WINDOW (window), "BaCon Rules") g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL) 'code here
'code end gtk_widget_show (window) gtk_main ()
/* void gdk_monitor_get_workarea ( GdkMonitor* monitor, GdkRectangle* workarea ) */ What do I think about gtk3 ? BR Alex Attachments:
|
|
|
Post by alexfish on Nov 29, 2022 20:49:28 GMT 1
|
|