Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danzen/zimjs
ZIM JavaScript Canvas Framework - Code Creativity! Interactive Media For All.
https://github.com/danzen/zimjs
canvas canvas-framework creativity javascript learn-to-code learning teaching zim zimjs
Last synced: 6 days ago
JSON representation
ZIM JavaScript Canvas Framework - Code Creativity! Interactive Media For All.
- Host: GitHub
- URL: https://github.com/danzen/zimjs
- Owner: danzen
- License: other
- Created: 2014-11-25T03:28:27.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-10-28T03:00:40.000Z (11 days ago)
- Last Synced: 2024-10-28T05:35:17.841Z (11 days ago)
- Topics: canvas, canvas-framework, creativity, javascript, learn-to-code, learning, teaching, zim, zimjs
- Language: JavaScript
- Homepage:
- Size: 11.2 MB
- Stars: 507
- Watchers: 34
- Forks: 47
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-game-engine-dev - ZIM - Creative canvas framework. [[Website](https://zimjs.com/)] (Libraries / JavaScript)
README
# ZIM
JavaScript Canvas Framework - Code Creativity!
https://zimjs.comA consistent, complete, simple and colorful Canvas Framework that provides quick visual results. ZIM is great for learning to code but also powerful for professionals to make games, apps, art and more for desktop and mobile!
Please see the About section for why we use ZIM to make Interactive Media.
https://zimjs.com/about.html## Examples
![zim](https://github.com/danzen/zimjs/assets/380281/af5c1e20-9f74-4b60-81f8-4ca1052ef16a)
ZIM is great for games, puzzles, art, visualizations, interfaces and more! See:
https://zimjs.com/examples.htmlCoding in ZIM looks like this:
```javascript
new Rectangle(50, 50, green).center().drag(); // for a centered draggable rectangle!new MotionController(new Emitter().center(), "mousemove"); // for a particle emitter following the mouse
const squiggle = new Squiggle().loc(100, 100); // wavy line with Bezier handles
new Circle(20, pink).addTo().animate({path:squiggle}, 1); // animate along a squigglenew Button(200, 70, "TRY ME")
.pos(30,30,RIGHT,BOTTOM)
.tap(()=>{zgo("https://zimjs.com");}); // go to URL
```
![zim2](https://github.com/danzen/zimjs/assets/380281/f318c755-7dd2-43ed-8bf0-ead77ec40b23)
![npm](https://img.shields.io/npm/v/zimjs.svg)
![GitHub](https://img.shields.io/badge/license-MIT-green.svg)
[![Discord](https://img.shields.io/discord/782972112646307881)](https://discord.com/invite/KczUuFkZdk)
[![Discourse](https://img.shields.io/badge/discourse-forum-brightgreen.svg)](https://forum.zimjs.com)## Getting Started
Copy the template on the Code page into an editor like VS Code and view results in any Browser.
https://zimjs.com/code.htmlThis uses ES6 Modules or Script tags from our CDN at https://zimjs.org/cdn
Alternatively, see the NPM instructions in the section down below.ZIM EDITOR - an online editor with lots of examples, file saving and sharing
https://zimjs.com/editorZIM INTRO - sample code with comments
https://zimjs.com/intro.htmlZIM BASICS - video series on YouTube
https://www.youtube.com/watch?v=G4K0PwtwXRQ&list=PLCIzupgRt1pYPy1ufRjssbGuPKMviuFvBZIM CODEPEN TOPIC
https://codepen.io/topic/zim/ZIM LEARN has many code and video tutorials including:
ZIM Bits - 64 common techniques, ZIM Capture, What IZ tutorials, ZIM Badges, Code Zero and more!
https://zimjs.com/learn.htmlZIM SKOOL is great for learning with 8 full lessons including in Browser code examples.
https://zimjs.com/skool.html and for kids https://zimjs.com/kids.html - like Magic!LEARN JAVASCRIPT WITH CREATIVE CODING
https://zimjs.com/learnjavascript.htmlZIM TIPS has a listing of the elegant ways we code in ZIM
https://zimjs.com/tips.htmlZIM DOCS has all the Classes and Functions broken down by module - expand the topics
to see descriptions, examples, methods, properties, events, source, bits, vids, demos and more!
https://zimjs.com/docs.html## NPM
Here is ZIM on NPM: https://www.npmjs.com/package/zimjs
There are additional helper modules matching the CDN helper modules:
@zimjs/physics |
@zimjs/game |
@zimjs/three |
@zimjs/socket |
@zimjs/cam |
@zimjs/pizzazz
These steps describe setting up ZIM with Vite and NPM for vanilla JavaScript or TypeScript.
There are also templates for VUE, Svelte, React and Angular further down.A. SETUP
- Open a folder in an IDE such as VS Code (The project folder will be made inside this folder)
- Open a terminal - see Terminal in the menu - or CTRL SHIFT `
- Check to see if you have node - type:node - v
- If not then install from https://nodejs.org
- Run Vite - type:npm create vite
- If this needs to install, press y for yes
- Give the project a name - it will make a directory
- Select a framework - use arrow to see all options
- Eg. choose Vanilla
- Select a variant
- Eg. choose JavaScript
- Change to your project folder - type:cd yourProject
- Get the ZIM package and dependencies - type:npm i zimjsB. TEMPLATE
- replace the code in main.js with the template:
```javascript
// ZIM - JavaScript Canvas Framework - https://zimjs.com - code creativity
import zim from "zimjs";// make ZIM global - if this is not used then would use zim.Frame() and zim.Circle()
zimplify();// or make all globals except need to use zim.Blob and zim.Window
// these are two classes that have occassionally conflicted with other libraries
// zimplify(["Blob", "Window"]);// See Docs under Frame for FIT, FILL, FULL, and TAG
new Frame(FIT, 1024, 768, light, dark, ready);
function ready() {
// given F (Frame), S (Stage), W (width), H (height)
// put code here
new Circle(100, purple)
.center()
.drag();
} // end ready
```
- or with TypeScript - replace the src/main.ts code with:
```javascript
// ZIM - JavaScript Canvas Framework - https://zimjs.com - code creativity
import {Frame, Circle} from "zimjs";// See Docs under Frame for FIT, FILL, FULL, and TAG
new Frame(FIT, 1024, 768, light, dark, ready);
function ready() {
// given F (Frame), S (Stage), W (width), H (height)
// put code here
new Circle(100, purple)
.center()
.drag();
} // end ready
```
- In the index.html file, optionally replace the Vite icon with:
```html```
- Replace the title with your app titleC. DEVELOPMENT
- Start a Dev server - type:npm run dev
- Alt-click the Local link in the terminal
- This opens up a browser to see the file with the purple circle
- Make edits to your ZIM app
- See https://zimjs.com/learn for how to use ZIM
- See https://zimjs.com/docs for reference to commands
- When done developing use CTRL C to exit the dev terminalD. DEPLOYMENT
- Bundle the files for distribution - type:npm run build
- This makes a dist/ folder with the minified code
- Currently, Vite puts the js code in /assets/
- Which means to run it in a browser, it needs to be in the root
- Or you can remove the / and use assets/ to run relatively
- like with "open in default browser" extension locally
- For local images and sounds see https://zimjs.com/tips.html#IMAGESE. NOTICE
- ZIM is a front-end framework at https://zimjs.com
- We make so much without npm at all...
- You can avoid all of the above by going to https://zimjs.com/code
- pressing the copy button and pasting into an empty html file
- Then view the html file in a browser
- This takes 1 minute and kids can do it
- You can also use ZIM online at https://zimjs.com/editorF. OTHER FRAMEWORKS
- See the sections below for using ZIM with other frameworks
- The setup is the same as above but the app code is as follows## VUE, SVELTE, REACT, ANGULAR
![html_JavaScript_Frameworks](https://github.com/danzen/zimjs/assets/380281/318f3b45-8a27-45f4-886c-62706e0f2b93)
ZIM can be used in other frameworks. Thank you @yoanhg421 for the setup
See https://github.com/danzen/zimjs-templates for full files.
Follow the SETUP instructions above and then adjust the code as follows:
### VUE - with zim namespace
```javascript
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();
});
```
### VUE - without zim namespace
```javascript
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 Circle(50, red).center().drag();
}
});
});onBeforeUnmount(() => {
frame.dispose();
});
```
### SVELTE - with zim namespace and Typescript
```javascript
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();
});
```
### SVELTE - without zim namespace and no Typescript
```javascript
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 Circle(50, red).center().drag();
}
});
});onDestroy(() => {
frame.dispose();
});
```
### REACT - with zim namespace
```javascript
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 (
<>
{/* Move StrictMove from the root to here */}
{/* Include ZIM code outside StrictMode */}
>
)
}
export default App;
```
### REACT - without zim namespace
```javascript
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 (
<>
{/* Move StrictMove from the root to here */}
{/* Include ZIM code outside StrictMode */}
>
)
}
export default App;
```
### ANGULAR - with zim namespace and TypeScript (always)
```javascript
import { AfterContentInit, Component, OnDestroy } from '@angular/core';
import { Frame, Circle } from 'zimjs';@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnDestroy, AfterContentInit {
frame: Frame | undefined;
ngOnDestroy(): void {
this.frame?.dispose();
}ngAfterContentInit(): void {
this.frame = new Frame({
scaling: FIT,
width: 600,
height: 300,
ready: () => {
new Circle(50, red).center().drag();
},
});
}title = 'ZIM in Angular';
}
```## Issues & Community
You are welcome to add issues here but we tend to use our Forum for issues and support
We would love to see you there!
https://forum.zimjs.com
You are welcome to join us on Discord as well
https://zimjs.com/discord
An easy view of updates can be found here:
https://zimjs.com/updates.html## Dependencies
ZIM is powered by the robust CreateJS Library and adds many conveniences, components and controls.
Cheers to Grant, Lanny and the CreateJS Team!
https://createjs.com - here is the ZIM version of CreateJS
## Authors
* **Dr Abstract (Inventor Dan Zen)**
Canadian New Media Awards Programmer of the Year
Canadian New Media Awards Educator of the Year
https://zimjs.com/interactivemedia
Hamilton Arts Awards for Media Arts
http://danzen.com - Museum of Interactive Works## License
This project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details## Acknowledgments
* Thanks to the folks here and on Slack with reports, requests and enthusiasm!
* Thanks Sheridan College and the Interactive Media Post Grad Program for the testing grounds!
* Thanks to family for keeping me active in the "real world"
* Thanks for giving us a STAR on GitHub!