Filtro de brilho de gradienteFlash Player 9 e posterior, Adobe AIR 1.0 e posterior A classe GradientGlowFilter permite a aplicação de um efeito de brilho aprimorado em objetos de exibição ou objetos BitmapData. Os efeitos permitem que você tenha mais controle sobre o brilho e produza um efeito mais realista. Além disso, o filtro de brilho de gradiente permite aplicar um brilho gradiente nas bordas interna, externa ou superior de um objeto. O exemplo a seguir desenha um círculo no palco e aplica um filtro de brilho de gradiente a ele. À medida que você move o mouse mais para a direita e para baixo, a quantidade de desfoque aumenta nas direções horizontal e vertical, respectivamente. Além disso, sempre que você clicar no palco, a intensidade do desfoque aumentará. 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); |
![]() |