UNPKG

mountain-generator

Version:
17 lines (16 loc) 988 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.lowPoly = void 0; const displacement_map_1 = require("./functions/displacement-map"); const to_line_1 = require("./functions/to-line"); const to_path_1 = require("./functions/to-path"); const colors = ["#D6AE01", "#F75E25", "#434B4D"]; function lowPoly(options) { const { width, height, points, roughness } = options; let svg = ""; const svgPath = (0, to_path_1.default)(width, height, (0, to_line_1.default)(width, (0, displacement_map_1.default)(height, Math.pow(2, points), height / 4, roughness))); svg += `<path fill=${colors[Math.floor(Math.random() * colors.length)]} d="${svgPath}" />`; return `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 ${width} ${height}" width="${width}" height="${height}" preserveAspectRatio="none" version="1.1">${svg}</svg>`; } exports.lowPoly = lowPoly; exports.default = lowPoly;