Whitebeam Object Definition

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Object Definition

Method Description

GraphicImage.setClipRegion()

Limit drawing functions to a subset of the entire image

Syntax

GraphicImage = GraphicImage.setClipRegion(top_left, bottom_right)

Parameters

The 'GraphicImage.setClipRegion' method takes 2 parameters:

Name Type/Value Range/Length Description
top_leftstruct GraphicImage.Pointsee definition Optional, default = {x:0,y:0}
Coordinates of the top-left of the clip region
bottom_rightstruct GraphicImage.Pointsee definition Optional, default = {x:image.width,y:image.height}
Coordinates of the bottom-right of the clip region

Results

The 'GraphicImage.setClipRegion' method returns GraphicImage:

Type/Value Range/Length Description
GraphicImage   Return a reference to the GraphicImage (to 'this')

Remarks

By default drawing operations can change any area of the destination image. For those occassions where you want to restrict drawing to a specific area, for example within a frame, you can use setClipRegion.

To subsequently clear the restriction, simply call setClipRegion with no parameters.

Example

Load a 'frame' and then write some text within the border - making sure the 10 pixel border is not over-written :

  // Create an empty 100x100 pixel palette based image
  var border = (new GraphicImage).make('/images/border.gif','image/gif');

  // Set clip region to avoid the 10 pixel border all the way round the image
  border.setClipRegion({x:10,y:10},{x:border.width-20, y:border.height-20});

  // Write some text
  var r = rimg.drawText("Hello World",{x:40,y:40},"/fonts/comic.ttf",20,0x202020);
        
Whitebeam release 1.3.36
(loadtime : 13ms)