-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement fill-rule for path with libtess #29
- Loading branch information
Showing
25 changed files
with
399 additions
and
35 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<script setup> | ||
import { Path, TesselationMethod } from '@infinite-canvas-tutorial/core'; | ||
import '@infinite-canvas-tutorial/ui'; | ||
import { ref, onMounted } from 'vue'; | ||
import Stats from 'stats.js'; | ||
let canvas; | ||
const stats = new Stats(); | ||
stats.showPanel(0); | ||
const $stats = stats.dom; | ||
$stats.style.position = 'absolute'; | ||
$stats.style.left = '0px'; | ||
$stats.style.top = '0px'; | ||
const wrapper = ref(null); | ||
onMounted(() => { | ||
const $canvas = wrapper.value; | ||
if (!$canvas) return; | ||
$canvas.parentElement.appendChild($stats); | ||
$canvas.addEventListener('ic-ready', (e) => { | ||
canvas = e.detail; | ||
// fill-rule: nonzero | ||
const star1 = new Path({ | ||
d: 'M50 0 L21 90 L98 35 L2 35 L79 90 Z', | ||
fill: '#F67676', | ||
// wireframe: true, | ||
// tessellationMethod: TesselationMethod.EARCUT, | ||
tessellationMethod: TesselationMethod.LIBTESS, | ||
}); | ||
canvas.appendChild(star1); | ||
star1.position.x = 100; | ||
star1.position.y = 100; | ||
// fill-rule: evenodd | ||
const star2 = new Path({ | ||
d: 'M150 0 L121 90 L198 35 L102 35 L179 90 Z', | ||
fill: '#F67676', | ||
fillRule: 'evenodd', | ||
// wireframe: true, | ||
tessellationMethod: TesselationMethod.LIBTESS, | ||
// stroke: 'green', | ||
// strokeWidth: 2, | ||
}); | ||
canvas.appendChild(star2); | ||
star2.position.x = 300; | ||
star2.position.y = 100; | ||
}); | ||
$canvas.addEventListener('ic-frame', (e) => { | ||
stats.update(); | ||
}); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div style="position: relative"> | ||
<ic-canvas ref="wrapper" style="height: 200px"></ic-canvas> | ||
</div> | ||
</template> |
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
Oops, something went wrong.