![](https://private-user-images.githubusercontent.com/380281/307906083-85f60a84-2835-4cb7-90bf-9087a68e7295.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNzk1NTgsIm5iZiI6MTczOTI3OTI1OCwicGF0aCI6Ii8zODAyODEvMzA3OTA2MDgzLTg1ZjYwYTg0LTI4MzUtNGNiNy05MGJmLTkwODdhNjhlNzI5NS5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjExJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMVQxMzA3MzhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iN2YwMTJmY2RkZmM0NDA3NTVlYWE3Y2Q5YTA2NmI3OTc2NGY1NTViOTg2Njg0NDdmNDE2YzgwZmI0ZGJkMzllJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9._ju3sKGy_bk1eiHEXHgRZWfpVRtJuMca6Tqht4Mtytw)
Here are NPM templates to add ZIM to Vue, React, Svelte and Angular using NPM.
Useful links:
- https://zimjs.com
- https://www.npmjs.com/package/zimjs
- https://github.com/danzen/zimjs
- https://zimjs.slack.com
- Download the CODE (green button on main page)
- Unzip, copy a desired template folder, and rename it
- Drop the folder on an editor such as VS Code.
- Open a terminal (CTRL ` )
If you are using React, Vue, Svelte
- Run
npm install
- Run
npm run dev
If you are have Angular and haven't done so already, install it globally by running
npm install -g @angular/cli
- Run
npm install
- Run
ng serve
And you are good to go.
The ZIM Helper Modules are available here:
@zimjs/physics | @zimjs/game | @zimjs/three | @zimjs/cam | @zimjs/pizzazz
Follow the instructios on the NPM page
If you have a project that doesn't use typescript you can use the samples below to add ZIM to your project
<script setup>
import { onMounted, onBeforeUnmount } from "vue";
import zim from "zimjs";
let frame;
onMounted(() => {
frame = new zim.Frame({
scaling: "zim",
width: 500,
height: 400,
color:light,
ready: () => {
// put code here
new zim.Circle(50, red).center().drag();
}
});
});
onBeforeUnmount(() => {
frame.dispose();
});
</script>
<template>
<div id="zim"></div>
</template>
<style>
</style>
<script setup>
import { onMounted, onBeforeUnmount } from "vue";
import zim from "zimjs";
zim.zimplify(); // make zim commands global
let frame;
onMounted(() => {
frame = new Frame({
scaling: "zim",
width: 500,
height: 400,
color:light,
ready: () => {
// put code here
new zim.Circle(50, red).center().drag();
}
});
});
onBeforeUnmount(() => {
frame.dispose();
});
</script>
<template>
<div id="zim"></div>
</template>
<style>
</style>
<script >
import { onMount, onDestroy } from "svelte";
import zim from "zimjs";
let frame: Frame;
onMount(() => {
frame = new zim.Frame({
scaling: "zim",
width: 500,
height: 400,
color:light,
ready: () => {
// put code here
new zim.Circle(50, red).center().drag();
}
});
function ready() {
// put code here
new zim.Circle(50, red).center().drag();
}
});
onDestroy(() => {
frame.dispose();
});
</script>
<main>
<div id="zim">
</main>
<style>
</style>
<script>
import { onMount, onDestroy } from "svelte";
import zim from "zimjs";
zim.zimplify(); // make zim commands global
let frame;
onMount(() => {
frame = new Frame({
scaling: "zim",
width: 500,
height: 400,
color:light,
ready: () => {
// put code here
new zim.Circle(50, red).center().drag();
}
});
});
onDestroy(() => {
frame.dispose();
});
</script>
<main>
<div id="zim">
</main>
<style>
</style>
<script>
import { Component, ReactNode, StrictMode } from "react";
import "./App.css";
import zim from "zimjs";
class ZimFrame extends Component {
frame: zim.Frame | undefined;
componentDidMount(): void {
this.frame = new zim.Frame({
scaling: "zim",
width: 500,
height: 400,
color:light,
ready: () => {
// put code here
new zim.Circle(50, red).center().drag();
}
});
}
componentWillUnmount(): void {
this.frame?.dispose();
}
render(): ReactNode {
return null;
}
}
function App() {
return (
<>
<div>
{/* Move StrictMove from the root to here */}
<StrictMode>
<div id='zim'></div>
</StrictMode>
{/* Include ZIM code outside StrictMode */}
<ZimFrame />
</div>
</>
)
}
export default App;
</script>
<script>
import { Component, ReactNode, StrictMode } from "react";
import "./App.css";
import zim from "zimjs";
zim.zimplify(); // make zim commands global
class ZimFrame extends Component {
frame: Frame | undefined;
componentDidMount(): void {
this.frame = new Frame({
scaling: "zim",
width: 500,
height: 400,
color:light,
ready: () => {
// put code here
new Circle(50, red).center().drag();
}
});
}
componentWillUnmount(): void {
this.frame?.dispose();
}
render(): ReactNode {
return null;
}
}
function App() {
return (
<>
<div>
{/* Move StrictMove from the root to here */}
<StrictMode>
<div id='zim'></div>
</StrictMode>
{/* Include ZIM code outside StrictMode */}
<ZimFrame />
</div>
</>
)
}
export default App;
</script>
Dr Abstract @danzen