Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ready() {
this.sx = +this.attr('width');
this.sy = +this.attr('height') || this.sx;
const r = +this.attr('resolution') || 2;
this.rx = this.sx * r;
this.ry = this.sy * r;
this.$canvas =
$N('canvas', {width: this.rx, height: this.ry}, this) as CanvasView;
this.$canvas.css({width: this.sx + 'px', height: this.sy + 'px'});
this.loadBackground(this.attr('src'));
this.depthMap1 = repeat2D(0, this.sx, this.sy);
this.depthMap2 = repeat2D(0, this.sx, this.sy);
this.damping = +this.attr('damping') || 0.994;
this.clipping = +this.attr('clipping') || 5;
this.refraction = +this.attr('refraction') || 8;
this.reflection = +this.attr('reflection') || 1;
// The touch pattern is a 2D array containing numbers between -1 and 1.
this.touchPattern = this.createDropPattern(this.touchSize * 2);
slide(this.$canvas, {
start: (p) => this.touchWater(p.scale(1 / r), 0.5),
move: (p) => this.touchWater(p.scale(1 / r), 0.1)
});
}
ready() {
this.sx = +this.attr('width');
this.sy = +this.attr('height') || this.sx;
const r = +this.attr('resolution') || 2;
this.rx = this.sx * r;
this.ry = this.sy * r;
this.$canvas =
$N('canvas', {width: this.rx, height: this.ry}, this) as CanvasView;
this.$canvas.css({width: this.sx + 'px', height: this.sy + 'px'});
this.loadBackground(this.attr('src'));
this.depthMap1 = repeat2D(0, this.sx, this.sy);
this.depthMap2 = repeat2D(0, this.sx, this.sy);
this.damping = +this.attr('damping') || 0.994;
this.clipping = +this.attr('clipping') || 5;
this.refraction = +this.attr('refraction') || 8;
this.reflection = +this.attr('reflection') || 1;
// The touch pattern is a 2D array containing numbers between -1 and 1.
this.touchPattern = this.createDropPattern(this.touchSize * 2);
slide(this.$canvas, {
start: (p) => this.touchWater(p.scale(1 / r), 0.5),
move: (p) => this.touchWater(p.scale(1 / r), 0.1)
});
}
function redraw() {
if (points.length < 2) return $path.points = [];
let matrix = repeat2D(0, points.length, points.length);
for (let i = 0; i < points.length; ++i) {
for (let j = 0; j < i; ++j) {
matrix[i][j] = matrix[j][i] = Point.distance(points[i], points[j]);
}
}
const tsm = travellingSalesman(matrix);
$path.points = tsm.path!.map(i => points[i]);
}
export function fill(value: number, x: number, y: number) {
return repeat2D(value, x, y);
}