2009年8月7日星期五

ActionScript 3.0 Image Effects

颱風天在家裡,甚麼事情也不能做,更扯的是餐城也進不去,詭異的是我老婆可以...$%&@#,這時候只能暗自猜想 playfish 該不會將我的電腦變成拒絕往來戶了吧。既然沒有遊戲可以玩,只好趁機花點時間再繼續看看之前買的書:

ActionScript 3.0 Image Effects
http://tlsj.tenlong.com.tw/WebModule/BookSearch/bookSearchViewAction.do?isbn=1430218711&sid=50458



本書的章節如下:

1. The Drawing API

無廢話,直接快速帶過常用的 API 語法。甚至會提到 Flash Player 10 才支援的語法,譬如 Graphics 的:

copyFrom(sourceGraphics:Graphics):void
Copies all of drawing commands from the source Graphics object into the calling Graphics object.

lineBitmapStyle(bitmap:BitmapData, matrix:Matrix = null, repeat:Boolean = true, smooth:Boolean = false):void
Specifies a bitmap to use for the line stroke when drawing lines.

drawTriangles(vertices:Vector.<Number>, indices:Vector.<int> = null, uvtData:Vector.<Number> = null, culling:String = "none"):void
Renders a set of triangles, typically to distort bitmaps and give them a three-dimensional appearance.

"繪製命令" 本身也可以被當作物件來操作、管理,那要做 undo 應該就會更容易些。還有像是使用 BitmapData 當作畫線的素材,這也是之前所沒有的。至於繪製三角形組的語法,若是搭配 BitmapData 填圖的話,那就可以用來實作 3D 貼圖的效果。


2. Filters and Blend Modes

介紹大部分的 Filter 與 Blend Modes,與其他書本類似。

會提到類似這篇文章的內容:http://blog.ben.idv.tw/2008/09/convolutionfilter.html

3. Bitmaps and BitmapData

談到點陣圖、像素、位元等等的基本知識。加上搭配 ColorTransform 做一些特效變化。


4. Advanced Bitmap Manipulation

談到 BitmapData.noise()、perlinNoise()、copyChannel(),還有像是數位相機常會提供影像光譜資訊的功能:

Computes a 256-value binary number histogram of a BitmapData object.

接著會提到 threshold(),也就是我們會用來做 webcam 動態偵測時所需要的功能:http://blog.ben.idv.tw/2008/08/webcam.html
甚至可以用來做動態去背的機制。

另外也會再多談到幾個 photoshop 中所提供的功能 要如何用 AS3 做到。

5. Pixel Bender and Shaders

帶過 Pixel Bender Toolkit 的使用,想當然不會離題太遠而提到 Pixel Bender language 的語法,然後接著就是在 AS3 中如何使用 Shader 載入 *.pbj,以及如何在 AS3 中提供 kernel 所需的參數。

6. ActionScript in the Third Dimension

很有用的章節,會先將 2.5D 解釋完,然後用一點點簡單的範例說明。

談到用 Vector3D、Matrix3D 來對每個 3D 座標作位移、距離計算等等。

因為 3D 的 z,跟實際上每個 DisplayObject 被加進 Display List 的順序所造成的 Depth 不同,所以需要 Transform 類別新加的方法來處理以計算每個 3D 的 z 換成 2D 後的大小:

Returns a Matrix3D object, which can transform the space of a specified display object in relation to the current display object's space.

然後再進行排序,以決定重新加入 Display List 的順序。

最後會提到以 BitmapData 進行 3D 貼圖的做法,也會用到 drawTriangles() 來完成。

這章節,提到不少小型 3D Engine 原理。

7. Using an Animation and Effect Library

使用以下兩組 library:

比較特別的是,他有支援複合式動畫、特效的機制,使用了 Composite 設計模式,可用來製作連續動畫,將多個動畫組合起來做 連續 或 同時 播放。






以下章節還沒閱讀到,不過相信也會很精彩

8. Elemental Animation Effects
9. Text Effects
10. Video Effects
11. Sound Visualization Effects
12. Interactive Effects



非常值得推薦給需要做影像處理、特效的開發者閱讀,或是一些網路活動要針對 webcam 拍照後做特效的機制,也都可以參考本書的範例程式。




最後,補充一點,以上我貼的語法說明,是從 adobe 官網貼來的,若你手邊的 Help 檔是 Flash CS3 的話,那是不夠的,因為只支援到 Flash Player 9,一定要找有支援到 Flash Player 10 的新版 Help 才行,譬如 Flex 3.3 的 Help:



1 意見:

Design Plus Plus 提到...

這本看起來還不錯耶,邦大颱風天也在K書,真用功~:)

關於我






* ben {dot} chang {at} ben {dot} idv {dot} tw
* FriendFeed

贊助我1元美金:

Plurk

標籤雲