Skip to content

Pencil.js ❤️ Vue - Build reactive 2D graphics scene in your Vue project

License

Notifications You must be signed in to change notification settings

pencil-js/vue-pencil.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-pencil.js logo

vue-pencil.js

Pencil.js ❤️ Vue - Build reactive 2D graphics scene in your Vue project

Install

npm install vue-pencil.js

You need to install vue and pencil.js yourself alongside vue-pencil.js.

Usage

You have 3 choices:

  1. Install vue-pencil.js globally and use it wherever you want in your Vuejs app.
  2. Import only components you need in your Vuejs components.
  3. 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://unpkg.com/vue"></script>
    <!-- Pencil.js script tag-->
    <script src="https://unpkg.com/pencil.js"></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>

Example

Check out working examples in the examples directory.

Contributing

Any contribution abiding to the code of conduct is welcome.

License

MIT