Bitmap 海浪实现方式
package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Shape; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.filters.DisplacementMapFilter; import flash.geom.Point; import flash.utils.getTimer; import tween.EasyTween; public class Test2 extends Sprite { // [Embed(source="_preset.png")] [Embed(source="sea.png")] public var waterBitmapCls:Class; private var refractTmpBitmap:Bitmap; private var refractBmData:BitmapData; private var refractDisplaceFilter:DisplacementMapFilter; private var woBitmapData:BitmapData; private var perlinOffsetPoint:Point = new Point(); private var perlinOffset:Array = []; private var filterArray:Array; private var p:Point = new Point(10, 200); private var _waveLayer:Sprite; private var _shipLayer:Sprite; private var _s:AAA; public static const WATERSIZE:int = 300; public function Test2() { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; // var bbb:BitmapData = new BitmapData(WATERSIZE, WATERSIZE); // bbb.perlinNoise(150, 150, 1, 50, true, true, 7, true, this.perlinOffset); // // var bb:Bitmap = new Bitmap(bbb); // addChild(bb); // return; this.refractTmpBitmap = new waterBitmapCls(); this.refractBmData = new BitmapData(WATERSIZE, WATERSIZE); this.refractDisplaceFilter = new DisplacementMapFilter(this.refractBmData, new Point(0, 0), 1, 2, 10, 20); this.woBitmapData = this.refractTmpBitmap.bitmapData.clone(); this.perlinOffsetPoint.x = 0; this.perlinOffsetPoint.y = 0; this.perlinOffset = [this.perlinOffsetPoint]; this.filterArray = [this.refractDisplaceFilter]; generateWater = true; this.addEventListener(Event.ENTER_FRAME, enterframeHandler); for(var i:int = 0; i < 4; i++) { for(var j:int = 0; j < 4; j++) { var b:Bitmap = new Bitmap(woBitmapData); b.x = i * WATERSIZE; b.y = j * WATERSIZE; this.addChild(b); } } _waveLayer = new Sprite(); addChild(_waveLayer); _shipLayer = new Sprite(); addChild(_shipLayer); _s = new AAA(); _shipLayer.addChild(_s); var l:Shape = new Shape(); l.graphics.lineStyle(1, 0xFF0000); l.graphics.moveTo(WATERSIZE, 100); l.graphics.lineTo(WATERSIZE, WATERSIZE); stage.addChild(l); } private var _t:int = getTimer(); private var generateWater:Boolean = false; private var waterIndex:int = 0; private var waterTiles:Vector.<BitmapData> = new Vector.<BitmapData>(); private var waterDirection:int = -1; private static var waterTileAmount:int = 32; private function enterframeHandler(e:*):void { // this.removeEventListener(Event.ENTER_FRAME, enterframeHandler); var v:Number = 2;//Math.sin(getTimer()) + 10; this.perlinOffsetPoint.x = this.perlinOffsetPoint.x + v; this.perlinOffsetPoint.y = this.perlinOffsetPoint.y - v; this.refractBmData.perlinNoise(80, 80, 1, 50, true, true, 7, true, this.perlinOffset); this.refractTmpBitmap.filters = this.filterArray; this.woBitmapData.lock(); this.woBitmapData.draw(this.refractTmpBitmap); this.woBitmapData.unlock(); // if(generateWater) // { // var v:Number = 2;//Math.sin(getTimer()) + 10; // this.perlinOffsetPoint.x = this.perlinOffsetPoint.x + v; // this.perlinOffsetPoint.y = this.perlinOffsetPoint.y - v; // // this.refractBmData.perlinNoise(80, 80, 1, 50, true, true, 7, true, this.perlinOffset); // this.refractTmpBitmap.filters = this.filterArray; // // this.woBitmapData.lock(); // this.woBitmapData.draw(this.refractTmpBitmap); // this.woBitmapData.unlock(); // // var bitmapData2:BitmapData = this.woBitmapData.clone(); // // this.waterTiles[this.waterIndex] = bitmapData2; // waterIndex++; // if(waterIndex > waterTileAmount) // { // generateWater = false; // waterDirection = -1; // } // } // else // { // waterIndex += waterDirection; // // if (this.waterIndex >= waterTileAmount) // { // this.waterIndex = waterTileAmount; // this.waterDirection = -1; // } // else if (this.waterIndex <= 0) // { // this.waterIndex = 0; // this.waterDirection = 1; // } // // var bitmapData3:BitmapData = this.waterTiles[waterIndex]; // this.woBitmapData.copyPixels(bitmapData3, bitmapData3.rect, new Point()); // } // this.refractTmpBitmap.bitmapData.applyFilter(this.woBitmapData, this.woBitmapData.rect, new Point(), refractDisplaceFilter); // this.woBitmapData.copyPixels(this.refractTmpBitmap.bitmapData, this.refractTmpBitmap.bitmapData.rect, new Point()); // var dltaT:int = getTimer() - _t; EasyTween.updateAll(33); // p.x += 2; _s.x = this.mouseX; _s.y = this.mouseY; Wave.playWave(_s.x, _s.y, _waveLayer); } } }
相关推荐
Bitmap方法C语言实现,支持插入、删除和查找功能。
bitmap是个省空间的数据结构,我的c实现
Linux中软件RAID的Bitmap功能实现分析.pdf
Transparent Bitmap实现透明的位图(7KB)
C#中Bitmap类实现对图像操作的一些方法
软件开发网在此之前给大家介绍过图片加载框架Glide的基本用法介绍,大家可以先参考一下,本篇内容更加深入的分析了Glide获取图片Path、Bitmap用法,以及实现的代码分析。 1. 获取Bitmap: 1)在图片下载缓存好之后...
本文将介绍如何使用Spring Boot结合Redis Bitmap实现签到功能。通过这一实现方式,我们能够有效地进行大量用户的签到统计,节省存储空间并提高性能。文章将先阐述Redis Bitmap的基本原理,随后展示如何在Spring Boot...
学习字体的好资料学习字体的好资料学习字体的好资料学习字体的好资料学习字体的好资料
C#语言下,官方好像没有提供直接的方式把Bitmap转为Mat,但是可以使用我的这个方式转变格式
处理bitmap内存溢出问题
主要介绍了Android 实现把bitmap图片的某一部分的颜色改成其他颜色,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
Bitmap类和PictureBox控件实现显示,保存 源码
android bitmap outofMemory 用来解决android中常见的bitmap outOfMemory
机器视觉技术必备,从位图到halcon图像,bitmap图像转为halcon图像,bitmap to Hobject
Halcon_Bitmap转换方法 写的文档 开发笔记
赠送jar包:RoaringBitmap-0.7.45.jar; 赠送原API文档:RoaringBitmap-0.7.45-javadoc.jar; 赠送源代码:RoaringBitmap-0.7.45-sources.jar; 赠送Maven依赖信息文件:RoaringBitmap-0.7.45.pom; 包含翻译后的API...
bitmap是一个十分有用的结构。所谓的Bit-map就是用一个bit位来标记某个元素对应的Value, 而Key即是该元素。由于采用了Bit为单位来存储数据,因此在存储空间方面,可以大大节省。 适用范围:可进行数据的快速查找,...
改用原始图像数据流回调函数RegisterImageStreamCallback进行抓图 但回调函数帧为YUV420格式 需要转成Bitmap才用用于显示及本地查看 在网上找了好多都是基于R Y+1 4075 V 128 G Y 0 3455 U 128 – 0 7169 V 128 B Y+...
使用clippath实现的CircleImageView,没有Bitmap,没有锯齿