Build Reactive 2d Graphics Scene with Vue

Build Reactive 2d Graphics Scene with Vue

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

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://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>

Example

Check out working examples in the examples directory.

Contributing

Any contribution abiding to the code of conduct is welcome.

Download Details:

Author: pencil-js

Source Code: https://github.com/pencil-js/vue-pencil.js

vuejs vue javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

8 Popular Websites That Use The Vue.JS Framework

In this article, we are going to list out the most popular websites using Vue JS as their frontend framework. Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.

Vue Native is a framework to build cross platform native mobile apps using JavaScript

Vue Native is a framework to build cross platform native mobile apps using JavaScript. It is a wrapper around the APIs of React Native. So, with Vue Native, you can do everything that you can do with React Native. With Vue Native, you get

How to Make a Simple Vue Custom Select Component

In this article, you’ll learn how to build a Vue custom select component that can be easily be styled using your own CSS. In fact, it’s the same component that we use in production on Qvault, and you can see it in action on the playground.

Creating a Custom Tooltip Component in Vue

There are plenty of libraries out there that will have you up and running with a good tooltip solution in minutes. However, if you are like me, you are sick and tired of giant dependency trees that have the distinct possibility of breaking at any time.

Vue ShortKey plugin for Vue.js

Vue-ShortKey - The ultimate shortcut plugin to improve the UX .Vue-ShortKey - plugin for VueJS 2.x accepts shortcuts globaly and in a single listener.