1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| <script type="module"> import { Graph, Layer, VectorSource, BgUtil, Color, MathUtil, GGeometryType, Rect, Point, Circle, Gradient, Text, Polyline, Polygon } from "../../src/index.js";
let colorSet = ["red", "orange", "gold", "green", "black", "blue"];
let graph = new Graph({ "target": "graphWrapper" });
BgUtil.generateGrid(Object.assign({ "interval": 10, "graph": graph }, graph.getSize()));
let layer = graph.addLayer(); let width = 180; let height = 120; let colorSet = ["red", "orange", "gold", "green", "black", "blue"];
for (let x = 40; x < 800; x += width + 20) { for (let y = 40; y < 400; y += height + 20) { let color = colorSet[MathUtil.getRandomNum(0, colorSet.length - 1)]; let colorBand = Color.band(color, 10);
let gradient = new Gradient({ "type": "linear", "coords": { "x1": x, "y1": y, "x2": x + width, "y2": y }, "colorStops": [{ "offset": "0.1", "color": colorBand[2] }, { "offset": "0.95", "color": colorBand[6] }] });
layer.getSource().add(new Rect({ x, y, width, height, "style": { "fillColor": gradient, "fillStyle": 1, "shadowOffsetX": MathUtil.getRandomNum(3, 8), "shadowOffsetY": MathUtil.getRandomNum(2, 5), "shadowBlur": 30, "shadowColor": colorBand[8], "color": "none" } })); } } </script>
|