PageRenderTime 54ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/v0.8.0/Test_Red2D_V0.8.0/src/filter_ex/Test01_UseFilters.as

http://red2d-agal2d.googlecode.com/
ActionScript | 283 lines | 202 code | 39 blank | 42 comment | 40 complexity | 5a9dc664182a8cc13154a7b1e7ef6b9e MD5 | raw file
  1. package filter_ex
  2. {
  3. /**
  4. * by Paik seonki / redcamel
  5. * webseon@hanmail.net
  6. */
  7. import com.bit101.components.HUISlider;
  8. import com.bit101.components.Label;
  9. import com.bit101.components.RadioButton;
  10. import com.bit101.components.Style;
  11. import flash.display.Sprite;
  12. import flash.events.Event;
  13. import red2D.display.Red_Sprite;
  14. import red2D.filter.fragmentBasic.BlackAndWhite;
  15. import red2D.filter.fragmentBasic.BrightFilter;
  16. import red2D.filter.fragmentBasic.EmbossFilter;
  17. import red2D.filter.fragmentBasic.InvertFilter;
  18. import red2D.filter.fragmentBasic.LightLevelFilter;
  19. import red2D.filter.fragmentBasic.MonoFilter;
  20. import red2D.filter.fragmentBasic.NeonSign;
  21. import red2D.filter.fragmentBasic.NightVisionFilter;
  22. import red2D.filter.fragmentUV.UV_OffsetFilter;
  23. import red2D.filter.fragmentUV.UV_TileFilter;
  24. import red2D.filter.fragmentUV.UV_Wave;
  25. import red2D.filter.fragmentUV.UV_ZoomFilter;
  26. import red2D.material.BitmapMaterial;
  27. import red2D.system.Red_Scene;
  28. /**
  29. * Test11_UseFilter
  30. * <p>Last update - Oct 28, 2011</p>
  31. * @author ???(seon ki, paik) http://redcamel-studio.tistory.com
  32. * @langversion ActionScript 3.0
  33. * @playerversion Flash 11
  34. * @playerversion AIR 3.0
  35. */
  36. public class Test01_UseFilters extends Red_Scene
  37. {
  38. // ?? ???? ?? ???
  39. [Embed( source = "./resource/img.jpg" )]
  40. private var MapTest:Class;
  41. private var _target:Red_Sprite;
  42. private var _normal:RadioButton;
  43. private var _mono:RadioButton;
  44. private var _invert:RadioButton;
  45. private var _nightvision:RadioButton;
  46. private var _neonSign:RadioButton;
  47. // ?? ??? ?????
  48. private var _currentRadio:RadioButton = _normal
  49. private var _lightLevel:RadioButton;
  50. private var _lightLevelStrength:HUISlider
  51. private var _brightLevel:RadioButton;
  52. private var _brightLevelStrength:HUISlider;
  53. private var _rStrength:HUISlider;
  54. private var _gStrength:HUISlider;
  55. private var _bStrength:Object;
  56. private var _uvZoom:RadioButton;
  57. private var _uvZoomCenterX:HUISlider;
  58. private var _uvZoomCenterY:Object;
  59. private var _uvZoomStrength:HUISlider;
  60. private var _uvTile:RadioButton;
  61. private var _tileScale:HUISlider;
  62. private var _uvOffset:RadioButton;
  63. private var _uvOffsetX:HUISlider;
  64. private var _uvOffsetY:HUISlider;
  65. private var _emboss:RadioButton;
  66. private var _embossValue:HUISlider;
  67. private var _blackAndWhite:RadioButton;
  68. private var _blackAndWhiteValue:Object;
  69. private var _waveValue:HUISlider;
  70. private var _wave:RadioButton;
  71. private var _waveValue2:HUISlider;
  72. private var _underWaterValue2:Object;
  73. private var _underWaterValue:Object;
  74. private var _underWater:RadioButton;
  75. public function Test01_UseFilters()
  76. {
  77. //TODO ??????
  78. }
  79. /**
  80. * Red_Scene? ???? setDesign? ??????? ??? ?????.
  81. *
  82. */
  83. public override function setDesign():void
  84. {
  85. var testMaterial:BitmapMaterial = new BitmapMaterial(new MapTest().bitmapData)
  86. _target = new Red_Sprite(1920,1200,stage.stageWidth/2,stage.stageHeight/2)
  87. _target.material = testMaterial
  88. addChild(_target)
  89. setSimpelGUI()
  90. }
  91. /**
  92. * Red_SceneV0.8 ??? ? updatea? ?????? ??? ??????.
  93. * ??? stage? ????? ???? ?? ??? ??? ??? ???????.
  94. * update???? ??????? ??? ??????? ???? ???? ??? ? ????.
  95. *
  96. */
  97. public override function update():void
  98. {
  99. }
  100. /**
  101. ***************************************************************************************************
  102. ***************************************************************************************************
  103. */
  104. private function setSimpelGUI():void{
  105. var gui:Sprite = new Sprite
  106. gui.graphics.beginFill(0x000000)
  107. gui.graphics.drawRect(10,10,200,1000)
  108. gui.graphics.endFill()
  109. stage.addChild(gui)
  110. gui.x=0
  111. gui.y=0
  112. Style.setStyle(Style.DARK)
  113. var defaultHeight:Number = 20
  114. var defaultY:Number = 50
  115. var guiTitle:Label = new Label(gui,20,15,"Red2D Test\nTest Filter ")
  116. _normal = new RadioButton(gui, 20, defaultHeight*0+defaultY, "normal Filter", true, changeFilter)
  117. _mono = new RadioButton(gui, 20, defaultHeight*1+defaultY, "mono Filter", false, changeFilter)
  118. _invert = new RadioButton(gui, 20, defaultHeight*2+defaultY, "invert Filter", false, changeFilter)
  119. _nightvision = new RadioButton(gui, 20, defaultHeight*3+defaultY, "nightvision Filter", false, changeFilter)
  120. _lightLevel = new RadioButton(gui, 20, defaultHeight*4.5+defaultY, "lightLevel Filter", false, changeFilter)
  121. _lightLevelStrength = new HUISlider(gui, 20,defaultHeight*5+defaultY, "Strength",HD_value)
  122. _lightLevelStrength.width=200
  123. _lightLevelStrength.setSliderParams(0,10,2.5)
  124. _brightLevel = new RadioButton(gui, 20, defaultHeight*6.5+defaultY, "brightLevel Filter", false, changeFilter)
  125. _brightLevelStrength = new HUISlider(gui, 20,defaultHeight*7+defaultY, "Strength",HD_value)
  126. _brightLevelStrength.width=200
  127. _brightLevelStrength.setSliderParams(0,2,0.3)
  128. _neonSign = new RadioButton(gui, 20, defaultHeight*8.5+defaultY, "neonSign Filter", false, changeFilter)
  129. _rStrength = new HUISlider(gui, 20,defaultHeight*9+defaultY, "r",HD_value)
  130. _rStrength.width=200
  131. _rStrength.setSliderParams(0,1,0.3)
  132. _gStrength = new HUISlider(gui, 20,defaultHeight*9.5+defaultY, "g",HD_value)
  133. _gStrength.width=200
  134. _gStrength.setSliderParams(0,1,0.3)
  135. _bStrength = new HUISlider(gui, 20,defaultHeight*10+defaultY, "b",HD_value)
  136. _bStrength.width=200
  137. _bStrength.setSliderParams(0,1,0.3)
  138. _uvZoom = new RadioButton(gui, 20, defaultHeight*11.5+defaultY, "uvZoom Filter", false, changeFilter)
  139. _uvZoomCenterX = new HUISlider(gui, 20,defaultHeight*12+defaultY, "centerX",HD_value)
  140. _uvZoomCenterX.width=200
  141. _uvZoomCenterX.setSliderParams(0,1,0.3)
  142. _uvZoomCenterY = new HUISlider(gui, 20,defaultHeight*12.5+defaultY, "centerY",HD_value)
  143. _uvZoomCenterY.width=200
  144. _uvZoomCenterY.setSliderParams(0,1,0.3)
  145. _uvZoomStrength = new HUISlider(gui, 20,defaultHeight*13+defaultY, "zoomScale",HD_value)
  146. _uvZoomStrength.width=200
  147. _uvZoomStrength.setSliderParams(0,1,0.3)
  148. _uvTile = new RadioButton(gui, 20, defaultHeight*14.5+defaultY, "uvTile Filter", false, changeFilter)
  149. _tileScale = new HUISlider(gui, 20,defaultHeight*15+defaultY, "scale",HD_value)
  150. _tileScale.width=200
  151. _tileScale.setSliderParams(0,1,0.3)
  152. new Label(gui, 20, defaultHeight*15.5+defaultY, "tileFilter is Very Heavy!")
  153. _uvOffset = new RadioButton(gui, 20, defaultHeight*17+defaultY, "uvOffset Filter", false, changeFilter)
  154. _uvOffsetX = new HUISlider(gui, 20,defaultHeight*17.5+defaultY, "x",HD_value)
  155. _uvOffsetX.width=200
  156. _uvOffsetX.setSliderParams(0,1,0)
  157. _uvOffsetY = new HUISlider(gui, 20,defaultHeight*18+defaultY, "y",HD_value)
  158. _uvOffsetY.width=200
  159. _uvOffsetY.setSliderParams(0,1,0)
  160. _emboss = new RadioButton(gui, 20, defaultHeight*20+defaultY, "emboss Filter", false, changeFilter)
  161. _embossValue = new HUISlider(gui, 20,defaultHeight*20.5+defaultY, "value",HD_value)
  162. _embossValue.width=200
  163. _embossValue.setSliderParams(-2,2,0.5)
  164. _blackAndWhite = new RadioButton(gui, 20, defaultHeight*22+defaultY, "BlackAndWhite Filter", false, changeFilter)
  165. _blackAndWhiteValue = new HUISlider(gui, 20,defaultHeight*22.5+defaultY, "value",HD_value)
  166. _blackAndWhiteValue.width=200
  167. _blackAndWhiteValue.setSliderParams(0,1,0.5)
  168. _wave = new RadioButton(gui, 20, defaultHeight*24+defaultY, "wave Filter", false, changeFilter)
  169. _waveValue = new HUISlider(gui, 20,defaultHeight*24.5+defaultY, "waveLength",HD_value)
  170. _waveValue.width=200
  171. _waveValue.labelPrecision=2
  172. _waveValue.setSliderParams(0,360,1)
  173. _waveValue2 = new HUISlider(gui, 20,defaultHeight*25+defaultY, "$amplitude",HD_value)
  174. _waveValue2.width=200
  175. _waveValue2.labelPrecision=2
  176. _waveValue2.setSliderParams(0,100,1)
  177. }
  178. private function HD_value($e:Event=null):void
  179. {
  180. changeFilter()
  181. }
  182. private function changeFilter(e:Event = null):void
  183. {
  184. if(e!=null){
  185. _currentRadio = e.target as RadioButton
  186. }
  187. for(var i:int=0; i<childNum; ++i){
  188. var target:Red_Sprite = _target
  189. if (_currentRadio == _normal) {
  190. //??? ???????? ??? ? ??? ?????.(null?? ???? ????, ????? ???? ????????.)
  191. target.filters = []
  192. }
  193. else if (_currentRadio == _mono) {
  194. //??? ????? filters ??? ???? ??? ??? ??? ??????.(?? API??? ?????)
  195. target.filters = [new MonoFilter]
  196. }
  197. else if (_currentRadio == _invert) {
  198. // ????
  199. target.filters = [new InvertFilter]
  200. }
  201. else if (_currentRadio == _nightvision) {
  202. // ?????? ?????.
  203. target.filters = [new NightVisionFilter]
  204. }
  205. else if (_currentRadio == _lightLevel) {
  206. // ????????
  207. target.filters = [new LightLevelFilter(_lightLevelStrength.value)]
  208. }
  209. else if (_currentRadio == _brightLevel) {
  210. // ??????
  211. target.filters = [new BrightFilter(_brightLevelStrength.value)]
  212. }
  213. else if (_currentRadio == _neonSign) {
  214. // ????
  215. target.filters = [new NeonSign(_rStrength.value, _gStrength.value, _bStrength.value)]
  216. }
  217. else if (_currentRadio == _uvZoom) {
  218. // UZ???
  219. target.filters = [new UV_ZoomFilter(_uvZoomCenterX.value, _uvZoomCenterY.value, _uvZoomStrength.value)]
  220. }
  221. else if (_currentRadio == _uvTile) {
  222. // ????
  223. target.filters = [new UV_TileFilter(_tileScale.value)]
  224. }
  225. else if (_currentRadio == _uvOffset) {
  226. // uvOffset??
  227. target.filters = [new UV_OffsetFilter(_uvOffsetX.value,_uvOffsetY.value)]
  228. }
  229. else if (_currentRadio == _emboss) {
  230. // _emboss??
  231. target.filters = [new EmbossFilter(_embossValue.value)]
  232. }
  233. else if (_currentRadio == _blackAndWhite) {
  234. // blackAndWhite??
  235. target.filters = [new BlackAndWhite(_blackAndWhiteValue.value)]
  236. }
  237. else if (_currentRadio == _wave) {
  238. // wave??
  239. target.filters = [new UV_Wave(_waveValue.value, _waveValue2.value)]
  240. }
  241. }
  242. }
  243. }
  244. }