• 点击图片产生水波纹特效的图片(FLASH)


    打开Macromedia Flash 8.0

    一、设置舞台大小(380×175)。
    二、导入图片到库,不要导入到舞台。
    三、打开库设置图片链接。标识符为:surface ,将“为运行时导入”勾去掉,勾上“为actionscript 导出”和“在第一帧导出”
    四、在第一帧插入动作代码(按F9,把下列代码粘贴进去即可)
    var damper = new flash.display.BitmapData(380, 175, false, 128);
    var result = new flash.display.BitmapData(380, 175, false, 128);
    var result2 = new flash.display.BitmapData(380, 175, false, 128);
    var source = new flash.display.BitmapData(380, 175, false, 128);
    var buffer = new flash.display.BitmapData(380, 175, false, 128);
    var output = new flash.display.BitmapData(380, 175, true, 128);
    var surface = flash.display.BitmapData.loadBitmap("surface");
    var bounds = new flash.geom.Rectangle(0, 0, 380, 175);
    var origin = new flash.geom.Point();
    var matrix = new flash.geom.Matrix();
    var matrix2 = new flash.geom.Matrix();
    matrix2.a = matrix2.d = 2;
    var wave = new flash.filters.ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9, 0);
    var damp = new flash.geom.ColorTransform(0, 0, 9.960937E-001, 1, 0, 0, 2, 0);
    var water = new flash.filters.DisplacementMapFilter(result2, origin, 4, 4, 48, 48, "ignore");
    attachBitmap(output, 0);
    var ms = getTimer();
    var frame = 0;
    var mouseDown = false;
    onMouseDown = function ()
    {
    mouseDown = true;
    };
    onMouseUp = function ()
    {
    onEnterFrame();
    mouseDown = false;
    };
    onEnterFrame = function ()
    {
    if (mouseDown)
    {
    var _loc2 = _xmouse / 2;
    var _loc1 = _ymouse / 2;
    source.setPixel(_loc2 + 1, _loc1, 16777215);
    source.setPixel(_loc2 - 1, _loc1, 16777215);
    source.setPixel(_loc2, _loc1 + 1, 16777215);
    source.setPixel(_loc2, _loc1 - 1, 16777215);
    source.setPixel(_loc2, _loc1, 16777215);
    } // end if
    result.applyFilter(source, bounds, origin, wave);
    result.draw(result, matrix, null, "add");
    result.draw(buffer, matrix, null, "difference");
    result.draw(result, matrix, damp);
    result2.draw(result, matrix2, null, null, null, true);
    output.applyFilter(surface, new flash.geom.Rectangle(0, 0, 380, 175), origin, water);
    buffer = source;
    source = result.clone();
    };

    五、把帧频提高点(默认为12)

    六、测试影片,呵呵,水波涟漪,真实再现,赶快试试吧!

    七、效果演示:

  • 相关阅读:
    C#创建Windows Service(Windows 服务)基础教程
    c#写windows服务
    怎么样快速学习AngularJS?
    Web API 安全问题
    ASP.NET Web API身份验证和授权
    通过HttpClient来调用Web Api接口~续~实体参数的传递
    在WebApi中实现Cors访问
    SQL Server 动态生成数据库所有表Insert语句
    EasyUI combobox
    Linq使用Group By 1
  • 原文地址:https://www.cnblogs.com/guardian/p/2301876.html
Copyright © 2020-2023  润新知