Article View: comp.sys.amiga.tech
Article #11594Re: ClipRect help wanted
From: Scott Evernden
Date: Sun, 26 Feb 1989 06:53
Date: Sun, 26 Feb 1989 06:53
42 lines
1668 bytes
1668 bytes
In article <5379@abo.fi> rosenbergr@abo.fi (Robin Rosenberg, Computer Science, ]bo Akademi) writes:
>A simple question: What is the best way of doing clipping. I.e
>I would like to render some text and images into a part of a window. If
>the object goes outside the required borders (a rectangle) I want that part
>chopped of. I know the ROMS have a InstallClipRect() function but how do
>I use it?
>Could anyone give me an example of how to do this the right way?
Sure. It's really not too hard...
As part of your init code do:
struct Library *LayersBase;
struct Region *region;
LayersBase = OpenLibrary("layers.library", 0L);
region = NewRegion();
Then, when you want clipping within (xmin,ymin)-(xmax,ymax):
struct Rectangle rect;
rect.MinX = minx;
rect.MinY = miny;
rect.MaxX = maxx;
rect.MaxY = maxy;
ClearRegion(region);
OrRectRegion(region, &rect);
InstallClipRegion(window->RPort->Layer, region);
There are lots of region operations, and you can create clip
areas that are not necessarily rectangular by using combinations
of And/Or/XorRectRegion() and -RegionRegion().
Finally, at cleanup time:
DisposeRegion(region);
InstallClipRegion(window->RPort->Layer, (struct Region *) NULL);
CloseLibrary(LayersBase);
-scott
Technical Details
Message-ID:
<911@applix.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ulowell!m2c!applix!scottReferences:
<5379@abo.fi>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ulowell!m2c!applix!scott From: scott@applix.UUCP (Scott Evernden) Newsgroups: comp.sys.amiga.tech Subject: Re: ClipRect help wanted Message-ID: <911@applix.UUCP> Date: 26 Feb 89 06:53:26 GMT References: <5379@abo.fi> Reply-To: scott@applix.UUCP (Scott Evernden) Organization: APPLiX Inc., Westboro MA Lines: 42