0.0.7 • Published 2 years ago

p5vue v0.0.7

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

Usage

Install:

npm i p5vue
npm i -D p5

Now add p5vue to your project:

  • Import the Plugin to your main.js file

    // main.js || main.ts
    import { createApp } from "vue"
    import App from "./App.vue"
    
    import p5vue from "p5vue"
    
    createApp(App).use(p5vue).mount("#app")
  • Use the P5 component inside the app

    <script setup>
    import p5 from "p5"
    
    const sketch = (p5) => {
      p5.setup = () => {
        p5.createCanvas(500, 500)
      }
    
      p5.draw = () => {
        p5.background("#fff000")
      }
    }
    </script>
    
    <template>
    	<P5 :sketch="sketch"/>
    </template>

Output:

Typescript:

Typescript inst fully supported yet. To get the Plugin working without type errors do this:

  • // main.ts
    import { createApp } from "vue"
    import App from "./App.vue"
    // @ts-ignore
    import p5vue from "p5vue"
    
    createApp(App).use(p5vue).mount("#app")
  • // Add the p5 type in function argument
    <script setup>
    import p5 from "p5"
    
    const sketch = (p5: p5) => {
      p5.setup = () => {
        p5.createCanvas(500, 500)
      }
    
      p5.draw = () => {
        p5.background("#fff000")
      }
    }
    </script>
    
    <template>
    	<P5 :sketch="sketch"/>
    </template>
0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago