Hello,
I am in the way to start (at least try) coding some applications with FreeBASIC.
I need something cross platform Windows - Linux so after tests with FLTK and GTK I think I will use GTK3 with Glade + GladeToBac as ui builder.
Installing that under linux was easy but not so easy into Windows.
After some search and reading (msys2, etc...) finally I got Glade - GladeToBac - Freebasic working on both system and can compile and run simple things.
Now the question :
In the apps I need to draw some geometrical figures (lines, triangles, circles...) into a "canvas". I also need the functions for scaling this canvas and made pan and zoom (usually called world coordinates, screen coordinates etc...).
I found in the GTK documentation the "GtkDrawigArea". Is that what I sould use ? Or is there some better widget to do that ?
And where can I find tutorial, documentation and even samples in FreeBASIC language of what I try to do ? It seems I also need to learn some things about Cairo but it is unclear what I have to do with GTK (create the area) and with Cairo (draw into the area)...
Thanks and regards.
Philippe
Freebasic -GTK - Graphics
Re: Freebasic -GTK - Graphics
you can try make code with "VisualFBEditor - IDE for FreeBasic" viewtopic.php?t=27284
VisualFBEditor based on the library MyFbFramework which is an open source library. A lot of programmers work with it with GTK3 in Linux
VisualFBEditor based on the library MyFbFramework which is an open source library. A lot of programmers work with it with GTK3 in Linux
Re: Freebasic -GTK - Graphics
I give a try under Windows and look well !
I have to do some test under Linux now.
I have not mention than the graphical part can become very heavy with fe more than 10000 triangles to draw as fast as possible and then make zoom, pan etc on this image.
Cairo and GTK are fast in this kind of operation so in the same time I try to continue my test on the tool chain FB + GTK + Cairo and still search for tutos or examples about that.
I have to do some test under Linux now.
I have not mention than the graphical part can become very heavy with fe more than 10000 triangles to draw as fast as possible and then make zoom, pan etc on this image.
Cairo and GTK are fast in this kind of operation so in the same time I try to continue my test on the tool chain FB + GTK + Cairo and still search for tutos or examples about that.
Re: Freebasic -GTK - Graphics
VisualFBEditor works not smoothly under Linux (I use 22.04 LTS Kubuntu).
I can compile and run but the IDE show lot of what look like bugs.
Selection case stay empty (but the selection seems to act)
No way to resize controls with the mouse into a form
If change control size by hand in the properties its not take in account after compile... and so on !
I can compile and run but the IDE show lot of what look like bugs.
Selection case stay empty (but the selection seems to act)
No way to resize controls with the mouse into a form
If change control size by hand in the properties its not take in account after compile... and so on !
Re: Freebasic -GTK - Graphics
Hello,
I need some help usin GTK3 + Cairo into FreeBasic.
I have found an example of cade where Cairo draw into a "screen" opened with ScreenRes...
I belive I should change something into the "surface" declaration... I try "DrArea" instead of ScreenPtr() but I got a warning at compile and nothing is displayed..
Thanks and regards.
Philippe
I need some help usin GTK3 + Cairo into FreeBasic.
I have found an example of cade where Cairo draw into a "screen" opened with ScreenRes...
How should I modify this code to draw the same thing into a GtkDrawingArea (or may be another Gtk widget but not a screen) ?'' Example showing cairo being used to draw into the FB graphics window
#LIBPATH "c:\msys64\mingw64\lib"
#include once "cairo/cairo.bi"
Const SCREEN_W = 400
Const SCREEN_H = 300
ScreenRes SCREEN_W, SCREEN_H, 32
'' Create a cairo drawing context, using the FB screen as surface.
Var surface = cairo_image_surface_create_for_data(ScreenPtr(), CAIRO_FORMAT_ARGB32, SCREEN_W, SCREEN_H, SCREEN_W * SizeOf(ULong))
Var c = cairo_create(surface)
ScreenLock()
'' Draw the entire context white.
cairo_set_source_rgba(c, 1, 1, 1, 1)
cairo_paint(c)
'' Draw a red line
cairo_set_line_width(c, 1)
cairo_set_source_rgba(c, 1, 0, 0, 1)
cairo_move_to(c, 0, 0)
cairo_line_to(c, SCREEN_W - 1, SCREEN_H - 1)
cairo_stroke(c)
ScreenUnlock()
Sleep
'' Clean up the cairo context
cairo_destroy(c)
I belive I should change something into the "surface" declaration... I try "DrArea" instead of ScreenPtr() but I got a warning at compile and nothing is displayed..
Thanks and regards.
Philippe
-
- Posts: 821
- Joined: Jul 26, 2018 18:28
Re: Freebasic -GTK - Graphics
The compiler's Examples folder contains the following examples:
https://github.com/freebasic/fbc/blob/m ... _image.bas
https://github.com/freebasic/fbc/blob/m ... _Cairo.bas
https://github.com/freebasic/fbc/blob/m ... _image.bas
https://github.com/freebasic/fbc/blob/m ... _Cairo.bas