From 9ccb4a7bc728fd0e85c04fddb802fde02b73cfe2 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 29 May 2022 20:44:11 -0500 Subject: add basic color brushing demo --- src/modules/Terrain.js | 111 ------------------------------------------------- 1 file changed, 111 deletions(-) delete mode 100644 src/modules/Terrain.js (limited to 'src/modules') diff --git a/src/modules/Terrain.js b/src/modules/Terrain.js deleted file mode 100644 index 21908ac..0000000 --- a/src/modules/Terrain.js +++ /dev/null @@ -1,111 +0,0 @@ -'use strict'; - -import Voronoi from './3rdparty/rhill-voronoi-core.js'; - -import { useAverage } from './Util.js'; -import { AABB, QuadTree } from './Geometry.js'; - - -/* from here on up, we always assume that points live in the range [(0,0), (1,1)) */ - -function lloydRelax(point_set, density) { - /* setup quadtree and averages */ - let tree = new QuadTree(1,1); - let averages = {}; - for (let i=0; i ({x: Math.random(), y: Math.random()}); - - this.min_height = 0; - this.max_height = 0; - - let seed_points = []; - for (let i=0; i (a.x - b.x)**2 + (a.y - b.y)**2; - - const sigma = radius/3; - const beta = 1/(2*sigma*sigma); - const center = { x, y }; - const power = pt => Math.exp(-beta * dist2(pt, center)); - - for (let pt of points) f(pt, strength * power(pt)); - } - - - renderGrid(ct) { - ct.save(); - ct.lineWidth = 0.001; - for (let edge of this.graph.edges) { - ct.fillStyle = `hsl(${edge.va.height}, 100%, 50%)`; - ct.beginPath(); - ct.arc(edge.va.x, edge.va.y, 0.005, 0, 2*Math.PI); - ct.closePath(); - ct.fill(); - - ct.beginPath(); - ct.moveTo(edge.va.x, edge.va.y); - ct.lineTo(edge.vb.x, edge.vb.y); - ct.closePath(); - ct.stroke(); - } - ct.restore(); - } -} - -export { lloydRelax }; -export default Terrain; -- cgit v1.2.1