On 07/23/12 05:05, Michiel wrote:
> I'm fairly new to FLTK, and I want to create a neat looking interface using
> FLTL on an embedded system without OpenGL.
> What would like to have is a "progress bar" in the shape of an battery.
> For this I made a battery picture, but I'm a little stuck on how I can only
> select a part of that image and put that on the screen. FLTK doesn't seem to
> have a funcion like CopyRect(Source, Dest, SrcRect, DestRect) to simply copy
> a part of an image to another image. (Might come handy in the future).
> So I was wondering do I need to make such functions myself or does FLTK
> provide something functionallity for handeling parts of an image or drawing
> parts of images on a canvas-like component?
I've used the clipping stack to do such things..
ie. fl_push_clip(x,y,w,h)/fl_pop_clip().
So for instance if you have two images:
1) battery 'full',
2) battery 'empty'
..then draw both images using the clip region to control
which part of each image to show.
So to draw '75% full', let's say the two images ("fullbatt" and
"emptybatt")
are 100 pixels wide, and I wanted to draw 75% full:
fl_push_clip(x,y, 75, h);
fullbatt->draw(x,y);
fl_pop_clip();
fl_push_clip(x+75,y, 25, h);
emptybatt->draw(x,y);
fl_pop_clip();
Pretty sure that'd work.
You could probably do it with just one clip call by drawing
the entire full battery, then just clip the empty image.
Might flicker though unless you're using an Fl_Double_Window.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk