Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How? Tiled image in region defined by arc
How? Tiled image in region defined by arc [message #451739] Mon, 07 March 2005 21:41 Go to next message
Eclipse UserFriend
Originally posted by: jcuri.hotmail.com

I have an SWT image that needs to be drawn on a GC tiled within a region
defined by an ARC (either a bow arc or a pie shaped arc). This seems like
something trivial but I can't figure out how to do this.

Similarly, how do I fill an arc or a pie shaped arc with a gradient color?

I need to get this working with Eclipse 3.0. Any suggestions?

P.S. I know there are newer rendering features provided in the latest 3.1
milestone M5 (that I haven't looked at) but my app needs to be 3.0
compatible.
Re: How? Tiled image in region defined by arc [message #451747 is a reply to message #451739] Tue, 08 March 2005 12:44 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
You need to define a Region that represents the shape to be filled in. Then
you set the clipping of the GC you are drawing with to be that region. Draw
in the bounding rectangle of the Region and it will be clipped to the odd
shape. Don't forget to dispose of the region. If doing this in the Paint
event, don't forget to restore the original clipping.

e.g. (Based on CTabFolder.fillRegion) :

//define a region for the irregular shape
int[] shape = new int[] {0,0, 10,10, 10,20, 30,20, 30,10, 25,5}; // some
points that define your shape
Region region = new Region();
region.add(shape);

//store original clipping
Region clipping = new Region();
gc.getClipping(clipping);

//limit drawing to the interstion of the damaged area and your irregular
shape
region.intersect(clipping);
gc.setClipping(region);

//draw gradient
Rectangle bounds = region.getBounds();
gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width, bounds.height,
false);

//restore original clipping
gc.setClipping(clipping);
clipping.dispose();

// Region objects must be disposed because they are system resources
region.dispose();



"Jamie Curier" <jcuri@hotmail.com> wrote in message
news:d0ihpf$5vf$1@www.eclipse.org...
>
> I have an SWT image that needs to be drawn on a GC tiled within a region
> defined by an ARC (either a bow arc or a pie shaped arc). This seems like
> something trivial but I can't figure out how to do this.
> Similarly, how do I fill an arc or a pie shaped arc with a gradient color?
>
> I need to get this working with Eclipse 3.0. Any suggestions?
>
> P.S. I know there are newer rendering features provided in the latest 3.1
> milestone M5 (that I haven't looked at) but my app needs to be 3.0
> compatible.
>
Previous Topic:Any multimedia controls in SWT?
Next Topic:DirectedGraph and the Edge.tree field
Goto Forum:
  


Current Time: Thu Apr 18 23:02:56 GMT 2024

Powered by FUDForum. Page generated in 0.01981 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top