English 中文(简体)
行动:筛查梯度线
原标题:ActionScript - Screen Wrapping A Gradient Line?

我有一个直线梯度线,从屏幕的一端到另一端。

如何最佳(或仅)方法筛选这一条线图,以便看上去?

我目前的“<>索尔ution”是把屏幕的宽度翻一番,重复每半线的梯度。 这条线路由中心注册,并移至右边。 一旦进入阶段,这条线就会重新进入起点。

是否有更好的办法?

最佳回答

我可以认为,唯一的选择是利用提款机提取梯度中线,计算每个框架的抵消额。 但是,这无疑比仅仅在显示物上进行位置转变还要昂贵。 仅凭算术就足以使其放缓。

你提出的解决办法似乎并不多见elegant,或有效率,但鉴于我们正在使用一种高度优化的、用于绘制和改造被忽略的病媒和模型(而且实际上不能依赖任何其他优化)的仪器,我认为,最好的办法就是在这一点上仅仅信任证书。

问题回答

您可以照搬梯度线,并与之挂钩:

package  
{
import flash.display.GradientType;
import flash.display.InterpolationMethod;
import flash.display.SpreadMethod;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;

public class GradientLine extends Sprite 
{
    private var position:Number = 0;

    public function GradientLine() 
    {
        addEventListener( Event.ENTER_FRAME, drawLine );
    }

    private function drawLine(e:Event):void 
    {
        graphics.clear();

        var m:Matrix = new Matrix();
        m.createGradientBox( stage.stageWidth, stage.stageHeight, 0, position, 0 );

        position -= 10;//move from right to left by 10px

        graphics.lineStyle( 2 );
        graphics.lineGradientStyle( GradientType.LINEAR, [ 0xFF0000, 0xFFCC00, 0x0000CC ], [ 1, 1, 1 ], [ 0, 128, 255 ], m, SpreadMethod.REFLECT, InterpolationMethod.RGB, position );

        graphics.moveTo( 0, 250 );
        graphics.lineTo( stage.stageWidth, 250 );
    }
}
}

the stage needs to be available. you can set the createGradientBox ( width , height ) to the size you need. SpreadMethod.REFLECT causes the gradient to reflect, you may want to try SpreadMethod.REPEAT.





相关问题
images sliding continuously with <table> and jQuery

I m trying to write a little test page that circulates images through a window (see image). I have colored boxes inside a table (gray border), with each box being a element. <table id="boxes" ...

WPF 3d rotation animations

I have a few 3d rectangles on my screen that I want to pivot around the Y axis. I want to press down with the mouse, and rotate the 3d object to a max rotation, but when the user moves their mouse, ...

Disable Windows 7 touch animation in WPF

In Windows 7 when you touch the screen there is a short animation that occurs at the touch point. In my WPF app I want to display my own touch points, without showing the one supplied by Windows. ...

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Direct 2D gnuplot PNG animation?

Can anyone please confirm that yes/no Gnuplot 4.5 (on CVS) can output 2D animated PNG files? I have numerous datasets but one line that I d like to show iteratively in 3 different places in my graph. ...

Visual State Manager VS Animations in WPF

There is a lot of talk about the simplicity of Visual States and the transitions between them in WPF/Silverlight. I have the need to generate animations dynamically at runtime, to animate the ...

Create a ImageIcon that is the mirror of another one

I ll like to know if there is a way to create a ImageIcon that is the mirror of another ImageIcon. Searching on Google, I found how to do it by using many AWT libraries. Is there a way to do it with ...

how to drag in the animation in iphone application?

Iphone application is using the static co-ordinates to reach at some points in the application,which is based on the button event. But what i want is when i drag the item than it should reach at some ...

热门标签