diff --git a/examples/data/branch_circle.png b/examples/data/branch_circle.png new file mode 100644 index 0000000..887482f Binary files /dev/null and b/examples/data/branch_circle.png differ diff --git a/examples/data/branch_long.png b/examples/data/branch_long.png new file mode 100644 index 0000000..e391e94 Binary files /dev/null and b/examples/data/branch_long.png differ diff --git a/examples/data/drop-alpha.png b/examples/data/drop-alpha.png new file mode 100644 index 0000000..76a2449 Binary files /dev/null and b/examples/data/drop-alpha.png differ diff --git a/examples/data/flower1.png b/examples/data/flower1.png new file mode 100644 index 0000000..c0d1226 Binary files /dev/null and b/examples/data/flower1.png differ diff --git a/examples/data/flower2.png b/examples/data/flower2.png new file mode 100644 index 0000000..669a8cb Binary files /dev/null and b/examples/data/flower2.png differ diff --git a/examples/data/flower3.png b/examples/data/flower3.png new file mode 100644 index 0000000..53a0a2d Binary files /dev/null and b/examples/data/flower3.png differ diff --git a/examples/data/leaf1.png b/examples/data/leaf1.png new file mode 100644 index 0000000..b4e616e Binary files /dev/null and b/examples/data/leaf1.png differ diff --git a/examples/data/leaf2.png b/examples/data/leaf2.png new file mode 100644 index 0000000..bd4e232 Binary files /dev/null and b/examples/data/leaf2.png differ diff --git a/examples/data/tile1.png b/examples/data/tile1.png new file mode 100644 index 0000000..13966da Binary files /dev/null and b/examples/data/tile1.png differ diff --git a/examples/data/tile2.png b/examples/data/tile2.png new file mode 100644 index 0000000..f80a4ef Binary files /dev/null and b/examples/data/tile2.png differ diff --git a/examples/data/tile3.png b/examples/data/tile3.png new file mode 100644 index 0000000..e5c2376 Binary files /dev/null and b/examples/data/tile3.png differ diff --git a/examples/data/tile4.png b/examples/data/tile4.png new file mode 100644 index 0000000..9383f64 Binary files /dev/null and b/examples/data/tile4.png differ diff --git a/examples/data/tile5.png b/examples/data/tile5.png new file mode 100644 index 0000000..fe52bd1 Binary files /dev/null and b/examples/data/tile5.png differ diff --git a/examples/data/tile6.png b/examples/data/tile6.png new file mode 100644 index 0000000..d0afddf Binary files /dev/null and b/examples/data/tile6.png differ diff --git a/examples/js/util.js b/examples/js/util.js new file mode 100644 index 0000000..bb73930 --- /dev/null +++ b/examples/js/util.js @@ -0,0 +1,75 @@ +const pixelRatio = 2; +let isDown = false, moveX = 0, moveY = 0, offsetX = 0, offsetY = 0; +let canvas, ctx; +let renderer, stage; +let sw = document.body.clientWidth; +let sh = document.body.clientHeight; + +function generateCanvas() { + canvas = document.createElement('canvas'); + document.body.appendChild(canvas); + ctx = canvas.getContext("2d"); + + window.addEventListener('resize', canvasResize, false); + canvasResize(); + + moveEvent(canvas); +} + +function canvasResize() { + sw = document.body.clientWidth; + sh = document.body.clientHeight; + + canvas.width = sw * pixelRatio; + canvas.height = sh * pixelRatio; + canvas.style.width = sw + 'px'; + canvas.style.height = sh + 'px'; + ctx.scale(pixelRatio, pixelRatio); +} + +function generatePixi(bgcolor) { + renderer = new PIXI.Renderer({ + width: sw, + height: sh, + antialias: true, + transparent: false, + autoDensity: true, + resolution: pixelRatio,//window.devicePixelRatio > 1 ? 2 : 1, + powerPreference: "high-performance", + backgroundColor: bgcolor + }); + document.body.appendChild(renderer.view); + stage = new PIXI.Container(); + + window.addEventListener('resize', pixiResize, false); + pixiResize(); + + moveEvent(renderer.view); +} + +function pixiResize() { + sw = document.body.clientWidth; + sh = document.body.clientHeight; + + renderer.resize(sw, sh); +} + +function moveEvent(canvas) { + const hammer = new Hammer(canvas); + hammer.add(new Hammer.Pan({direction: Hammer.DIRECTION_ALL, threshold: 0})); + hammer.on("pan", (e) => { + moveX = e.deltaX + offsetX; + moveY = e.deltaY + offsetY; + if (e.isFinal) { + offsetX = moveX; + offsetY = moveY; + } + }); +} + +function getSize(size) { + let ratio = Math.sqrt(sw * sw + sh * sh) / 1800; + if (ratio > 1) ratio = 1; + else if (ratio < 0.5) ratio = 0.5; + return size * ratio; +} \ No newline at end of file