Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
[AS3] PBFilterBase | ||
======================================================================================= | ||
HiSlope toolkit copyright (c) 2010 Tomek 'Og2t' Augustyn | ||
http://play.blog2t.net/hislope | ||
You are free to use this source code in any non-commercial project. | ||
You are free to modify this source code in anyway you see fit. | ||
You are free to distribute this source code. | ||
You may NOT charge anything for this source code. | ||
This notice and the copyright information must be left intact in any distribution of this source code. | ||
You are encouraged to release any improvements back to the ActionScript community. | ||
VERSION HISTORY: | ||
v0.1 Born on 07/07/2009 | ||
USAGE: | ||
TODOs: | ||
DEV IDEAS: | ||
KNOWN ISSUES | ||
---------------------------------------------------------------------------------------------*/ | ||
|
||
package hislope.filters | ||
{ | ||
// IMPORTS //////////////////////////////////////////////////////////////////////////////// | ||
|
||
import hislope.filters.IFilter; | ||
import flash.display.Shader; | ||
import flash.filters.ShaderFilter; | ||
import flash.display.ShaderParameter; | ||
import flash.utils.ByteArray; | ||
import hislope.core.Utils; | ||
|
||
// CLASS ////////////////////////////////////////////////////////////////////////////////// | ||
|
||
public class PBFilterBase extends FilterBase implements IFilter | ||
{ | ||
// CONSTANTS ////////////////////////////////////////////////////////////////////////// | ||
// MEMBERS //////////////////////////////////////////////////////////////////////////// | ||
|
||
protected var shaderFilter:ShaderFilter; | ||
protected var shader:Shader; | ||
private var shaderParams:Array = []; | ||
|
||
// CONSTRUCTOR //////////////////////////////////////////////////////////////////////// | ||
|
||
public function PBFilterBase(pbjFile:Class, PARAMETERS:Array = null) | ||
{ | ||
shader = new Shader(new pbjFile() as ByteArray); | ||
shaderFilter = new ShaderFilter(shader); | ||
|
||
if (PARAMETERS) Utils.autoDetectKernelParams(shader, PARAMETERS, shaderParams); | ||
|
||
super(); | ||
} | ||
|
||
// PUBLIC METHODS ///////////////////////////////////////////////////////////////////// | ||
|
||
public function updateShaderParams(PARAMETERS:Array):void | ||
{ | ||
// TODO go through all the shadeParams and update the shader according to the PARAMETERS | ||
} | ||
|
||
// PRIVATE METHODS //////////////////////////////////////////////////////////////////// | ||
// EVENT HANDLERS ///////////////////////////////////////////////////////////////////// | ||
// GETTERS & SETTERS ////////////////////////////////////////////////////////////////// | ||
// HELPERS //////////////////////////////////////////////////////////////////////////// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
[AS3] FilterName | ||
======================================================================================= | ||
HiSlope toolkit copyright (c) 2010 Tomek 'Og2t' Augustyn | ||
http://play.blog2t.net/hislope | ||
You are free to use this source code in any non-commercial project. | ||
You are free to modify this source code in anyway you see fit. | ||
You are free to distribute this source code. | ||
You may NOT charge anything for this source code. | ||
This notice and the copyright information must be left intact in any distribution of this source code. | ||
You are encouraged to release any improvements back to the ActionScript community. | ||
VERSION HISTORY: | ||
v0.1 Born on 09/07/2009 | ||
USAGE: | ||
TODOs: | ||
DEV IDEAS: | ||
KNOWN ISSUES: | ||
---------------------------------------------------------------------------------------------*/ | ||
|
||
package hislope.filters.pixelbender // filter path | ||
{ | ||
// IMPORTS //////////////////////////////////////////////////////////////////////////////// | ||
|
||
import hislope.display.MetaBitmapData; | ||
import hislope.filters.PBFilterBase; | ||
|
||
// CLASS ////////////////////////////////////////////////////////////////////////////////// | ||
|
||
public class FilterName extends PBFilterBase | ||
{ | ||
// CONSTANTS ////////////////////////////////////////////////////////////////////////// | ||
|
||
private static const NAME:String = "Filter Name"; | ||
private static var PARAMETERS:Array = [ | ||
{ | ||
name: "param1", | ||
label: "param 1", | ||
current: 0.1, | ||
min: 0, | ||
max: 1, | ||
type: "number" | ||
}, { | ||
name: "param2", | ||
label: "param 2", | ||
current: 1, | ||
min: 0, | ||
max: 255, | ||
type: "int" | ||
} | ||
]; | ||
|
||
private static const DEBUG_VARS:Array = [ | ||
"time", | ||
"frames" | ||
]; | ||
|
||
[Embed("../../pbj/Levels.pbj", mimeType="application/octet-stream")] | ||
private const pbjFile:Class; | ||
|
||
// MEMBERS //////////////////////////////////////////////////////////////////////////// | ||
|
||
public var time:Number; | ||
public var frames:Number; | ||
|
||
// PARAMETERS ///////////////////////////////////////////////////////////////////////// | ||
|
||
public var param1:Number; | ||
public var param2:int; | ||
|
||
// CONSTRUCTOR //////////////////////////////////////////////////////////////////////// | ||
|
||
public function FilterName(OVERRIDE:Object = null) | ||
{ | ||
super(pbjFile, PARAMETERS); | ||
// init your bitmaps, variables, etc. here | ||
|
||
time = 0; | ||
frames = 0; | ||
|
||
init(NAME, PARAMETERS, OVERRIDE, DEBUG_VARS); | ||
} | ||
|
||
// PUBLIC METHODS ///////////////////////////////////////////////////////////////////// | ||
|
||
override public function process(metaBmpData:MetaBitmapData):void | ||
{ | ||
// do operations | ||
|
||
time += param1; | ||
frames += param2; | ||
|
||
metaBmpData.applyShader(shaderFilter); | ||
|
||
getPreviewFor(metaBmpData); | ||
} | ||
|
||
override public function updateParams():void | ||
{ | ||
// update parameters if changed | ||
|
||
shader.data.time.value = [time]; | ||
shader.data.frames.value = [frames]; | ||
} | ||
|
||
// PRIVATE METHODS //////////////////////////////////////////////////////////////////// | ||
} | ||
} |