Parcourir la Source

add a few more dynamic trixls.

Lucas Stadler 12 ans auparavant
Parent
commit
3ab6c64762
1 fichiers modifiés avec 34 ajouts et 0 suppressions
  1. 34 0
      js/pixl/public/trixl.html

+ 34 - 0
js/pixl/public/trixl.html

@ -215,6 +215,40 @@
215 215
			}
216 216
		}
217 217
218
		trixl.dynamic.sin = function(pos, width, height, color) {
219
			var color = color || trixl.color;
220
			return function(t) {
221
				var x = (t * 0.01) % width,
222
				    y = height * (Math.sin(t * 0.01) + 1.0) * 0.5;
223
				return {x: pos[0] + x, y: pos[1] + y, z: pos[2], color: color};
224
			}
225
		}
226
227
		trixl.dynamic.circleDance = function(pos, radius, height, color) {
228
			var color = color || trixl.color;
229
			var scale = 1 / (10 * radius)
230
			return function(t) {
231
				var x = radius * Math.sin(t * scale),
232
				    y = height * (Math.sin(t * scale / height) + 1.0) * 0.5,
233
				    z = radius * Math.cos(t * scale);
234
				return {x: pos[0] + x, y: pos[1] + y, z: pos[2] + z, color: color};
235
			}
236
		}
237
238
		trixl.dynamic.sinWave = function(pos, length, width, height, color) {
239
			var wavies = [];
240
			for (var i = 0; i < length; i++) {
241
				var sin = trixl.dynamic.sin(pos, width, height, color);
242
				var wavie = function(i) {
243
					return function(t) {
244
						return sin(t - i * 250);
245
					}
246
				}(i);
247
				wavies.push(wavie);
248
			}
249
			return wavies;
250
		}
251
218 252
		trixl.generate = {};
219 253
		trixl.generate.random = function(lo, hi, color) {
220 254
			var x = lo + Math.round(Math.random() * (hi - lo)),