-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed internal renderer to use independent instance
- Loading branch information
1 parent
43452ec
commit 1ba17f2
Showing
9 changed files
with
137 additions
and
45 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Multiple Verly.js</title> | ||
|
||
<style> | ||
* { | ||
box-sizing: border-box; | ||
color: #ce072e; | ||
} | ||
|
||
html, | ||
body { | ||
margin: 0; | ||
padding: 10px; | ||
} | ||
|
||
canvas { | ||
outline: 1px solid black; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
|
||
<script src="../../dist/verly.bundle.js"></script> | ||
|
||
<script src="./index.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
window.onload = function () { | ||
createInstance(800); | ||
createInstance(300); | ||
} | ||
|
||
|
||
|
||
function createInstance(w) { | ||
let canvas = document.createElement('canvas'); | ||
canvas.id = Math.random(); | ||
let ctx = canvas.getContext('2d'); | ||
let width = w; | ||
let height = 400; | ||
canvas.width = width; | ||
canvas.height = height; | ||
document.body.appendChild(canvas); | ||
|
||
const verly = new Verly(16, canvas, ctx); | ||
|
||
let box = verly.createBox(100, 100, 100, 100); | ||
let hexagon = verly.createHexagon(100, 100, 18, 50); | ||
console.log(box) | ||
// // rendering | ||
box.renderSticks = () => { | ||
for (let i = 0; i < box.sticks.length; i++) { | ||
let stick = box.sticks[i]; | ||
ctx.beginPath(); | ||
ctx.strokeStyle = 'green' | ||
ctx.moveTo(stick.startPoint.pos.x, stick.startPoint.pos.y); | ||
ctx.lineTo(stick.endPoint.pos.x, stick.endPoint.pos.y); | ||
ctx.stroke(); | ||
ctx.closePath(); | ||
} | ||
} | ||
|
||
function animate() { | ||
ctx.clearRect(0, 0, width, height); | ||
|
||
verly.update(); | ||
// verly.render(); | ||
|
||
box.render(ctx); | ||
box.renderPointIndex(ctx); | ||
hexagon.render(ctx); | ||
hexagon.renderPointIndex(ctx); | ||
|
||
verly.interact(); | ||
|
||
// verly.renderPointIndex(); | ||
|
||
requestAnimationFrame(animate); | ||
} | ||
animate(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters