├── bin └── README.txt ├── assets ├── haxeui.png ├── img │ ├── control-090.png │ └── control-270.png ├── fonts │ ├── Roboto-Regular.eot │ ├── Roboto-Regular.ttf │ ├── Roboto-Regular.woff │ └── Roboto-Regular.woff2 ├── styles │ └── default │ │ └── main.css ├── css │ ├── dark.min.css │ ├── ui.min.css │ ├── dark.css │ └── ui.css ├── shader │ └── lyapunov.frag └── ui │ └── ui.xml ├── .gitignore ├── haxeui2-fractalgenerator.jpg ├── src ├── module.xml ├── MathUtils.hx ├── UI.hx └── Main.hx ├── README.md ├── LICENSE ├── application.xml └── haxe-shaderfun.hxproj /bin/README.txt: -------------------------------------------------------------------------------- 1 | haxe build directory -------------------------------------------------------------------------------- /assets/haxeui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maitag/haxe-shaderfun/HEAD/assets/haxeui.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/html5/ 2 | bin/windows/ 3 | bin/android/ 4 | bin/linux/ 5 | bin/flash/ 6 | .build 7 | -------------------------------------------------------------------------------- /assets/img/control-090.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maitag/haxe-shaderfun/HEAD/assets/img/control-090.png -------------------------------------------------------------------------------- /assets/img/control-270.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maitag/haxe-shaderfun/HEAD/assets/img/control-270.png -------------------------------------------------------------------------------- /haxeui2-fractalgenerator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maitag/haxe-shaderfun/HEAD/haxeui2-fractalgenerator.jpg -------------------------------------------------------------------------------- /assets/fonts/Roboto-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maitag/haxe-shaderfun/HEAD/assets/fonts/Roboto-Regular.eot -------------------------------------------------------------------------------- /assets/fonts/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maitag/haxe-shaderfun/HEAD/assets/fonts/Roboto-Regular.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maitag/haxe-shaderfun/HEAD/assets/fonts/Roboto-Regular.woff -------------------------------------------------------------------------------- /assets/fonts/Roboto-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maitag/haxe-shaderfun/HEAD/assets/fonts/Roboto-Regular.woff2 -------------------------------------------------------------------------------- /src/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/MathUtils.hx: -------------------------------------------------------------------------------- 1 | package; 2 | 3 | class MathUtils { 4 | public static function round(number:Float, precision:Int):Float { 5 | var num = number; 6 | num = num * Math.pow(10, precision); 7 | num = Math.round( num ) / Math.pow(10, precision); 8 | return num; 9 | } 10 | } -------------------------------------------------------------------------------- /assets/styles/default/main.css: -------------------------------------------------------------------------------- 1 | .label, .textfield { 2 | /*font-name: "fonts/Roboto-Regular.ttf";*/ 3 | font-name: "_sans"; 4 | font-size: 13px; 5 | } 6 | 7 | .flash .label, .flash .textfield { 8 | font-name: "_sans"; 9 | } 10 | 11 | .scrollview { 12 | padding: 1px; 13 | padding-bottom: 2px; 14 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # haxe-shaderfun 2 | 3 | 4 | [lyapunov fat fractals](https://github.com/maitag/lyapunov-c#lyapunov-c) and [haxeui 2](https://github.com/haxeui/haxeui-openfl#haxeui-openfl) 5 | 6 | [click here to explore fractal set](http://maitag.de/semmi/haxeopenfl/haxeui2-fractalgenerator/?AAFDCbIBvgIrAjUCvcv/FDB34XJ0fv6HxTy/38OamZk/) 7 | 8 | 9 | [![lyapunow fractal](haxeui2-fractalgenerator.jpg?raw=true)](http://maitag.de/semmi/haxeopenfl/haxeui2-fractalgenerator/?8QBvEMABagK+AnwCTwAWDTi8VX3d5dxYxUGSAEUAAIA/) -------------------------------------------------------------------------------- /assets/css/dark.min.css: -------------------------------------------------------------------------------- 1 | .button{border:1px solid #191C21;background-color:#4B4E53;background-color-end:#37383C;color:#C6C6C8;padding} 2 | .button:hover{border:1px solid #191C21;background-color:#53565B;background-color-end:#3C3D41;color:#C1C2C6;} 3 | .button:down{border:1px solid #1C1D1F;background-color:#2C2D2F;background-color-end:#43484C;color:#A2A3A5;} 4 | .hslider .slider-value-background,.vslider .slider-value-background{border:1px solid #101010;background-color:#353535;background-color-end:#434343;filter:drop-shadow(1,45,#000000,0.5,2,2,1,3,true);padding:1px;} 5 | .hslider .slider-value-background{height:6px;} 6 | .vslider .slider-value-background{width:6px;} 7 | .hslider .slider-button,.vslider .slider-button{border:1px solid #101010;background-color:#E6E6E6;background-color-end:#A0A0A0;} 8 | .hslider .slider-value,.vslider .slider-value{background-color:#FD4653;background-color-end:#AC282F;} 9 | 10 | -------------------------------------------------------------------------------- /assets/css/ui.min.css: -------------------------------------------------------------------------------- 1 | .label{color:#000000;vertical-align:center;} 2 | .hbox{width:100%;padding:0;} 3 | .vbox{padding:0;} 4 | #main{background-color:#707070;padding:10px;padding-left:14px;padding-bottom:14px;border:1px solid #222222;} 5 | .header{font-size:18px;color:#D0D0D0;vertical-align:center;} 6 | .header-small{font-size:11px;color:#C0C0C0;padding-bottom:10px;} 7 | .formula{width:100%;} 8 | .left{width:28%;} 9 | .middle{width:58%;} 10 | .right{width:14%;} 11 | .random-button{width:100%;} 12 | .col-label{horizontal-align:center;} 13 | .red .slider-value{background-color:#702211;background-color-end:#602211;} 14 | .green .slider-value{background-color:#1a661a;background-color-end:#1a551a;} 15 | .blue .slider-value{background-color:#223388;background-color-end:#223377;} 16 | .button{color:#C0C0C2;font-size:15px;} 17 | .hslider .slider-value-background{height:8px;} 18 | .vslider .slider-value-background{width:8px;} 19 | .hslider .slider-value{background-color:#AAAAAA;background-color-end:#888888;} 20 | 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Sylvio Sell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /application.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /assets/css/dark.css: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | ** BUTTON 3 | *************************************************************************/ 4 | .button { 5 | border: 1px solid #191C21; 6 | background-color: #4B4E53; 7 | background-color-end: #37383C; 8 | color: #C6C6C8; 9 | padding 10 | } 11 | 12 | .button:hover { 13 | border: 1px solid #191C21; 14 | background-color: #53565B; 15 | background-color-end: #3C3D41; 16 | color: #C1C2C6; 17 | } 18 | 19 | .button:down { 20 | border: 1px solid #1C1D1F; 21 | background-color: #2C2D2F; 22 | background-color-end: #43484C; 23 | color: #A2A3A5; 24 | } 25 | 26 | /************************************************************************ 27 | ** HSLIDER / VSLIDER 28 | *************************************************************************/ 29 | .hslider .slider-value-background, .vslider .slider-value-background { 30 | border: 1px solid #101010; 31 | background-color: #353535; 32 | background-color-end: #434343; 33 | filter: drop-shadow(1, 45, #000000, 0.5, 2, 2, 1, 3, true); 34 | padding: 1px; 35 | } 36 | 37 | .hslider .slider-value-background { 38 | height: 6px; 39 | } 40 | 41 | .vslider .slider-value-background { 42 | width: 6px; 43 | } 44 | 45 | .hslider .slider-button, .vslider .slider-button { 46 | border: 1px solid #101010; 47 | background-color: #E6E6E6; 48 | background-color-end: #A0A0A0; 49 | } 50 | 51 | .hslider .slider-value, .vslider .slider-value { 52 | background-color: #FD4653; 53 | background-color-end: #AC282F; 54 | } 55 | -------------------------------------------------------------------------------- /assets/css/ui.css: -------------------------------------------------------------------------------- 1 | .label { 2 | color: #000000; 3 | vertical-align: center; 4 | } 5 | 6 | .hbox { 7 | width: 100%; 8 | padding:0; 9 | } 10 | 11 | .vbox { 12 | padding:0; 13 | } 14 | 15 | #main { 16 | background-color: #707070; 17 | padding: 10px; 18 | padding-left: 14px; 19 | padding-bottom: 14px; 20 | border: 1px solid #222222; 21 | } 22 | 23 | /* --- header labels ----------------- */ 24 | .header { 25 | font-size: 18px; 26 | color: #D0D0D0; 27 | vertical-align: center; 28 | } 29 | 30 | .header-small { 31 | font-size: 11px; 32 | color: #C0C0C0; 33 | padding-bottom: 10px; 34 | } 35 | 36 | 37 | /* --- textfield for formula --- */ 38 | .formula { 39 | width: 100%; 40 | } 41 | 42 | /* --- columns for upper parameters --- */ 43 | 44 | .left { 45 | width: 28%; 46 | } 47 | 48 | .middle { 49 | width: 58%; 50 | } 51 | 52 | .right { 53 | width: 14%; 54 | } 55 | 56 | 57 | /* -------- random button ------------ */ 58 | .random-button { 59 | width: 100%; 60 | } 61 | 62 | 63 | /* -------- color labels ------------- */ 64 | .col-label { 65 | horizontal-align: center; 66 | } 67 | 68 | 69 | /* -------- colored sliders ---------- */ 70 | .red .slider-value { 71 | background-color: #702211; 72 | background-color-end: #602211; 73 | } 74 | 75 | .green .slider-value { 76 | background-color: #1a661a; 77 | background-color-end: #1a551a; 78 | } 79 | 80 | .blue .slider-value { 81 | background-color: #223388; 82 | background-color-end: #223377; 83 | } 84 | 85 | 86 | /* --- overwriting dark.css theme --- */ 87 | .button { 88 | color: #C0C0C2; 89 | font-size: 15px; 90 | } 91 | 92 | .hslider .slider-value-background { 93 | height: 8px; 94 | } 95 | 96 | .vslider .slider-value-background { 97 | width: 8px; 98 | } 99 | 100 | .hslider .slider-value { 101 | background-color: #AAAAAA; 102 | background-color-end: #888888; 103 | } 104 | 105 | -------------------------------------------------------------------------------- /haxe-shaderfun.hxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | "$(CompilerPath)/haxelib" run lime build "$(OutputFile)" $(TargetBuild) -$(BuildConfig) -Dfdb 42 | 43 | 44 | 45 | 46 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /assets/shader/lyapunov.frag: -------------------------------------------------------------------------------- 1 | /* 2 | ############################################################################### 3 | # Author: Sylvio Sell - maitag - Rostock 2013 # 4 | # Homepage: http://maitag.de # 5 | # License: GNU General Public License (GPL), Version 2.0 # 6 | # # 7 | # more images about that lyapunov fractalcode at: # 8 | # http://maitag.de/~semmi/ # 9 | # (have fun!;) # 10 | ############################################################################### */ 11 | 12 | varying vec2 vTexCoord; 13 | uniform vec2 uMouse, uResolution, uScale, uPosition; 14 | uniform vec2 uIteration, uParam; 15 | uniform float uStart; 16 | uniform float uBalance; 17 | uniform vec3 uColpos; 18 | uniform vec3 uColneg; 19 | uniform vec3 uColmid; 20 | uniform int uColtype; 21 | 22 | float func(float x, float y, float a, float b) 23 | { 24 | //return a*sin(x+y)*sin(x+y)+b; 25 | return #FORMULA; 26 | } 27 | 28 | float deriv(float x, float y, float a, float b) 29 | { 30 | //return a*sin(2.0*(x+y)); 31 | return #DERIVATE; 32 | } 33 | 34 | void pre_step(inout float x, vec2 p, float p1, float p2) 35 | { 36 | x = func(x,p.x,p1,p2); 37 | x = func(x,p.y,p1,p2); 38 | } 39 | 40 | void main_step(inout float index, inout int iter, inout float x, vec2 p, float p1, float p2, float balance) 41 | { 42 | x = func(x,p.x,p1,p2); 43 | index += ( log(abs(deriv(x,p.x,p1,p2)))*balance + deriv(x,p.x,p1,p2)*(1.0-balance) ) / 2.0; 44 | x = func(x,p.y,p1,p2); 45 | index += ( log(abs(deriv(x,p.y,p1,p2)))*balance + deriv(x,p.y,p1,p2)*(1.0-balance) ) / 2.0; 46 | iter = iter + 2; 47 | } 48 | 49 | void main( void ) { 50 | 51 | // Parameter 52 | float x = uStart; 53 | vec2 p = (vTexCoord - uPosition) / uScale; 54 | float p1 = uParam.x; 55 | float p2 = uParam.y; 56 | int iter_pre = int(floor(uIteration.x)); 57 | int iter_main = int(floor(uIteration.y)); 58 | float nabla_pre = uIteration.x - float(iter_pre); 59 | float nabla_main = uIteration.y - float(iter_main); 60 | 61 | float index = 0.0; 62 | int iter = 0; 63 | 64 | // pre-iteration ########################## 65 | 66 | for (int i = 0; i < 21; i++) { 67 | if (i < iter_pre) 68 | { 69 | pre_step(x, p, p1, p2); 70 | } 71 | } 72 | if (nabla_pre != 0.0) { 73 | float x_pre = x; 74 | pre_step(x, p, p1, p2); 75 | x = x*nabla_pre + x_pre*(1.0-nabla_pre); 76 | } 77 | 78 | // main-iteration ######################## 79 | 80 | for (int i = 0; i < 201; i++) { 81 | if (i < iter_main) 82 | { 83 | main_step(index, iter, x, p, p1, p2, uBalance); 84 | } 85 | } 86 | 87 | if (nabla_main == 0.0) { 88 | index = (iter != 0) ? index/float(iter) : 0.0; 89 | } 90 | else { 91 | float index_pre = (iter != 0) ? index/float(iter) : 0.0; 92 | 93 | main_step(index, iter, x, p, p1, p2, uBalance); 94 | 95 | index = (iter != 0) ? index/float(iter) : 0.0; 96 | index = index*nabla_main + index_pre*(1.0-nabla_main); 97 | } 98 | 99 | if (index > 0.0 && (uColtype==0 || uColtype==1)) { 100 | gl_FragColor = vec4(index*(uColpos-uColmid)+uColmid, 1.0); 101 | } 102 | else if (index < 0.0 && (uColtype==0 || uColtype==2)) { 103 | gl_FragColor = vec4(index*(uColmid-uColneg)+uColmid, 1.0); 104 | } 105 | else { 106 | gl_FragColor = vec4(uColmid, 1.0); 107 | } 108 | } 109 | 110 | -------------------------------------------------------------------------------- /src/UI.hx: -------------------------------------------------------------------------------- 1 | package; 2 | 3 | import haxe.io.BytesInput; 4 | import haxe.io.BytesOutput; 5 | import haxe.ui.core.Component; 6 | import haxe.ui.core.MouseEvent; 7 | import haxe.ui.core.UIEvent; 8 | 9 | @:build(haxe.ui.macros.ComponentMacros.build("assets/ui/ui.xml")) 10 | class UI extends Component { 11 | 12 | public function new() { 13 | super(); 14 | 15 | registerEvent(MouseEvent.MOUSE_DOWN, function(e:MouseEvent) { Main.uiIsdragging = true; }); 16 | registerEvent(MouseEvent.MOUSE_UP , function(e:MouseEvent) { Main.dragmode = Main.uiIsdragging = false; }); 17 | 18 | for (i in [iteration0, iteration1, param0, param1, start, balance, r1, g1, b1, r2, g2, b2, r3, g3, b3]) 19 | i.registerEvent(MouseEvent.MOUSE_UP , updateChanges); 20 | 21 | iteration0.userData = [Main.iteration,0]; 22 | iteration1.userData = [Main.iteration,1]; 23 | param0.userData = [Main.param,0]; 24 | param1.userData = [Main.param,1]; 25 | start.userData = [Main.start,0]; 26 | balance.userData= [Main.balance,0]; 27 | r1.userData = [Main.colpos,0]; 28 | g1.userData = [Main.colpos,1]; 29 | b1.userData = [Main.colpos,2]; 30 | r2.userData = [Main.colmid,0]; 31 | g2.userData = [Main.colmid,1]; 32 | b2.userData = [Main.colmid,2]; 33 | r3.userData = [Main.colneg,0]; 34 | g3.userData = [Main.colneg,1]; 35 | b3.userData = [Main.colneg,2]; 36 | 37 | // TODO 38 | changeFormula.onClick = function(e:UIEvent) { Main.updateFormula(formula.text); }; 39 | 40 | iteration0.onChange = updateValue; 41 | iteration1.onChange = updateValue; 42 | param0.onChange = updateValue; 43 | param1.onChange = updateValue; 44 | start.onChange = updateValue; 45 | balance.onChange= updateValue; 46 | r1.onChange = updateValue; 47 | g1.onChange = updateValue; 48 | b1.onChange = updateValue; 49 | r2.onChange = updateValue; 50 | g2.onChange = updateValue; 51 | b2.onChange = updateValue; 52 | r3.onChange = updateValue; 53 | g3.onChange = updateValue; 54 | b3.onChange = updateValue; 55 | 56 | randomParam.onClick = updateChanges; 57 | randomColor.onClick = updateChanges; 58 | } 59 | 60 | private function updateChanges(e:UIEvent) { 61 | if (Main.changed) { 62 | Main.changed = false; 63 | Main.updateUrlParams(); 64 | } 65 | } 66 | 67 | private function updateValue(e:UIEvent) { 68 | e.target.userData[0][e.target.userData[1]] = e.target.value.toFloat() / 255; 69 | Main.changed = true; 70 | } 71 | 72 | public function updateAll() { 73 | for (i in [iteration0, iteration1, param0, param1, start, balance, r1, g1, b1, r2, g2, b2, r3, g3, b3]) 74 | i.userData[0][i.userData[1]] = i.value.toFloat() / 255; 75 | } 76 | 77 | public function serializeParams():BytesOutput 78 | { 79 | var b = new BytesOutput(); 80 | b.writeInt16(iteration0.value); 81 | b.writeInt16(iteration1.value); 82 | b.writeInt16(param0.value); 83 | b.writeInt16(param1.value); 84 | b.writeInt16(start.value); 85 | b.writeInt16(balance.value); 86 | b.writeByte(r1.value); 87 | b.writeByte(g1.value); 88 | b.writeByte(b1.value); 89 | b.writeByte(r2.value); 90 | b.writeByte(g2.value); 91 | b.writeByte(b2.value); 92 | b.writeByte(r3.value); 93 | b.writeByte(g3.value); 94 | b.writeByte(b3.value); 95 | return(b); 96 | } 97 | 98 | public function unSerializeParams(b:BytesInput) 99 | { 100 | iteration0.value = b.readInt16(); 101 | iteration1.value = b.readInt16(); 102 | param0.value = b.readInt16(); 103 | param1.value = b.readInt16(); 104 | start.value = b.readInt16(); 105 | balance.value = b.readInt16(); 106 | r1.value = b.readByte(); 107 | g1.value = b.readByte(); 108 | b1.value = b.readByte(); 109 | r2.value = b.readByte(); 110 | g2.value = b.readByte(); 111 | b2.value = b.readByte(); 112 | r3.value = b.readByte(); 113 | g3.value = b.readByte(); 114 | b3.value = b.readByte(); 115 | } 116 | 117 | 118 | } -------------------------------------------------------------------------------- /assets/ui/ui.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |