ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > ConvolutionFilter (flash.filters.ConvolutionFilter) > clamp (ConvolutionFilter.clamp property) | |||
public clamp : Boolean
Indicates whether the image should be clamped. For pixels that are off the source image, a value of true indicates that the input image is extended along each of its borders as necessary by duplicating the color values at the given edge of the input image. A value of false indicates that another color should be used, as specified in the color and alpha properties. The default is true.
Availability: ActionScript 1.0; Flash Player 8
The following example creates two boxes using the BitmapData class, one of which is half the size of the other. When the example first loads, the larger box is drawn inside mc using the attachBitmap(). When mc is clicked and the applyFilter() method is called, the largeBox instance of BitmapData is redrawn with smallBox as a source bitmap. Since applyFilter() draws smallBox over a Rectangle whose width and height is specified as those of largeBox, the source bitmap is smaller than the drawing area. The clamp property of ConvolutionFilter in this case is set to false and the area which is not covered by the source bitmap, smallBox, is a solid red as determined by the clampColor and clampAlpha variables.
import flash.filters.ConvolutionFilter;
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
// Variables that affect clamping:
var clamp:Boolean = false;
var clampColor:Number = 0xFF0000;
var clampAlpha:Number = 1;
// For illustration, keep other ConvolutionFilter variables neutral:
var bias:Number = 0;
var preserveAlpha:Boolean = true;
// Construct a neutral matrix
var matrixCols:Number = 3;
var matrixRows:Number = 3;
var matrix:Array = [ 1,1,1,
1,1,1,
1,1,1 ];
var filter:ConvolutionFilter = new ConvolutionFilter(matrixCols, matrixRows, matrix, matrix.length, bias, preserveAlpha, clamp, clampColor, clampAlpha);
var largeBoxWidth:Number = 100;
var largeBoxHeight:Number = 100;
var largeBox:BitmapData = new BitmapData(largeBoxWidth, largeBoxWidth, true, 0xCC00FF00);
var smallBoxWidth:Number = largeBoxWidth / 2;
var smallBoxHeight:Number = largeBoxHeight / 2;
var smallBox:BitmapData = new BitmapData(smallBoxWidth, smallBoxWidth, true, 0xCC0000FF);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(largeBox, this.getNextHighestDepth());
mc.onPress = function() {
largeBox.applyFilter(smallBox, new Rectangle(0,0, largeBoxWidth, largeBoxHeight), new Point(0,0), filter);
}
|
|
|
|