Build reactive 2D graphics scene with vue
vue-pencil.js
Pencil.js - Build reactive 2D graphics scene in your Vue project.
Install
npm install vue-pencil.js
You need to install
vue
andpencil.js
yourself alongsidevue-pencil.js
.
Usage
You have 3 choices:
- Install
vue-pencil.js
globally and use it wherever you want in yourVuejs
app. - Import only components you need in your
Vuejs
components. - Use a direct
<script>
tag to include from a CDN.
1. Global install
import Vue from "vue";
import Pencil from "vue-pencil.js";
const options = {
prefix: "p", // Change the component's prefix (default: "p")
};
Vue.use(Pencil, options);
new Vue({
el: "#app",
template: `
<p-scene>
<p-circle :radius="100" :position="[100, 100]" />
</p-scene>
`,
});
2. Import component
<template>
<PScene>
<PCircle :radius="100" :position="[100, 100]" />
</PScene>
</template>
<script>
import { Components } from "vue-pencil.js";
const { PScene, PCircle } = Components;
export default {
name: "App",
components: {
PScene,
PCircle,
},
};
</script>
3. Direct <script>
tag
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example</title>
</head>
<body>
<div id="app"></div>
<!-- Vue script tag-->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<!-- vue-pencil.js script tag-->
<script src="https://unpkg.com/vue-pencil.js"></script>
<script>
new Vue({
el: "#app",
template: `
<p-scene>
<p-circle :radius="100" :position="[100, 100]" />
</p-scene>
`,
});
</script>
</body>
</html>