漸層光暈濾鏡Flash Player 9 以及更新的版本,Adobe AIR 1.0 以及更新的版本 GradientGlowFilter 類別可讓您對顯示物件或 BitmapData 物件套用增強的光暈特效。此效果可讓您更容易掌控光暈顏色,進而產生更真實的光暈效果。此外,漸層光暈濾鏡可讓您將漸層光暈套用至物件的邊緣內部、外部,或邊緣上方。 下列範例會在「舞台」上繪製一個圓形,並將漸層光暈濾鏡套用至此圓形。當您將滑鼠移至右側並接著往下移時,模糊量就會分別往水平及垂直方向增加。此外,任何時候,只要您在「舞台」上按一下,就可增加模糊的強度。 import flash.events.MouseEvent; import flash.filters.BitmapFilterQuality; import flash.filters.BitmapFilterType; import flash.filters.GradientGlowFilter; // Create a new Shape instance. var shape:Shape = new Shape(); // Draw the shape. shape.graphics.beginFill(0xFF0000, 100); shape.graphics.moveTo(0, 0); shape.graphics.lineTo(100, 0); shape.graphics.lineTo(100, 100); shape.graphics.lineTo(0, 100); shape.graphics.lineTo(0, 0); shape.graphics.endFill(); // Position the shape on the Stage. addChild(shape); shape.x = 100; shape.y = 100; // Define a gradient glow. var gradientGlow:GradientGlowFilter = new GradientGlowFilter(); gradientGlow.distance = 0; gradientGlow.angle = 45; gradientGlow.colors = [0x000000, 0xFF0000]; gradientGlow.alphas = [0, 1]; gradientGlow.ratios = [0, 255]; gradientGlow.blurX = 10; gradientGlow.blurY = 10; gradientGlow.strength = 2; gradientGlow.quality = BitmapFilterQuality.HIGH; gradientGlow.type = BitmapFilterType.OUTER; // Define functions to listen for two events. function onClick(event:MouseEvent):void { gradientGlow.strength++; shape.filters = [gradientGlow]; } function onMouseMove(event:MouseEvent):void { gradientGlow.blurX = (stage.mouseX / stage.stageWidth) * 255; gradientGlow.blurY = (stage.mouseY / stage.stageHeight) * 255; shape.filters = [gradientGlow]; } stage.addEventListener(MouseEvent.CLICK, onClick); stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); |
|