├── .gitignore
├── 3rd
├── colorPicker.js
├── colors.js
├── custom-theme
│ ├── images
│ │ ├── ui-bg_flat_0_aaaaaa_40x100.png
│ │ ├── ui-bg_flat_15_777777_40x100.png
│ │ ├── ui-bg_flat_16_151515_40x100.png
│ │ ├── ui-bg_glass_95_fef1ec_1x400.png
│ │ ├── ui-bg_highlight-hard_55_555555_1x100.png
│ │ ├── ui-bg_highlight-soft_35_adadad_1x100.png
│ │ ├── ui-bg_highlight-soft_60_dddddd_1x100.png
│ │ ├── ui-bg_inset-soft_15_121212_1x100.png
│ │ ├── ui-icons_666666_256x240.png
│ │ ├── ui-icons_aaaaaa_256x240.png
│ │ ├── ui-icons_bbbbbb_256x240.png
│ │ ├── ui-icons_c98000_256x240.png
│ │ ├── ui-icons_cccccc_256x240.png
│ │ ├── ui-icons_cd0a0a_256x240.png
│ │ └── ui-icons_f29a00_256x240.png
│ └── jquery-ui-1.8.16.custom.css
├── dat.gui.js
├── download.png
├── images
│ ├── ui-bg_diagonals-thick_18_b81900_40x40.png
│ ├── ui-bg_diagonals-thick_20_666666_40x40.png
│ ├── ui-bg_flat_10_000000_40x100.png
│ ├── ui-bg_glass_100_f6f6f6_1x400.png
│ ├── ui-bg_glass_100_fdf5ce_1x400.png
│ ├── ui-bg_glass_65_ffffff_1x400.png
│ ├── ui-bg_gloss-wave_35_f6a828_500x100.png
│ ├── ui-bg_highlight-soft_100_eeeeee_1x100.png
│ ├── ui-bg_highlight-soft_75_ffe45c_1x100.png
│ ├── ui-icons_222222_256x240.png
│ ├── ui-icons_228ef1_256x240.png
│ ├── ui-icons_ef8c08_256x240.png
│ ├── ui-icons_ffd27a_256x240.png
│ └── ui-icons_ffffff_256x240.png
├── jqColorPicker.js
├── jquery-1.11.2.min.js
├── jquery-1.6.2.min.js
├── jquery-ui-1.8.16.custom.min.js
├── jquery-ui.min.css
├── jquery-ui.min.js
├── jquery.text-overflow.js
├── sam.gui.js
├── three.js
└── three.min.js
├── README.rst
├── convtester
├── bootstrap.min.css
├── d3.v3.min.js
├── index.html
└── justified-nav.css
├── css
├── experiments.css
└── paintflow.css
├── fastmccabe
├── index.html
├── render.js
└── style.css
├── frustratedflockingfluid
├── grayscott.js
├── grayscott.png
└── index.html
├── gaussian-smoothlife
├── grayscott.js
└── index.html
├── gradientui
├── gradientui.css
├── gradientui.js
└── index.html
├── grayscott
├── grayscott.js
├── grayscott.png
└── index.html
├── gsimage
├── grayscott.js
├── index.html
├── lena.js
└── lena512.jpg
├── index.html
├── massspring
├── index.html
├── particles.js
├── particles.png
└── scenes.js
├── opticalflowtest
├── clicktopaint.png
├── index.html
└── opticalflow.js
├── paintflow
├── index.html
└── paintflow.js
├── paintflow2
├── clicktopaint.png
├── index.html
└── paintflow.js
├── softmaxdenoise
├── index.html
├── mandrill_noisy.jpg
├── softmax.css
├── softmax.js
├── tetons.jpg
├── tetons.png
├── tetons2.jpg
├── tetons2.png
└── tetons3.jpg
├── softmaxdenoisecolor
├── frog.jpg
├── index.html
├── softmax.css
├── softmax.js
└── toucan.jpg
├── waveletsharpen
├── index.html
├── sharpen.js
└── tetons.jpg
└── waveletsharpencolor
├── frog.jpg
├── index.html
└── sharpen.js
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 |
46 | [Dd]ebug/
47 | [Rr]elease/
48 | x64/
49 | build/
50 | [Bb]in/
51 | [Oo]bj/
52 |
53 | # MSTest test Results
54 | [Tt]est[Rr]esult*/
55 | [Bb]uild[Ll]og.*
56 |
57 | *_i.c
58 | *_p.c
59 | *.ilk
60 | *.meta
61 | *.obj
62 | *.pch
63 | *.pdb
64 | *.pgc
65 | *.pgd
66 | *.rsp
67 | *.sbr
68 | *.tlb
69 | *.tli
70 | *.tlh
71 | *.tmp
72 | *.tmp_proj
73 | *.log
74 | *.vspscc
75 | *.vssscc
76 | .builds
77 | *.pidb
78 | *.log
79 | *.scc
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 |
89 | # Visual Studio profiler
90 | *.psess
91 | *.vsp
92 | *.vspx
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 |
101 | # TeamCity is a build add-in
102 | _TeamCity*
103 |
104 | # DotCover is a Code Coverage Tool
105 | *.dotCover
106 |
107 | # NCrunch
108 | *.ncrunch*
109 | .*crunch*.local.xml
110 |
111 | # Installshield output folder
112 | [Ee]xpress/
113 |
114 | # DocProject is a documentation generator add-in
115 | DocProject/buildhelp/
116 | DocProject/Help/*.HxT
117 | DocProject/Help/*.HxC
118 | DocProject/Help/*.hhc
119 | DocProject/Help/*.hhk
120 | DocProject/Help/*.hhp
121 | DocProject/Help/Html2
122 | DocProject/Help/html
123 |
124 | # Click-Once directory
125 | publish/
126 |
127 | # Publish Web Output
128 | *.Publish.xml
129 | *.pubxml
130 | *.publishproj
131 |
132 | # NuGet Packages Directory
133 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
134 | #packages/
135 |
136 | # Windows Azure Build Output
137 | csx
138 | *.build.csdef
139 |
140 | # Windows Store app package directory
141 | AppPackages/
142 |
143 | # Others
144 | sql/
145 | *.Cache
146 | ClientBin/
147 | [Ss]tyle[Cc]op.*
148 | ~$*
149 | *~
150 | *.dbmdl
151 | *.[Pp]ublish.xml
152 | *.pfx
153 | *.publishsettings
154 |
155 | # RIA/Silverlight projects
156 | Generated_Code/
157 |
158 | # Backup & report files from converting an old project file to a newer
159 | # Visual Studio version. Backup files are not needed, because we have git ;-)
160 | _UpgradeReport_Files/
161 | Backup*/
162 | UpgradeLog*.XML
163 | UpgradeLog*.htm
164 |
165 | # SQL Server files
166 | App_Data/*.mdf
167 | App_Data/*.ldf
168 |
169 | #############
170 | ## Windows detritus
171 | #############
172 |
173 | # Windows image file caches
174 | Thumbs.db
175 | ehthumbs.db
176 |
177 | # Folder config file
178 | Desktop.ini
179 |
180 | # Recycle Bin used on file shares
181 | $RECYCLE.BIN/
182 |
183 | # Mac crap
184 | .DS_Store
185 |
186 |
187 | #############
188 | ## Python
189 | #############
190 |
191 | *.py[cod]
192 |
193 | # Packages
194 | *.egg
195 | *.egg-info
196 | dist/
197 | build/
198 | eggs/
199 | parts/
200 | var/
201 | sdist/
202 | develop-eggs/
203 | .installed.cfg
204 |
205 | # Installer logs
206 | pip-log.txt
207 |
208 | # Unit test / coverage reports
209 | .coverage
210 | .tox
211 |
212 | #Translations
213 | *.mo
214 |
215 | #Mr Developer
216 | .mr.developer.cfg
217 |
218 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion
219 |
220 | *.iml
221 |
222 | ## Directory-based project format:
223 | .idea/
224 |
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-bg_flat_0_aaaaaa_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-bg_flat_0_aaaaaa_40x100.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-bg_flat_15_777777_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-bg_flat_15_777777_40x100.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-bg_flat_16_151515_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-bg_flat_16_151515_40x100.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-bg_glass_95_fef1ec_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-bg_glass_95_fef1ec_1x400.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-bg_highlight-hard_55_555555_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-bg_highlight-hard_55_555555_1x100.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-bg_highlight-soft_35_adadad_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-bg_highlight-soft_35_adadad_1x100.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-bg_highlight-soft_60_dddddd_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-bg_highlight-soft_60_dddddd_1x100.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-bg_inset-soft_15_121212_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-bg_inset-soft_15_121212_1x100.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-icons_666666_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-icons_666666_256x240.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-icons_aaaaaa_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-icons_aaaaaa_256x240.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-icons_bbbbbb_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-icons_bbbbbb_256x240.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-icons_c98000_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-icons_c98000_256x240.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-icons_cccccc_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-icons_cccccc_256x240.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-icons_cd0a0a_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-icons_cd0a0a_256x240.png
--------------------------------------------------------------------------------
/3rd/custom-theme/images/ui-icons_f29a00_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/custom-theme/images/ui-icons_f29a00_256x240.png
--------------------------------------------------------------------------------
/3rd/download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/download.png
--------------------------------------------------------------------------------
/3rd/images/ui-bg_diagonals-thick_18_b81900_40x40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-bg_diagonals-thick_18_b81900_40x40.png
--------------------------------------------------------------------------------
/3rd/images/ui-bg_diagonals-thick_20_666666_40x40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-bg_diagonals-thick_20_666666_40x40.png
--------------------------------------------------------------------------------
/3rd/images/ui-bg_flat_10_000000_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-bg_flat_10_000000_40x100.png
--------------------------------------------------------------------------------
/3rd/images/ui-bg_glass_100_f6f6f6_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-bg_glass_100_f6f6f6_1x400.png
--------------------------------------------------------------------------------
/3rd/images/ui-bg_glass_100_fdf5ce_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-bg_glass_100_fdf5ce_1x400.png
--------------------------------------------------------------------------------
/3rd/images/ui-bg_glass_65_ffffff_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-bg_glass_65_ffffff_1x400.png
--------------------------------------------------------------------------------
/3rd/images/ui-bg_gloss-wave_35_f6a828_500x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-bg_gloss-wave_35_f6a828_500x100.png
--------------------------------------------------------------------------------
/3rd/images/ui-bg_highlight-soft_100_eeeeee_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
--------------------------------------------------------------------------------
/3rd/images/ui-bg_highlight-soft_75_ffe45c_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-bg_highlight-soft_75_ffe45c_1x100.png
--------------------------------------------------------------------------------
/3rd/images/ui-icons_222222_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-icons_222222_256x240.png
--------------------------------------------------------------------------------
/3rd/images/ui-icons_228ef1_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-icons_228ef1_256x240.png
--------------------------------------------------------------------------------
/3rd/images/ui-icons_ef8c08_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-icons_ef8c08_256x240.png
--------------------------------------------------------------------------------
/3rd/images/ui-icons_ffd27a_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-icons_ffd27a_256x240.png
--------------------------------------------------------------------------------
/3rd/images/ui-icons_ffffff_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/3rd/images/ui-icons_ffffff_256x240.png
--------------------------------------------------------------------------------
/3rd/jqColorPicker.js:
--------------------------------------------------------------------------------
1 | ;(function($, Colors, undefined){
2 | 'use strict';
3 |
4 | var $document = $(document),
5 | _instance,
6 | _colorPicker,
7 | _color,
8 | _options,
9 | _selector = '',
10 |
11 | _$trigger,
12 | _$UI, _$xy_slider, _$xy_cursor, _$z_cursor , _$alpha , _$alpha_cursor,
13 |
14 | _pointermove = 'touchmove mousemove pointermove',
15 | _pointerup = 'touchend mouseup pointerup',
16 | _GPU = false,
17 | _animate = window.requestAnimationFrame ||
18 | window.webkitRequestAnimationFrame || function(cb){cb()},
19 | _html = '
').children().eq(0).css('width',
123 | $(this).children().eq(0).width() // stabilizer
124 | );
125 | this._width = this.offsetWidth;
126 | this._height = this.offsetHeight;
127 | }).hide().
128 | on('touchstart mousedown pointerdown',
129 | '.cp-xy-slider,.cp-z-slider,.cp-alpha', pointerdown);
130 | }
131 |
132 | function pointerdown(e) {
133 | var action = this.className.
134 | replace(/cp-(.*?)(?:\s*|$)/, '$1').replace('-', '_');
135 |
136 | e.preventDefault && e.preventDefault();
137 | e.returnValue = false;
138 |
139 | _$trigger._offset = $(this).offset();
140 | (action = action === 'xy_slider' ? xy_slider :
141 | action === 'z_slider' ? z_slider : alpha)(e);
142 |
143 | $document.on(_pointerup, pointerup).on(_pointermove, action);
144 | }
145 |
146 | function pointerup(e) {
147 | $document.off(_pointermove).off(_pointerup);
148 | }
149 |
150 | function xy_slider(event) {
151 | var e = resolveEventType(event),
152 | x = e.pageX - _$trigger._offset.left,
153 | y = e.pageY - _$trigger._offset.top;
154 |
155 | _color.setColor({
156 | s: x / _$xy_slider._width * 100,
157 | v: 100 - (y / _$xy_slider._height * 100)
158 | }, 'hsv');
159 | preRender();
160 | }
161 |
162 | function z_slider(event) {
163 | var z = resolveEventType(event).pageY - _$trigger._offset.top,
164 | hsv = _color.colors.hsv;
165 |
166 | _color.setColor({h: 360 - (z / _$xy_slider._height * 360)}, 'hsv');
167 | preRender();
168 | }
169 |
170 | function alpha(event) {
171 | var x = resolveEventType(event).pageX - _$trigger._offset.left,
172 | alpha = x / _$alpha._width;
173 |
174 | _color.setColor({}, 'rgb', alpha > 1 ? 1 : alpha < 0 ? 0 : alpha);
175 | preRender();
176 | }
177 |
178 | function preRender(toggled) {
179 | var colors = _color.colors,
180 | hueRGB = colors.hueRGB,
181 | RGB = colors.RND.rgb,
182 | HSL = colors.RND.hsl,
183 | dark = '#222',
184 | light = '#ddd',
185 | colorMode = _$trigger.data('colorMode'),
186 | isAlpha = colors.alpha !== 1,
187 | alpha = Math.round(colors.alpha * 100) / 100,
188 | RGBInnerText = RGB.r + ', ' + RGB.g + ', ' + RGB.b,
189 | text = (colorMode === 'HEX' && !isAlpha ? '#' + colors.HEX :
190 | colorMode === 'rgb' || (colorMode === 'HEX' && isAlpha) ?
191 | (!isAlpha ? 'rgb(' + RGBInnerText + ')' :
192 | 'rgba(' + RGBInnerText + ', ' + alpha + ')') :
193 | ('hsl' + (isAlpha ? 'a(' : '(') + HSL.h + ', ' + HSL.s + '%, ' +
194 | HSL.l + '%' + (isAlpha ? ', ' + alpha : '') + ')')),
195 | HUEContrast = colors.HUELuminance > 0.22 ? dark : light,
196 | alphaContrast = colors.rgbaMixBlack.luminance > 0.22 ? dark : light,
197 | h = (1 - colors.hsv.h) * _$xy_slider._height,
198 | s = colors.hsv.s * _$xy_slider._width,
199 | v = (1 - colors.hsv.v) * _$xy_slider._height,
200 | a = alpha * _$alpha._width,
201 | translate3d = _GPU ? 'translate3d' : '';
202 |
203 | _$xy_slider._css = {
204 | backgroundColor: 'rgb(' +
205 | hueRGB.r + ',' + hueRGB.g + ',' + hueRGB.b + ')'};
206 | _$xy_cursor._css = {
207 | transform: translate3d + '(' + s + 'px, ' + v + 'px, 0)',
208 | left: !_GPU ? s : '',
209 | top: !_GPU ? v : '',
210 | borderColor : colors.RGBLuminance > 0.22 ? dark : light
211 | };
212 | _$z_cursor._css = {
213 | transform: translate3d + '(0, ' + h + 'px, 0)',
214 | top: !_GPU ? h : '',
215 | borderColor : 'transparent ' + HUEContrast
216 | };
217 | _$alpha._css = {backgroundColor: 'rgb(' + RGBInnerText + ')'};
218 | _$alpha_cursor._css = {
219 | transform: translate3d + '(' + a + 'px, 0, 0)',
220 | left: !_GPU ? a : '',
221 | borderColor : alphaContrast + ' transparent'
222 | };
223 | _$trigger._css = {
224 | backgroundColor : text,
225 | color: colors.rgbaMixBGMixCustom.luminance > 0.22 ? dark : light
226 | };
227 | _$trigger.text = _$trigger.val() !== text ? text : '';
228 |
229 | toggled !== undefined ? render(toggled) : _animate(render);
230 | }
231 |
232 | // As _animate() is actually requestAnimationFrame(), render() gets called
233 | // decoupled from any pointer action (whenever the browser decides to do
234 | // so) as an event. preRender() is coupled to toggle() and all pointermove
235 | // actions; that's where all the calculations happen. render() can now be
236 | // called without extra calculations which results in faster rendering.
237 | function render(toggled) {
238 | _$xy_slider.css(_$xy_slider._css);
239 | _$xy_cursor.css(_$xy_cursor._css);
240 | _$z_cursor.css(_$z_cursor._css);
241 | _$alpha.css(_$alpha._css);
242 | _$alpha_cursor.css(_$alpha_cursor._css);
243 |
244 | _options.doRender && _$trigger.css(_$trigger._css);
245 | _$trigger.text && _$trigger.val(_$trigger.text);
246 |
247 | _options.renderCallback.call(
248 | _colorPicker,
249 | _$trigger,
250 | typeof toggled === 'boolean' ? toggled : undefined
251 | );
252 | }
253 |
254 | $.fn.colorPicker = function(options) {
255 | var noop = function(){};
256 |
257 | options = $.extend({
258 | animationSpeed: 150,
259 | GPU: true,
260 | doRender: true,
261 | customBG: '#FFF',
262 | opacity: true,
263 | renderCallback: noop,
264 | buidCallback: noop,
265 | body: document.body,
266 | scrollResize: true,
267 | gap: 4
268 | // css: '',
269 | // cssAddon: '',
270 | // margin: '',
271 | // preventFocus: false
272 | }, options);
273 |
274 | !_colorPicker && options.scrollResize && $(window).
275 | on('resize scroll', function() {
276 | if (_colorPicker.$trigger) {
277 | _colorPicker.toggle.call(_colorPicker.$trigger[0], true);
278 | }
279 | });
280 | _instance = _instance ? _instance.add(this) : this;
281 | _instance.colorPicker = _colorPicker ||
282 | (_colorPicker = new ColorPicker(options));
283 | _selector += (_selector ? ', ' : '') + this.selector;
284 |
285 | $(options.body).off('.a').
286 | on('touchstart.a mousedown.a pointerdown.a', function(e) {
287 | var $target = $(e.target);
288 |
289 | if ($.inArray($target.closest(_selector)[0],
290 | _instance) === -1 &&
291 | !$target.closest(_$UI).length) {
292 | toggle();
293 | }
294 | }).
295 | on('focus.a click.a', _selector, toggle).
296 | on('change.a', _selector, function() {
297 | _color.setColor(this.value);
298 | _instance.colorPicker.render();
299 | });
300 |
301 | return this.each(function() {
302 | var value = extractValue(this),
303 | mode = value.split('('),
304 | $elm = findElement($(this));
305 |
306 | $elm.data('colorMode', mode[1] ? mode[0].substr(0, 3) : 'HEX').
307 | attr('readonly', _options.preventFocus);
308 | options.doRender && $elm.
309 | css({'background-color': value,
310 | 'color': function() {
311 | return _color.setColor(value).
312 | rgbaMixBGMixCustom.luminance > 0.22 ? '#222' : '#ddd'
313 | }
314 | });
315 | });
316 | };
317 | })(window.jQuery, Colors);
--------------------------------------------------------------------------------
/3rd/jquery.text-overflow.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.ellipsis = function(enableUpdating){
3 | var s = document.documentElement.style;
4 | if (!('textOverflow' in s || 'OTextOverflow' in s)) {
5 | return this.each(function(){
6 | var el = $(this);
7 | if(el.css("overflow") == "hidden"){
8 | var originalText = el.html();
9 | var w = el.width();
10 |
11 | var t = $(this.cloneNode(true)).hide().css({
12 | 'position': 'absolute',
13 | 'width': 'auto',
14 | 'overflow': 'visible',
15 | 'max-width': 'inherit'
16 | });
17 | el.after(t);
18 |
19 | var text = originalText;
20 | while(text.length > 0 && t.width() > el.width()){
21 | text = text.substr(0, text.length - 1);
22 | t.html(text + "...");
23 | }
24 | el.html(t.html());
25 |
26 | t.remove();
27 |
28 | if(enableUpdating == true){
29 | var oldW = el.width();
30 | setInterval(function(){
31 | if(el.width() != oldW){
32 | oldW = el.width();
33 | el.html(originalText);
34 | el.ellipsis();
35 | }
36 | }, 200);
37 | }
38 | }
39 | });
40 | } else return this;
41 | };
42 | })(jQuery);
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | ======================
2 | JavaScript Experiments
3 | ======================
4 |
5 | Some JavaScript experiments. You can see them online using the links below.
6 | `Google Chrome
`_ is the best browser
7 | for these demos, but `Opera `_ or
8 | Firefox should be fine too.
9 |
10 | `Gray-Scott `_
11 | ==========================================================
12 |
13 | `Gray-Scott `_
14 | is a solver for the Gray-Scott reaction-diffusion model. Roughly, this
15 | can be seen as a simulation of the behavior of diffusive living beings reproducing
16 | under conditions of limited food. Very different patterns emerge for
17 | slight changes in feeding and death rates.
18 |
19 | This experiment uses `Three.js `_
20 | and performs calculations on the GPU.
21 | It requires a WebGL enabled browser.
22 |
23 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/grayscott.png
24 | :align: center
25 | :target: http://pmneila.github.com/jsexp/grayscott
26 |
27 | Screenshots
28 | -----------
29 |
30 | Some screenshots of the application.
31 |
32 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/default_s.png
33 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/default.png
34 |
35 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/holes_s.png
36 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/holes.png
37 |
38 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/mazes_s.png
39 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/mazes.png
40 |
41 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/solitons_s.png
42 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/solitons.png
43 |
44 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/solitons2_s.png
45 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/solitons2.png
46 |
47 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/spots_s.png
48 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/spots.png
49 |
50 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/waves1_s.png
51 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/waves1.png
52 |
53 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/waves2_s.png
54 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/waves2.png
55 |
56 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/worm_s.png
57 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/worm.png
58 |
59 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/worms_s.png
60 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/worms.png
61 |
62 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/inverseworms_s.png
63 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/inverseworms.png
64 |
65 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/chaos_s.png
66 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/chaos.png
67 |
68 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/spotsx_s.png
69 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/spotsx.png
70 |
71 | .. image:: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/wormsx_s.png
72 | :target: https://github.com/pmneila/jsexp/raw/master/grayscott/snapshots/wormsx.png
73 |
74 |
75 | `Particles `_
76 | =========================================================
77 |
78 | `Particles `_
79 | is a simple mass-spring physics simulation.
80 |
81 | .. image:: https://github.com/pmneila/jsexp/raw/master/massspring/particles.png
82 | :align: center
83 | :target: http://pmneila.github.com/jsexp/massspring
84 |
--------------------------------------------------------------------------------
/convtester/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
22 |
23 |
24 |
25 |
26 |
27 |
211 |
212 |
213 |
214 |
--------------------------------------------------------------------------------
/convtester/justified-nav.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding-top: 20px;
3 | }
4 |
5 | .footer {
6 | padding-top: 40px;
7 | padding-bottom: 40px;
8 | margin-top: 40px;
9 | border-top: 1px solid #eee;
10 | }
11 |
12 | /* Main marketing message and sign up button */
13 | .jumbotron {
14 | text-align: center;
15 | background-color: transparent;
16 | }
17 | .jumbotron .btn {
18 | padding: 14px 24px;
19 | font-size: 21px;
20 | }
21 |
22 | /* Customize the nav-justified links to be fill the entire space of the .navbar */
23 |
24 | .nav-justified {
25 | background-color: #eee;
26 | border: 1px solid #ccc;
27 | border-radius: 5px;
28 | }
29 | .nav-justified > li > a {
30 | padding-top: 15px;
31 | padding-bottom: 15px;
32 | margin-bottom: 0;
33 | font-weight: bold;
34 | color: #777;
35 | text-align: center;
36 | background-color: #e5e5e5; /* Old browsers */
37 | background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e5e5e5));
38 | background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%);
39 | background-image: -o-linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%);
40 | background-image: -webkit-gradient(linear, left top, left bottom, from(top), color-stop(0%, #f5f5f5), to(#e5e5e5));
41 | background-image: linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%);
42 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
43 | background-repeat: repeat-x; /* Repeat the gradient */
44 | border-bottom: 1px solid #d5d5d5;
45 | }
46 | .nav-justified > .active > a,
47 | .nav-justified > .active > a:hover,
48 | .nav-justified > .active > a:focus {
49 | background-color: #ddd;
50 | background-image: none;
51 | -webkit-box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
52 | box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
53 | }
54 | .nav-justified > li:first-child > a {
55 | border-radius: 5px 5px 0 0;
56 | }
57 | .nav-justified > li:last-child > a {
58 | border-bottom: 0;
59 | border-radius: 0 0 5px 5px;
60 | }
61 |
62 | @media (min-width: 768px) {
63 | .nav-justified {
64 | max-height: 52px;
65 | }
66 | .nav-justified > li > a {
67 | border-right: 1px solid #d5d5d5;
68 | border-left: 1px solid #fff;
69 | }
70 | .nav-justified > li:first-child > a {
71 | border-left: 0;
72 | border-radius: 5px 0 0 5px;
73 | }
74 | .nav-justified > li:last-child > a {
75 | border-right: 0;
76 | border-radius: 0 5px 5px 0;
77 | }
78 | }
79 |
80 | /* Responsive: Portrait tablets and up */
81 | @media screen and (min-width: 768px) {
82 | /* Remove the padding we set earlier */
83 | .masthead,
84 | .marketing,
85 | .footer {
86 | padding-right: 0;
87 | padding-left: 0;
88 | }
89 | }
--------------------------------------------------------------------------------
/css/experiments.css:
--------------------------------------------------------------------------------
1 |
2 | body {
3 | font-family:sans-serif;
4 | background:#333333;
5 | color:#777777;
6 | width: 1200px;
7 | margin: 0 auto;
8 | }
9 |
10 | header, footer, aside, nav {
11 | display: block;
12 | }
13 |
14 | a:link {color:#777777;}
15 | a:visited {color:#777777;}
16 | a:hover {color:#999999;}
17 | a:active {color:#ffffff;}
18 |
19 | #copyright {
20 | font-size:8pt;
21 | text-align:center;
22 | margin-top:10px;
23 | }
24 |
25 | .remark {
26 | color: #ffffff;
27 | }
28 |
29 | .unsafe {
30 | color : #c86464;
31 | }
32 |
33 | #simulation {
34 | display:table;
35 | margin: 0 auto;
36 | border:1px solid;
37 | box-shadow: 10px 10px 7px #222;
38 | }
39 |
40 | #simulation .viewer {
41 | display:table-cell;
42 | }
43 |
44 | #simulation .panel {
45 | display:table-cell;
46 | vertical-align:top;
47 | width: 200px;
48 | padding: 0px 5px 0px 5px;
49 | font-size: 9pt;
50 | background:#151515;
51 | }
52 | #simulation .panel header {
53 | color: #ffffff;
54 | }
55 |
56 | #simulation .panel .slider {
57 | margin: 7px 10px 10px 10px;
58 | }
59 | #simulation .panel section {
60 | margin-bottom: 15px;
61 | border-bottom: 1px dotted;
62 | }
63 | #simulation .panel section:last-child {
64 | margin-bottom: 0px;
65 | border-bottom: 0px;
66 | }
67 |
68 |
69 | #myCanvas {
70 | display:block;
71 | vertical-align:bottom;
72 | background-color:#000000;
73 | border-right:1px solid;
74 | }
75 |
--------------------------------------------------------------------------------
/css/paintflow.css:
--------------------------------------------------------------------------------
1 |
2 | body {
3 | font-family:sans-serif;
4 | background:#333333;
5 | color:#777777;
6 | margin: 0 auto;
7 | }
8 |
9 | header, footer, aside, nav {
10 | display: block;
11 | }
12 |
13 | a:link {color:#777777;}
14 | a:visited {color:#777777;}
15 | a:hover {color:#999999;}
16 | a:active {color:#ffffff;}
17 |
18 | #copyright {
19 | font-size:8pt;
20 | text-align:center;
21 | margin-top:10px;
22 | }
23 |
24 | .remark {
25 | color: #ffffff;
26 | }
27 |
28 | .unsafe {
29 | color : #c86464;
30 | }
31 |
32 | #myCanvas {
33 | display:block;
34 | vertical-align:bottom;
35 | background-color:#000000;
36 | }
--------------------------------------------------------------------------------
/fastmccabe/render.js:
--------------------------------------------------------------------------------
1 | /*
2 | x y z w x y z w x y z w x y z w
3 | isrc -> x0 -> y0 -> x1 -> y1 -> x2 -> y2 -> x3 -> y3 -> x4 -> y4 -> x5 -> y5 -> x6 -> y6 -> x7 -> y7
4 |
5 | */
6 |
7 | var Renderer = function(config){
8 |
9 | this.canvas = undefined;
10 | this.canvasQ = undefined;
11 | this.canvasWidth = undefined;
12 | this.canvasHeight = undefined;
13 |
14 | this.mRenderer = undefined;
15 | this.mScene = undefined;
16 | this.mCamera = undefined;
17 |
18 | this.uiStep = 0 >>> 0; // coerce to uint32
19 |
20 | this.time = new Date().getTime();
21 |
22 | this.mTexture0 = undefined;
23 | this.mTexture1 = undefined;
24 | this.mTexture2 = undefined;
25 | this.mTexture3 = undefined;
26 | this.mTexture4 = undefined;
27 | this.mTexture5 = undefined;
28 | this.mTexture6 = undefined;
29 | this.mTexture7 = undefined;
30 | this.mTexture8 = undefined;
31 | this.mTexture9 = undefined;
32 | this.debugTexture = undefined;
33 | this.mScreenQuad = undefined;
34 |
35 | this.mccabeMaterial = undefined;
36 | this.debugMaterial = undefined;
37 | this.noiseMaterial = undefined;
38 | this.pass0Material = undefined;
39 | this.pass1Material = undefined;
40 | this.pass2Material = undefined;
41 | this.pass3Material = undefined;
42 | this.screenMaterial = undefined;
43 |
44 | this.textureWidth = 1024;
45 | this.textureHeight = 1024;
46 |
47 | // Configuration.
48 | this.hard = config.hard;
49 | this.rate = config.rate;
50 | this.sharp = config.sharp;
51 | this.exponent = config.exponent;
52 | this.scale = config.scale;
53 | this.stddev = config.stddev;
54 | this.hystj = config.hystj;
55 | this.hystk = config.hystk;
56 | this.blurl = config.blurl;
57 |
58 | this.debug = false;
59 |
60 | this.mUniforms = {
61 | screenWidth: {type: "f", value: undefined},
62 | screenHeight: {type: "f", value: undefined},
63 | sSource: {type: "t", value: undefined},
64 | bSource0: {type: "t", value: undefined},
65 | bSource1: {type: "t", value: undefined},
66 | bSource2: {type: "t", value: undefined},
67 | bSource3: {type: "t", value: undefined},
68 | iSource: {type: "t", value: undefined},
69 | hard: {type: "f", value: this.hard},
70 | rate: {type: "f", value: this.rate},
71 | sharp: {type: "f", value: this.sharp},
72 | exponent: {type: "f", value: this.exponent},
73 | scale: {type: "f", value: this.scale},
74 | stddev: {type: "f", value: this.stddev},
75 | hystj: {type: "f", value: this.hystj},
76 | hystk: {type: "f", value: this.hystk},
77 | blurl: {type: "f", value: this.blurl}
78 | };
79 |
80 | this.updateUniforms = function()
81 | {
82 | this.mUniforms.hard.value = this.hard;
83 | this.mUniforms.rate.value = this.rate;
84 | this.mUniforms.sharp.value = this.sharp;
85 | this.mUniforms.exponent.value = this.exponent;
86 | this.mUniforms.scale.value = this.scale;
87 | this.mUniforms.stddev.value = this.stddev;
88 | this.mUniforms.hystj.value = this.hystj;
89 | this.mUniforms.hystk.value = this.hystk;
90 | this.mUniforms.blurl.value = this.blurl;
91 | };
92 |
93 | this.init = function()
94 | {
95 | this.initCanvas();
96 | this.initGl();
97 | this.render();
98 | };
99 |
100 | this.initCanvas = function()
101 | {
102 | this.canvasQ = $('#myCanvas');
103 | this.canvas = this.canvasQ.get(0);
104 |
105 | window.addEventListener('resize', this.onResize.bind(this), false );
106 | };
107 |
108 | this.getMaterial = function(vertexShaderId, fragmentShaderId)
109 | {
110 | return new THREE.ShaderMaterial({
111 | uniforms: this.mUniforms,
112 | vertexShader: document.getElementById(vertexShaderId).textContent,
113 | fragmentShader: document.getElementById(fragmentShaderId).textContent
114 | });
115 | };
116 |
117 | this.initGl = function()
118 | {
119 | this.mRenderer = new THREE.WebGLRenderer({canvas: this.canvas, preserveDrawingBuffer: true});
120 |
121 | this.mScene = new THREE.Scene();
122 | this.mCamera = new THREE.OrthographicCamera(-0.5, 0.5, 0.5, -0.5, -1, 1);
123 | this.mCamera.position.z = 0;
124 | this.mScene.add(this.mCamera);
125 |
126 | this.screenMaterial = this.getMaterial('standardVertexShader', 'screenFragmentShader');
127 | this.mccabeMaterial = this.getMaterial('standardVertexShader', 'mccabeFragmentShader');
128 | this.debugMaterial = this.getMaterial('standardVertexShader', 'debugFragmentShader');
129 | this.noiseMaterial = this.getMaterial('standardVertexShader', 'noiseFragmentShader');
130 | this.pass0Material = this.getMaterial('gaussianPyramidVertexShader0', 'gaussianPyramidFragmentShader');
131 | this.pass1Material = this.getMaterial('gaussianPyramidVertexShader1', 'gaussianPyramidFragmentShader');
132 | this.pass2Material = this.getMaterial('gaussianPyramidVertexShader2', 'gaussianPyramidFragmentShader');
133 | this.pass3Material = this.getMaterial('gaussianPyramidVertexShader3', 'gaussianPyramidFragmentShader');
134 |
135 | var plane = new THREE.PlaneGeometry(1.0, 1.0);
136 | this.mScreenQuad = new THREE.Mesh(plane, this.screenMaterial);
137 | this.mScene.add(this.mScreenQuad);
138 |
139 | // Set the new shape of canvas.
140 | this.canvasQ.width(this.getCanvasWidth());
141 | this.canvasQ.height(this.getCanvasHeight());
142 |
143 | // Get the real size of canvas.
144 | this.canvasWidth = this.canvasQ.width();
145 | this.canvasHeight = this.canvasQ.height();
146 |
147 | this.mRenderer.setSize(this.canvasWidth, this.canvasHeight);
148 |
149 | this.mTexture0 = this.getWrappedRenderTarget();
150 | this.mTexture1 = this.getWrappedRenderTarget();
151 | this.mTexture2 = this.getWrappedRenderTarget();
152 | this.mTexture3 = this.getWrappedRenderTarget();
153 | this.mTexture4 = this.getWrappedRenderTarget();
154 | this.mTexture5 = this.getWrappedRenderTarget();
155 | this.mTexture6 = this.getWrappedRenderTarget();
156 | this.mTexture7 = this.getWrappedRenderTarget();
157 | this.mTexture8 = this.getWrappedRenderTarget();
158 | this.mTexture9 = this.getWrappedRenderTarget();
159 | this.debugTexture = this.getWrappedRenderTarget();
160 |
161 | this.mUniforms.screenWidth.value = this.textureWidth;
162 | this.mUniforms.screenHeight.value = this.textureHeight;
163 |
164 | };
165 |
166 | this.getWrappedRenderTarget = function()
167 | {
168 | return new THREE.WebGLRenderTarget(this.textureWidth, this.textureHeight, {
169 | minFilter: THREE.NearestFilter,
170 | magFilter: THREE.NearestFilter,
171 | format: THREE.RGBAFormat,
172 | type: THREE.FloatType,
173 | wrapS: THREE.RepeatWrapping,
174 | wrapT: THREE.RepeatWrapping
175 | });
176 | };
177 |
178 | this.renderToTarget = function(material, iSource, sSource, target)
179 | {
180 | this.mScreenQuad.material = material;
181 | this.mUniforms.iSource.value = iSource;
182 | this.mUniforms.sSource.value = sSource;
183 | this.mRenderer.render(this.mScene, this.mCamera, target, true);
184 | };
185 |
186 | this.renderToFinalTarget = function(material, iSource, bSource0, bSource1, bSource2, bSource3, target)
187 | {
188 | this.mScreenQuad.material = material;
189 | this.mUniforms.iSource.value = iSource;
190 | this.mUniforms.bSource0.value = bSource0;
191 | this.mUniforms.bSource1.value = bSource1;
192 | this.mUniforms.bSource2.value = bSource2;
193 | this.mUniforms.bSource3.value = bSource3;
194 | this.mRenderer.render(this.mScene, this.mCamera, target, true);
195 | };
196 |
197 | this.render = function()
198 | {
199 | this.updateUniforms();
200 | var imageTexture;
201 |
202 | if (this.uiStep == 0) {
203 | this.renderToTarget(this.noiseMaterial, this.mTexture0, this.mTexture1, this.mTexture0);
204 | this.renderToTarget(this.noiseMaterial, this.mTexture0, this.mTexture1, this.mTexture9);
205 | }
206 | if (this.uiStep % 2 == 0) {
207 | this.renderToTarget(this.pass0Material, this.mTexture0, this.mTexture1, this.mTexture2);
208 | this.renderToTarget(this.pass1Material, this.mTexture2, this.mTexture3, this.mTexture4);
209 | this.renderToTarget(this.pass2Material, this.mTexture4, this.mTexture5, this.mTexture6);
210 | this.renderToTarget(this.pass3Material, this.mTexture6, this.mTexture7, this.mTexture8);
211 | this.renderToFinalTarget(this.mccabeMaterial, this.mTexture0, this.mTexture2, this.mTexture4, this.mTexture6, this.mTexture8, this.mTexture9);
212 | if (this.debug) {
213 | this.renderToFinalTarget(this.debugMaterial, this.mTexture0, this.mTexture2, this.mTexture4, this.mTexture6, this.mTexture8, this.debugTexture);
214 | imageTexture = this.debugTexture;
215 | } else {
216 | imageTexture = this.mTexture9;
217 | }
218 | } else {
219 | this.renderToTarget(this.pass0Material, this.mTexture9, this.mTexture2, this.mTexture1);
220 | this.renderToTarget(this.pass1Material, this.mTexture1, this.mTexture4, this.mTexture3);
221 | this.renderToTarget(this.pass2Material, this.mTexture3, this.mTexture6, this.mTexture5);
222 | this.renderToTarget(this.pass3Material, this.mTexture5, this.mTexture8, this.mTexture7);
223 | this.renderToFinalTarget(this.mccabeMaterial, this.mTexture9, this.mTexture1, this.mTexture3, this.mTexture5, this.mTexture7, this.mTexture0);
224 | if (this.debug) {
225 | this.renderToFinalTarget(this.debugMaterial, this.mTexture9, this.mTexture1, this.mTexture3, this.mTexture5, this.mTexture7, this.debugTexture);
226 | imageTexture = this.debugTexture;
227 | } else {
228 | imageTexture = this.mTexture0;
229 | }
230 | }
231 |
232 | this.mUniforms.iSource.value = imageTexture;
233 | this.mScreenQuad.material = this.screenMaterial;
234 | this.mRenderer.render(this.mScene, this.mCamera);
235 |
236 | this.uiStep++;
237 | requestAnimationFrame(this.render.bind(this));
238 | };
239 |
240 | this.resetCounter = function() {
241 | this.uiStep = 0 >>> 0;
242 | };
243 |
244 | this.snapshot = function()
245 | {
246 | var dataURL = this.canvas.toDataURL("image/jpeg");
247 | window.open(dataURL, "name-"+Math.random());
248 | };
249 |
250 | this.toggleDebug = function()
251 | {
252 | this.debug = !this.debug;
253 | };
254 |
255 | this.onResize = function()
256 | {
257 |
258 | // Set the new shape of canvas.
259 | this.canvasQ.width(this.getCanvasWidth());
260 | this.canvasQ.height(this.getCanvasHeight());
261 |
262 | // Get the real size of canvas.
263 | this.canvasWidth = this.canvasQ.width();
264 | this.canvasHeight = this.canvasQ.height();
265 |
266 | this.mRenderer.setSize(this.canvasWidth, this.canvasHeight);
267 |
268 | };
269 |
270 | this.getCanvasWidth = function()
271 | {
272 | return window.innerWidth;
273 | };
274 |
275 | this.getCanvasHeight = function()
276 | {
277 | return window.innerHeight;
278 | };
279 |
280 | };
281 |
282 | window.onload = function() {
283 | var renderer = new Renderer({
284 | hard: 10.0,
285 | rate: 25.0,
286 | sharp: 10.0,
287 | exponent: 2.0,
288 | stddev: 4.0,
289 | scale: 0.001,
290 | hystj: 5.0,
291 | hystk: 20.0,
292 | blurl: 4.0
293 | });
294 | var gui = new dat.GUI();
295 |
296 | gui.add(renderer, 'hard').min(0.0).max(50.0).step(0.01).name("Hardness");
297 | gui.add(renderer, 'sharp').min(0.0).max(20.0).step(0.01).name("Sharpness");
298 | gui.add(renderer, 'exponent').min(-5.0).max(5.0).step(0.01).name("Scale Exponent");
299 | gui.add(renderer, 'scale').min(0.001).max(1.0).step(0.001).name("Prescale");
300 | gui.add(renderer, 'rate').min(0.0).max(50.0).step(0.01).name("Rate");
301 | gui.add(renderer, 'stddev').min(0.0).max(10.0).step(0.01).name("Std Deviation");
302 | gui.add(renderer, 'hystj').min(0.01).max(10.0).step(0.01).name("Hysteresis Scale");
303 | gui.add(renderer, 'hystk').min(0.01).max(40.0).step(0.01).name("Hysteresis Delta");
304 | gui.add(renderer, 'blurl').min(0.0).max(7.0).step(0.01).name("Debug View Ctrl");
305 | gui.add(renderer, 'toggleDebug').name("Debug View");
306 | gui.add(renderer, 'snapshot').name("Screenshot");
307 |
308 | renderer.init();
309 | };
--------------------------------------------------------------------------------
/fastmccabe/style.css:
--------------------------------------------------------------------------------
1 |
2 | body {
3 | font-family:sans-serif;
4 | background:#333333;
5 | color:#777777;
6 | margin: 0 auto;
7 | }
8 |
9 | header, footer, aside, nav {
10 | display: block;
11 | }
12 |
13 | #myCanvas {
14 | display:block;
15 | vertical-align:bottom;
16 | background-color:#000000;
17 | }
--------------------------------------------------------------------------------
/frustratedflockingfluid/grayscott.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/frustratedflockingfluid/grayscott.png
--------------------------------------------------------------------------------
/gradientui/gradientui.css:
--------------------------------------------------------------------------------
1 |
2 | .gradient-view
3 | {
4 | border: 1px solid;
5 | }
6 |
7 | .gradient-dragger
8 | {
9 | border: 1px solid;
10 | width: 7px;
11 | height: 8px;
12 | position: absolute;
13 | bottom: 10px;
14 | cursor: auto;
15 | }
16 |
--------------------------------------------------------------------------------
/gradientui/gradientui.js:
--------------------------------------------------------------------------------
1 |
2 | (function($){
3 |
4 | var hexToRgb = function(hex) {
5 | var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
6 | return result ? {
7 | r: parseInt(result[1], 16)/255.0,
8 | g: parseInt(result[2], 16)/255.0,
9 | b: parseInt(result[3], 16)/255.0
10 | } : null;
11 | }
12 |
13 | var clamp = function(value, min, max)
14 | {
15 | return Math.max(min, Math.min(max, value));
16 | }
17 |
18 | var Dragger = function(parent, position, color)
19 | {
20 | this.parent = parent;
21 | this.parent.$this.append('
');
22 | this.$this = parent.$this.children('.gradient-dragger:last');
23 | this.width = parent.$this.children('.gradient-view').width() - 7;
24 | this.position = position;
25 | this.color = color;
26 | this.dragging = false;
27 | this.moved = false;
28 | this.oldleft = undefined
29 | this.mousedownx = undefined;
30 | this.$this.css("left", this.position*this.width);
31 | this.$this.css("background-color", this.color);
32 |
33 | this.$this.bind("click.dragger", {this : this}, function(event){event.data.this.click(event)});
34 | this.$this.bind("mousedown.dragger", {this : this}, function(event){event.data.this.mousedown(event)});
35 | $(window).bind("mouseup.dragger", {this : this}, function(event){event.data.this.mouseup(event)});
36 | $(window).bind("mousemove.dragger", {this : this}, function(event){event.data.this.mousemove(event)});
37 | }
38 |
39 | Dragger.prototype.click = function(event)
40 | {
41 | if(this.moved)
42 | return;
43 |
44 | var aux = this;
45 | colorPicker.exportColor = function()
46 | {
47 | aux.color = '#' + colorPicker.CP.hex;
48 | aux.$this.css("background-color", aux.color);
49 | aux.parent.redraw();
50 | };
51 |
52 | colorPicker.expColor = false;
53 | colorPicker.expHEX = false;
54 | colorPicker.mode = 'H';
55 | colorPicker.objs = this.color;
56 | colorPicker(event);
57 | }
58 |
59 | Dragger.prototype.mousedown = function(event)
60 | {
61 | this.oldleft = parseInt(this.$this.css("left"), 10);
62 | this.mousedownx = event.pageX;
63 | this.dragging = true;
64 | this.moved = false;
65 | }
66 |
67 | Dragger.prototype.mouseup = function(event)
68 | {
69 | this.dragging = false;
70 | }
71 |
72 | Dragger.prototype.mousemove = function(event)
73 | {
74 | if(!this.dragging)
75 | return;
76 |
77 | var diff = event.pageX - this.mousedownx;
78 | var newleft = clamp(this.oldleft + diff, 0, this.width);
79 |
80 | this.position = newleft / this.width;
81 | this.$this.css("left", newleft);
82 | this.parent.redraw();
83 |
84 | this.moved = true;
85 | }
86 |
87 | Dragger.prototype.setPosition = function(pos)
88 | {
89 | pos = clamp(pos, 0.0, 1.0);
90 | var newleft = pos*this.width;
91 |
92 | this.$this.css("left", newleft);
93 | this.position = pos;
94 | }
95 |
96 | Dragger.prototype.setColor = function(color)
97 | {
98 | this.color = color;
99 | this.$this.css("background-color", color);
100 | this.parent.redraw();
101 | }
102 |
103 | var Gradient = function(parent, values)
104 | {
105 | this.$this = parent;
106 |
107 | // Disable selection.
108 | this.$this.get(0).onselectstart = function(){return false;};
109 |
110 | this.$this.css("position", "relative");
111 | this.width = this.$this.width();
112 | this.height = this.$this.height();
113 | this.$this.append(' ');
114 |
115 | this.gradientview = this.$this.children('.gradient-view:first');
116 | this.gradientview.width(this.width);
117 | this.gradientview.height(this.height - 21);
118 | this.gradientview.css('position', 'absolute');
119 | this.gradientview.css('left', 0);
120 |
121 | this.canvas = this.gradientview.get(0);
122 | this.canvas.width = this.gradientview.width();
123 | this.canvas.height = this.gradientview.height();
124 | this.ctx = this.canvas.getContext('2d');
125 |
126 | this.draggers = [];
127 | for(var i=0; i < values.length; i++)
128 | this.draggers.push(new Dragger(this, values[i][0], values[i][1]));
129 |
130 | this.redraw();
131 | }
132 |
133 | Gradient.prototype.updateValues = function()
134 | {
135 | var aux = this.draggers.map(function(a){return [a.position, a.color];});
136 | aux.sort(function(a,b){return a[0]-b[0];});
137 |
138 | this.values = aux;
139 |
140 | if(this.callback !== undefined)
141 | this.callback.fn(this.callback.data);
142 | }
143 |
144 | Gradient.prototype.setValues = function(values)
145 | {
146 | this.values = values;
147 | for (var i = values.length - 1; i >= 0; i--) {
148 | var v = values[i];
149 | this.draggers[i].setPosition(v[0]);
150 | this.draggers[i].setColor(v[1]);
151 | };
152 | }
153 |
154 | Gradient.prototype.redraw = function()
155 | {
156 | this.updateValues();
157 | var values = this.values;
158 |
159 | var lingrad = this.ctx.createLinearGradient(0, 0, this.canvas.width, 0);
160 | for(var i=0; i
2 |
3 |
4 |
5 | Gradient widget
6 |
7 |
8 |
9 |
10 |
14 |
19 |
20 |
21 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/grayscott/grayscott.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/grayscott/grayscott.png
--------------------------------------------------------------------------------
/gsimage/grayscott.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Gray-Scott
3 | *
4 | * A solver of the Gray-Scott model of reaction diffusion.
5 | *
6 | * ©2012 pmneila.
7 | * p.mneila at upm.es
8 | */
9 |
10 | (function(){
11 |
12 | // Canvas.
13 | var canvas;
14 | var canvasQ;
15 | var canvasWidth;
16 | var canvasHeight;
17 |
18 | var mMouseX, mMouseY;
19 | var mMouseDown = false;
20 |
21 | var mRenderer;
22 | var mScene;
23 | var mCamera;
24 | var mUniforms;
25 | var mColors;
26 | var mColorsNeedUpdate = true;
27 | var mLastTime = 0;
28 |
29 | var mMap;
30 | var mTexture1, mTexture2;
31 | var mGSMaterial, mScreenMaterial;
32 | var mScreenQuad;
33 |
34 | var mToggled = false;
35 |
36 | var mMinusOnes = new THREE.Vector2(-1, -1);
37 |
38 | // Some presets.
39 | var presets = [
40 | { // Default
41 | //feed: 0.018,
42 | //kill: 0.051
43 | feed: 0.037,
44 | kill: 0.061
45 | },
46 | { // Solitons
47 | feed: 0.03,
48 | kill: 0.062
49 | },
50 | { // Pulsating solitons
51 | feed: 0.025,
52 | kill: 0.06
53 | },
54 | { // Worms.
55 | feed: 0.078,
56 | kill: 0.061
57 | },
58 | { // Mazes
59 | feed: 0.029,
60 | kill: 0.057
61 | },
62 | { // Holes
63 | feed: 0.039,
64 | kill: 0.058
65 | },
66 | { // Chaos
67 | feed: 0.026,
68 | kill: 0.051
69 | },
70 | { // Chaos and holes (by clem)
71 | feed: 0.034,
72 | kill: 0.056
73 | },
74 | { // Moving spots.
75 | feed: 0.014,
76 | kill: 0.054
77 | },
78 | { // Spots and loops.
79 | feed: 0.018,
80 | kill: 0.051
81 | },
82 | { // Waves
83 | feed: 0.014,
84 | kill: 0.045
85 | },
86 | { // The U-Skate World
87 | feed: 0.062,
88 | kill: 0.06093
89 | }
90 | ];
91 |
92 | // Configuration.
93 | var feed = presets[0].feed;
94 | var kill = presets[0].kill;
95 |
96 | lena.onload = function(){init()};
97 |
98 | init = function()
99 | {
100 | init_controls();
101 |
102 | canvasQ = $('#myCanvas');
103 | canvas = canvasQ.get(0);
104 |
105 | canvas.onmousedown = onMouseDown;
106 | canvas.onmouseup = onMouseUp;
107 | canvas.onmousemove = onMouseMove;
108 |
109 | mRenderer = new THREE.WebGLRenderer({canvas: canvas, preserveDrawingBuffer: true});
110 |
111 | mScene = new THREE.Scene();
112 | mCamera = new THREE.OrthographicCamera(-0.5, 0.5, 0.5, -0.5, -10000, 10000);
113 | mCamera.position.z = 100;
114 | mScene.add(mCamera);
115 |
116 | mMap = new THREE.Texture(lena);
117 | mMap.wrapS = THREE.RepeatWrapping;
118 | mMap.wrapT = THREE.RepeatWrapping;
119 | mMap.repeat.x = mMap.repeat.y = 512;
120 | mMap.needsUpdate = true;
121 | mUniforms = {
122 | screenWidth: {type: "f", value: undefined},
123 | screenHeight: {type: "f", value: undefined},
124 | tSource: {type: "t", value: undefined},
125 | delta: {type: "f", value: 1.0},
126 | feed_texture: {type: "t", value: mMap},
127 | kill: {type: "f", value: kill},
128 | brush: {type: "v2", value: new THREE.Vector2(-10, -10)},
129 | color1: {type: "v4", value: new THREE.Vector4(0, 0, 0.0, 0)},
130 | color2: {type: "v4", value: new THREE.Vector4(0, 1, 0, 0.2)},
131 | color3: {type: "v4", value: new THREE.Vector4(1, 1, 0, 0.21)},
132 | color4: {type: "v4", value: new THREE.Vector4(1, 0, 0, 0.4)},
133 | color5: {type: "v4", value: new THREE.Vector4(1, 1, 1, 0.6)}
134 | };
135 | mColors = [mUniforms.color1, mUniforms.color2, mUniforms.color3, mUniforms.color4, mUniforms.color5];
136 | $("#gradient").gradient("setUpdateCallback", onUpdatedColor);
137 |
138 | mGSMaterial = new THREE.ShaderMaterial({
139 | uniforms: mUniforms,
140 | vertexShader: document.getElementById('standardVertexShader').textContent,
141 | fragmentShader: document.getElementById('gsFragmentShader').textContent,
142 | });
143 | mScreenMaterial = new THREE.ShaderMaterial({
144 | uniforms: mUniforms,
145 | vertexShader: document.getElementById('standardVertexShader').textContent,
146 | fragmentShader: document.getElementById('screenFragmentShader').textContent,
147 | });
148 |
149 | var plane = new THREE.PlaneGeometry(1.0, 1.0);
150 | mScreenQuad = new THREE.Mesh(plane, mScreenMaterial);
151 | mScene.add(mScreenQuad);
152 |
153 | mColorsNeedUpdate = true;
154 |
155 | resize(512, 512);
156 |
157 | render(0);
158 | mUniforms.brush.value = new THREE.Vector2(0.5, 0.5);
159 | mLastTime = new Date().getTime();
160 | requestAnimationFrame(render);
161 | }
162 |
163 | var resize = function(width, height)
164 | {
165 | // Set the new shape of canvas.
166 | canvasQ.width(width);
167 | canvasQ.height(height);
168 |
169 | // Get the real size of canvas.
170 | canvasWidth = canvasQ.width();
171 | canvasHeight = canvasQ.height();
172 |
173 | mRenderer.setSize(canvasWidth, canvasHeight);
174 |
175 | // TODO: Possible memory leak?
176 | var scale = 1.0;
177 | mTexture1 = new THREE.WebGLRenderTarget(canvasWidth*scale, canvasHeight*scale,
178 | {minFilter: THREE.LinearFilter,
179 | magFilter: THREE.LinearFilter,
180 | format: THREE.RGBFormat,
181 | type: THREE.FloatType});
182 | mTexture2 = new THREE.WebGLRenderTarget(canvasWidth*scale, canvasHeight*scale,
183 | {minFilter: THREE.LinearFilter,
184 | magFilter: THREE.LinearFilter,
185 | format: THREE.RGBFormat,
186 | type: THREE.FloatType});
187 |
188 | mUniforms.screenWidth.value = canvasWidth*scale;
189 | mUniforms.screenHeight.value = canvasHeight*scale;
190 | }
191 |
192 | var render = function(time)
193 | {
194 | var dt = (time - mLastTime)/20.0;
195 | if(dt > 0.8 || dt<=0)
196 | dt = 0.8;
197 | mLastTime = time;
198 |
199 | mScreenQuad.material = mGSMaterial;
200 | mUniforms.delta.value = dt;
201 | // mUniforms.feed.value = feed;
202 | mUniforms.kill.value = kill;
203 |
204 | for(var i=0; i<8; ++i)
205 | {
206 | if(!mToggled)
207 | {
208 | mUniforms.tSource.value = mTexture1;
209 | mRenderer.render(mScene, mCamera, mTexture2, true);
210 | mUniforms.tSource.value = mTexture2;
211 | }
212 | else
213 | {
214 | mUniforms.tSource.value = mTexture2;
215 | mRenderer.render(mScene, mCamera, mTexture1, true);
216 | mUniforms.tSource.value = mTexture1;
217 | }
218 |
219 | mToggled = !mToggled;
220 | mUniforms.brush.value = mMinusOnes;
221 | }
222 |
223 | if(mColorsNeedUpdate)
224 | updateUniformsColors();
225 |
226 | mScreenQuad.material = mScreenMaterial;
227 | mRenderer.render(mScene, mCamera);
228 |
229 | requestAnimationFrame(render);
230 | }
231 |
232 | loadPreset = function(idx)
233 | {
234 | feed = presets[idx].feed;
235 | kill = presets[idx].kill;
236 | worldToForm();
237 | }
238 |
239 | var updateUniformsColors = function()
240 | {
241 | var values = $("#gradient").gradient("getValuesRGBS");
242 | for(var i=0; i
2 |
3 |
4 | Reaction diffusion simulation
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
23 |
70 |
123 |
124 |
125 |
126 |
136 |
155 |
156 |
157 |
158 | Gray-Scott model with image-based feed rate (alpha)
159 |
160 |
184 |
192 |
193 |
194 |
This simulation requires the GL extensions framebuffer_object and texture_float.
195 | If you cannot see the simulation your system probably lacks at least one of these extensions.
196 |
197 |
In Google Chrome, you can see the available GL extensions going to chrome://gpu.
198 |
199 |
200 |
201 |
--------------------------------------------------------------------------------
/gsimage/lena512.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CornuAmmonis/jsexp/24ecb3d621c47a8abfb01828775703674eaf9250/gsimage/lena512.jpg
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/massspring/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Mass-spring simulation
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
17 |
18 |
19 |
20 | Mass-spring simulation
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | Change the scene with the controls below.
29 | Use the
30 | to drag particles.
31 | Use the
32 | to pin/unpin particles.
33 |
34 |
35 |