Browse Source

Add files via upload

pull/3/head
Jongmin Kim 5 years ago committed by GitHub
parent
commit
e542c8b317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. BIN
      examples/data/branch_circle.png
  2. BIN
      examples/data/branch_long.png
  3. BIN
      examples/data/drop-alpha.png
  4. BIN
      examples/data/flower1.png
  5. BIN
      examples/data/flower2.png
  6. BIN
      examples/data/flower3.png
  7. BIN
      examples/data/leaf1.png
  8. BIN
      examples/data/leaf2.png
  9. BIN
      examples/data/tile1.png
  10. BIN
      examples/data/tile2.png
  11. BIN
      examples/data/tile3.png
  12. BIN
      examples/data/tile4.png
  13. BIN
      examples/data/tile5.png
  14. BIN
      examples/data/tile6.png
  15. 75
      examples/js/util.js

BIN
examples/data/branch_circle.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
examples/data/branch_long.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
examples/data/drop-alpha.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
examples/data/flower1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
examples/data/flower2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
examples/data/flower3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
examples/data/leaf1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

BIN
examples/data/leaf2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
examples/data/tile1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
examples/data/tile2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
examples/data/tile3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
examples/data/tile4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
examples/data/tile5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
examples/data/tile6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

75
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;
}
Loading…
Cancel
Save