DisplacementMapFilter clone [AS 2]
Klasa: DisplacementMapFilter
Kompatybilność: ActionScript 1.0, Flash 8+
Zwraca identyczną kopię obiektu filtru.
Listing
import flash.filtrs.DisplacementMapFilter;
import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Matrix;
import flash.geom.ColorTransform;
var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial", true);
var filtr_1:DisplacementMapFilter = new DisplacementMapFilter(mapBitmap, new Point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000);
var filtr_2:DisplacementMapFilter = filtr_1;
var clonedFilter:DisplacementMapFilter = filtr_1.clone();
trace(filtr_1 == filtr_2); // true
trace(filtr_1 == clonedFilter); // false
for(var i in filtr_1) {
trace(">> " + i + ": " + filtr_1[i]);
// >> clone: [type Function]
// >> alpha: 0
// >> color: 0
// >> mode: wrap
// >> scaleY: 10
// >> scaleX: 10
// >> componentY: 1
// >> componentX: 1
// >> mapPoint: (-30, -30)
// >> mapBitmap: [object Object]
}
for(var i in clonedFilter) {
trace(">> " + i + ": " + clonedFilter[i]);
// >> clone: [type Function]
// >> alpha: 0
// >> color: 0
// >> mode: wrap
// >> scaleY: 10
// >> scaleX: 10
// >> componentY: 1
// >> componentX: 1
// >> mapPoint: (-30, -30)
// >> mapBitmap: [object Object]
}
function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData {
var mc:MovieClip = this.createEmptyMovieClip("mc", 1);
var matrix:Matrix = new Matrix();
matrix.createGradientBox(w, h, 0, 0, 0);
mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad");
mc.lineTo(w, 0);
mc.lineTo(w, h);
mc.lineTo(0, h);
mc.lineTo(0, 0);
mc.endFill();
(hide == true) ? mc._alpha = 0 : mc._alpha = 100;
var bmp:BitmapData = new BitmapData(w, h, true, bgColor);
bmp.draw(mc, new Matrix(), new ColorTransform(), "normal", bmp.rectangle, true);
mc.attachBitmap(bmp, this.getNextHighestDepth());
return bmp;
}
import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Matrix;
import flash.geom.ColorTransform;
var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial", true);
var filtr_1:DisplacementMapFilter = new DisplacementMapFilter(mapBitmap, new Point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000);
var filtr_2:DisplacementMapFilter = filtr_1;
var clonedFilter:DisplacementMapFilter = filtr_1.clone();
trace(filtr_1 == filtr_2); // true
trace(filtr_1 == clonedFilter); // false
for(var i in filtr_1) {
trace(">> " + i + ": " + filtr_1[i]);
// >> clone: [type Function]
// >> alpha: 0
// >> color: 0
// >> mode: wrap
// >> scaleY: 10
// >> scaleX: 10
// >> componentY: 1
// >> componentX: 1
// >> mapPoint: (-30, -30)
// >> mapBitmap: [object Object]
}
for(var i in clonedFilter) {
trace(">> " + i + ": " + clonedFilter[i]);
// >> clone: [type Function]
// >> alpha: 0
// >> color: 0
// >> mode: wrap
// >> scaleY: 10
// >> scaleX: 10
// >> componentY: 1
// >> componentX: 1
// >> mapPoint: (-30, -30)
// >> mapBitmap: [object Object]
}
function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData {
var mc:MovieClip = this.createEmptyMovieClip("mc", 1);
var matrix:Matrix = new Matrix();
matrix.createGradientBox(w, h, 0, 0, 0);
mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad");
mc.lineTo(w, 0);
mc.lineTo(w, h);
mc.lineTo(0, h);
mc.lineTo(0, 0);
mc.endFill();
(hide == true) ? mc._alpha = 0 : mc._alpha = 100;
var bmp:BitmapData = new BitmapData(w, h, true, bgColor);
bmp.draw(mc, new Matrix(), new ColorTransform(), "normal", bmp.rectangle, true);
mc.attachBitmap(bmp, this.getNextHighestDepth());
return bmp;
}
Dodano przez: divix
Ranga: Administrator serwisu Punktów: 0
Ranga: Administrator serwisu Punktów: 0
Komentarze użytkowników
:: Losowe artykuły
:: Wymiana linków
Modowe inspiracje |
Android Gry i Aplikacje |
ZaplanujTransport.pl: Przeprowadzki, transport, aukcje |
Logo dla firmy |
Change Tires - Car Weather Forecast Reminder |
Laminas: MVC Framework for PHP |
IT Books Reviews and Programming: JS, JAVA, PHP, ANDROID, CSS |
Katalog roślin |
Programming articles: JAVA, PHP, C++, Python, JavaScript |
Kancelaria Adwokacka Łukasz Huszno