Giter Site home page Giter Site logo

danzen / zimjs Goto Github PK

View Code? Open in Web Editor NEW
472.0 33.0 47.0 11.21 MB

ZIM JavaScript Canvas Framework - Code Creativity! Interactive Media For All.

License: Other

JavaScript 100.00%
javascript canvas-framework zim zimjs canvas creativity learn-to-code teaching learning

zimjs's Introduction

ZIM

JavaScript Canvas Framework - Code Creativity!
https://zimjs.com

A 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

ZIM is great for games, puzzles, art, visualizations, interfaces and more! See:
https://zimjs.com/examples.html

Coding in ZIM looks like this:

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 squiggle

new Button(200, 70, "TRY ME")
  .pos(30,30,RIGHT,BOTTOM) 
  .tap(()=>{zgo("https://zimjs.com");}); // go to URL
  

zim2

npm GitHub Discord Discourse

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.html

This 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/editor

ZIM INTRO - sample code with comments
https://zimjs.com/intro.html

ZIM BASICS - video series on YouTube
https://www.youtube.com/watch?v=G4K0PwtwXRQ&list=PLCIzupgRt1pYPy1ufRjssbGuPKMviuFvB

ZIM 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.html

ZIM 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.html

ZIM TIPS has a listing of the elegant ways we code in ZIM
https://zimjs.com/tips.html

ZIM 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 zimjs

B. TEMPLATE

  • replace the code in main.js with the template:
// 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:
// 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:
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="https://zimjs.com/icons/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="https://zimjs.com/icons/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="https://zimjs.com/icons/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="https://zimjs.com/icons/apple-touch-icon-144x144.png" />
<link rel="apple-touch-icon-precomposed" sizes="60x60" href="https://zimjs.com/icons/apple-touch-icon-60x60.png" />
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="https://zimjs.com/icons/apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="https://zimjs.com/icons/apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://zimjs.com/icons/apple-touch-icon-152x152.png" />
<link rel="apple-touch-icon-precomposed" sizes="180x180" href="https://zimjs.com/icons/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="https://zimjs.com/icons/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="192x192" href="https://zimjs.com/icons/android-chrome-192x192.png" />
<link rel="icon" type="image/png" sizes="512x512" href="https://zimjs.com/icons/android-chrome-512x512.png" />
  • Replace the title with your app title

C. 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
  • When done developing use CTRL C to exit the dev terminal

D. 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#IMAGES

E. 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/editor

F. 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

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

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

VUE - without zim namespace

<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 Circle(50, red).center().drag();
      }
    });
  });

  onBeforeUnmount(() => {
    frame.dispose();
  });  
</script>

<template>
  <div id="zim"></div>
</template>

<style>
</style>

SVELTE - with zim namespace and Typescript

<script lang="ts">  
  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>

SVELTE - without zim namespace and no Typescript

<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 Circle(50, red).center().drag();
      }
    });
  });

  onDestroy(() => {
    frame.dispose();
  });
</script>

<main>
  <div id="zim">
</main>

<style>
</style>

REACT - with zim namespace

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;

REACT - without zim namespace

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;

ANGULAR - with zim namespace and TypeScript (always)

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

License

This project is licensed under the MIT License - see the 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!

zimjs's People

Contributors

backwardsuser avatar danzen avatar mhajder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zimjs's Issues

accessing an image from a spritesheet by name?

Hey this is the most awesome library for making kids apps in JS that I think EXISTS!!! Thank you!!!

I made a TexturePacker json/image spritesheet and threw the json into a JS file as an object so I could reference it easier - I have the letters of the alphabet laid out, just static for now. I wanted to pack a few other spritesheets with misc images and figure this should be pretty easy - I must be missing something! My data is here:

`var alphabetRegularResolution = {
"images": [
"alphabet-0.png"
],
"frames": [
[1, 1, 240, 241, 0, -5, -5],
[243, 1, 240, 240, 0, -5, -5],
[485, 1, 240, 240, 0, -5, -5],
[727, 1, 240, 241, 0, -5, -5],
[1, 244, 240, 240, 0, -5, -4],
[243, 244, 240, 241, 0, -5, -5],
[485, 244, 240, 241, 0, -5, -5],
[727, 244, 240, 241, 0, -5, -5],
[1, 487, 240, 241, 0, -5, -5],
[243, 487, 240, 241, 0, -5, -5],
[485, 487, 240, 241, 0, -5, -5],
[727, 487, 240, 241, 0, -5, -5],
[1, 730, 240, 241, 0, -5, -5],
[243, 730, 240, 241, 0, -5, -5],
[485, 730, 240, 241, 0, -5, -5],
[727, 730, 240, 241, 0, -5, -5],
[1, 973, 240, 241, 0, -5, -5],
[243, 973, 240, 241, 0, -5, -5],
[485, 973, 240, 241, 0, -5, -5],
[727, 973, 240, 241, 0, -5, -5],
[1, 1216, 240, 241, 0, -5, -5],
[243, 1216, 240, 241, 0, -5, -5],
[485, 1216, 240, 241, 0, -5, -5],
[727, 1216, 240, 241, 0, -5, -5],
[1, 1459, 240, 241, 0, -5, -5]
],
"animations": {
"a": { "frames": [0] },
"b": { "frames": [1] },
"c": { "frames": [2] },
"d": { "frames": [3] },
"e": { "frames": [4] },
"f": { "frames": [5] },
"g": { "frames": [6] },
"h": { "frames": [7] },
"i": { "frames": [8] },
"j": { "frames": [9] },
"k": { "frames": [10] },
"l": { "frames": [11] },
"m": { "frames": [12] },
"n": { "frames": [13] },
"o": { "frames": [14] },
"p": { "frames": [15] },
"q": { "frames": [16] },
"r": { "frames": [17] },
"s": { "frames": [18] },
"t": { "frames": [19] },
"u": { "frames": [20] },
"v": { "frames": [21] },
"w": { "frames": [22] },
"x": { "frames": [23] },
"z": { "frames": [24] }
},

"texturepacker": [
"SmartUpdateHash: $TexturePacker:SmartUpdate:79a38008ef9a27f6aaab4db36f052401:f6383cfc6f9d22762e8601b5a194da83:615a9b210f7a1e092bb53bb63749870a$",
"Created with TexturePacker (https://www.codeandweb.com/texturepacker) for EaselJS"
]

}`

And I'm trying this to load it:

frame.loadAssets(["alphabet-0.png", "bg.png"], "sprites/"); frame.on("complete", function() { waiter.hide(); frame.asset("bg.png").addTo(stage); var animation = new zim.Sprite({json:alphabetRegularResolution}); zog(animation); })

Can you see what I need to do to access just the 'a'? I tried

var animation = new zim.Sprite({json:alphabetRegularResolution}, 'a');

But this is a no go in Zim. I tried using some createJS methods but couldn't get anything to show up on the stage.

Seems this must be here and I just missed how to do it! Thanks for this library - I am making a kids app for learning to read visually, for autistic and other kids who have trouble with phonics, and this is exactly the kind of thing to make the app shine.

2 bugs found.

1,window constructor parameter: scrollBarActive =false, will cause a error bug.
2,custom list item has a background rectangle with amost transparent white color(maybe "fcfcfc"), it's very hard to see ,but it looks buggy.

centerReg() does not working on ZimJS version 10

Hi,

Im using ZimJS with tag ZIM10 in order to create a isometric world map.

This is my code:

<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>ZIM Frame - Fit Template</title>

<script src="https://d309knd7es5f10.cloudfront.net/createjs_1.1_min.js"></script>
<script>
   var zon = true;
   var zns = false;
</script>
<script src="zimjs.js"></script>
<script>

var scaling = "full"; // this will resize to fit inside the screen dimensions
var width = 1920;
var height = 1080;
var color = light; // ZIM colors like green, blue, pink, faint, clear, etc.
var outerColor = dark; // any HTML colors like "violet", "#333", etc. are fine to use

var frame = new Frame(scaling, width, height, color, outerColor);

frame.on("ready", function() {
   zog("ready from ZIM Frame"); // logs in console (F12 - choose console)

   var stage = frame.stage;
   var stageW = frame.width;
   var stageH = frame.height;

   var holder = new Container();
   var tile = new Tile(new Rectangle(50, 50, frame.light, frame.dark).centerReg(null, null, false), 8, 8)
     .rot(45)
     .addTo(holder)
     .outline();

   holder.sca(2, 1).center();

   tile.on("mouseover", function(e) {
     e.target.color = frame.pink;
     stage.update();
   });

   tile.on("mouseout", function(e) {
     e.target.color = frame.light;
     stage.update();
   });

   var ball = new Circle(40, frame.blue, frame.dark).center().sha();

   tile.on("click", function(e){
     var point = tile.localToGlobal(e.target.x, e.target.y);
     ball.pos(point.x, point.y);
     stage.update();
   });

   stage.update(); // this is needed to show any changes

}); // end of ready

</script>

<meta name="viewport" content="width=device-width, user-scalable=no" />

</head>

<body>
<!-- canvas with id="myCanvas" is made by zim Frame -->
</body>
</html>

But is not centering the registration point for the tile. In the tagged version ZIM7 is working fine but in the ZIM10 does not.

Its showing like this:
view screenshoot
Can you tell me what can i do in order to get the registration point in the center of the tile?

Thanks

Render to Three JS Canvas Texture

Can you provide an example of how a zim canvas can be mapped into a three js canvas texture?

I tried getting the canvas from the Frame and using it in THREE.CanvasTexture, but ZIM wants to take up the full screen. I want it to appear as a texture in the plane

Here's the codepen
Thanks

import zim from "https://zimjs.org/cdn/02/zim";


const z = new Frame(FILL, 256, 256, light, dark, ready);
function ready() {

    F.makeIcon(null,dark)
		.sca(2)
		.centerReg()
	
	F.madeWith().pos(40,40,RIGHT,BOTTOM);
	
} // end ready

import { } from "https://unpkg.com/three";

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
  75,
  window.innerWidth / window.innerHeight,
  0.1,
  1000
);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

// ****
const canvastexture = new THREE.CanvasTexture(z.canvas)

const geometry = new THREE.PlaneGeometry();
const material = new THREE.MeshBasicMaterial({ map: canvastexture });

const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
camera.position.z = 5;
const animate = () => {
  requestAnimationFrame(animate);
  renderer.render(scene, camera);
};
animate();```

access to plasma zapp not working

I click to 'login to start', log in, and I stay blocked to the page 'you're currently logged as' (cf screenshot). Tried on mac/chrome and iphone/safari, same problem.
Capture d’écran 2023-07-06 à 11 59 50

Request a Free Transform Tool

A free transform tool, that let the user option to scale, rotation and postion the items, with the little squares in the corners. - Ami from Slack

Zim.Frame("tagID") does not work well.

When I set Frame parameters tagID in version 10.5.4, it alerts "Uncaught DOMException: Failed to read the 'rules' property from 'CSSStyleSheet': Cannot access rules".
But it works well in 9.4.1 version.

Zog Barking

playing with Zim soundwave and my console's getting flooded, even with zon=false,

line 18425 missing a zon check -
zog(dataArray)
should read?
if (zon) zog(dataArray);

Enjoying the library, videos, docs etc - thanks for all your hard work.

Keyboard Updating Labels

I am trying to listen event

frame.on("keydown", function(e) {       
     if(k.selectedLabel == label1) {
         k.selectedLabel.text += e.key;
         k.selectedIndex++; //not working!
         stage.update(); 
     }
  })

Perhaps make all the functions inside keyboard available to public access.
That would allow me to directly call positionBlinker() or addToLabel(e.key)

It's great that it's possible to do all this great functionality with a virtual keyboard, but not why enable the real keyboard into this as well? Thank you.

Dial limit:False property not working with arrow keys

When using a dial and setting the limit property to false we are unable to use the arrow keys to make the dial go past the maximum value.

Using ZimJS 6.6.3 for this example.

Example dial code:
let horDial = new Dial({ width: 65, limit: false, useTicks: false, indicatorType: "dot", indicatorScale: .75, color: "#fff" })

Refactoring code

this is a powerfull and a rich Canvas Wrapper we like it and we want help you improve it ..but first
it will be more scalable and maintainable library by adding a good code Structure with refactoring the main code and redesign it with sub-module concept (Frame module, Animation Module, Physics module ...)
thank u Dan for your great effort .

bug report: SVGContainer("xxx.svg") parse error, but bitmap ("xxx.svg") works.

Uncaught TypeError: Cannot read property 'trim' of undefined
at zim.js:1596
at go.loop (zim.js:10731)
at C (zim.js:1593)
at L (zim.js:1712)
at k (zim.js:1730)
at zim.js:1696
at Object.go.loop (zim.js:10732)
at c (zim.js:1694)
at zim.js:1704
at Object.go.loop (zim.js:10732)

here is my svg file:

<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24pt" height="22pt" viewBox="0 0 24 22" version="1.1"> <defs> <g> <symbol overflow="visible" id="glyph0-0"> <path style="stroke:none;" d="M 0.984375 -16.546875 L 19.0625 -16.546875 L 19.0625 -19.09375 L 0.921875 -19.09375 L 0.921875 -16.546875 Z M 0.984375 -12.265625 L 19.0625 -12.265625 L 19.0625 -14.8125 L 0.921875 -14.8125 L 0.921875 -12.265625 Z M 0.984375 -8 L 19.0625 -8 L 19.0625 -10.546875 L 0.921875 -10.546875 L 0.921875 -8 Z M 0.984375 -3.71875 L 19.0625 -3.71875 L 19.0625 -6.265625 L 0.921875 -6.265625 L 0.921875 -3.71875 Z M 0.984375 0.546875 L 19.0625 0.546875 L 19.0625 -2 L 0.921875 -2 L 0.921875 0.546875 Z M 0.984375 4.828125 L 19.0625 4.828125 L 19.0625 2.28125 L 0.921875 2.28125 L 0.921875 4.828125 Z M 0.984375 4.828125 "/> </symbol> <symbol overflow="visible" id="glyph0-1"> <path style="stroke:none;" d="M 3 -6.9375 C 3.328125 -6.9375 3.625 -7.09375 3.84375 -7.3125 L 5.0625 -8.421875 L 5.0625 0.28125 C 5.0625 1.734375 5.984375 2.609375 7.46875 2.609375 L 20.21875 2.609375 C 21.71875 2.609375 22.625 1.734375 22.625 0.28125 L 22.625 -8.421875 L 23.84375 -7.3125 C 24.078125 -7.09375 24.375 -6.9375 24.703125 -6.9375 C 25.265625 -6.9375 25.75 -7.328125 25.75 -7.875 C 25.75 -8.203125 25.625 -8.46875 25.375 -8.703125 L 21.84375 -11.921875 L 21.84375 -17.796875 C 21.84375 -18.21875 21.515625 -18.53125 21.078125 -18.53125 L 19.5 -18.53125 C 19.0625 -18.53125 18.71875 -18.21875 18.71875 -17.796875 L 18.71875 -14.78125 L 15.265625 -17.90625 C 14.859375 -18.296875 14.34375 -18.5 13.84375 -18.5 C 13.34375 -18.5 12.828125 -18.296875 12.421875 -17.90625 L 2.328125 -8.703125 C 2.0625 -8.46875 1.9375 -8.203125 1.9375 -7.875 C 1.9375 -7.328125 2.4375 -6.9375 3 -6.9375 Z M 16.734375 -5.796875 C 16.734375 -6.265625 16.40625 -6.578125 15.953125 -6.578125 L 11.765625 -6.578125 C 11.296875 -6.578125 10.953125 -6.265625 10.953125 -5.796875 L 10.953125 0.609375 L 8 0.609375 C 7.390625 0.609375 7.09375 0.296875 7.09375 -0.3125 L 7.09375 -10.28125 L 13.578125 -16.1875 C 13.65625 -16.265625 13.734375 -16.3125 13.84375 -16.3125 C 13.953125 -16.3125 14.03125 -16.28125 14.125 -16.1875 L 20.59375 -10.28125 L 20.59375 -0.3125 C 20.59375 0.296875 20.3125 0.609375 19.703125 0.609375 L 16.734375 0.609375 Z M 16.734375 -5.796875 "/> </symbol> </g> </defs> <g id="surface1"> <g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> <use xlink:href="#glyph0-1" x="-1.847656" y="19"/> </g> </g> </svg>

Drag make animation weird in ZIMSHIM (adobe animate)

Hi there,

I got a weird situation. I watch this tutorial https://youtu.be/xjAyf3my2Bw and do the same thing.
all things work well. But I add a new MovieClip and make it move loopy by itself.
When I drag a ball, the ball move become fast a lot. And when I stop drag, anything works well as before.

I make the example in codepen and here is my adobe animate file a01.fla.zip

those I use.

<script src="https://zimjs.org/cdn/1.3.4/createjs.js"></script>
<script src="https://zimjs.org/cdn/00/zim_min.js"></script>

Thanks

Label.labelWidth change issue.

The size is not updated !
To fix them, I think you need simply call 'setSize()', inside the 'defineProperty'..
I hope this help !

Events ignored when shapes are added to other shapes

I've created a stage just like the slide example (http://zimjs.com/bits/view/slide.html) where I replace the image with another rectangle so that one rectangle is the mask of another. I consider the masked rectangle as the stage where other objects can be placed upon and when dragging this stage all objects are also moved. This is working as expected, except that shapes on the masked rectangle ignore events. What would be the issue?

var map = new Rectangle(frame.width, frame.height, frame.blue).addTo(stage).center();

var mask = new Rectangle(600, 400).addTo(stage, 0).pos(200, 100);
			
map.setMask(mask);
	
map.drag({
    mask:new createjs.Rectangle(200, 100, 600, 400),
    surround:true,
    slide:true,
    dragCursor:"pointer"
});
			
var line = new Rectangle(375, 50, frame.red).pos(300, 300).addTo(map); // added to map so it also moves when the map gets dragged.
			
line.on("mouseover", function() {
    console.log("test"); / /ignored
});

Frame LoadAssets Problem

Hi, I have seen your tutorials video - ZIM CAPTURE loadAssets. and i got some problem on Chrome.

Access to XMLHttpRequest at 'file:///D:/Javascript%20project/zimJS_001/assets/people.jpg' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
createjs_1.1_min.js:29 Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided.
at t.e._formatImage (createjs_1.1_min.js:29)
at t.e.handleEvent (createjs_1.1_min.js:29)
at createjs_1.1_min.js:29
at t.e._dispatchEvent (createjs_1.1_min.js:29)
at t.e._dispatchEvent (createjs_1.1_min.js:29)
at t.e.dispatchEvent (createjs_1.1_min.js:29)
at t.e._handleLoad (createjs_1.1_min.js:29)
at t.e._handleReadyStateChange (createjs_1.1_min.js:29)
at XMLHttpRequest. (createjs_1.1_min.js:29)
at t.e.load (createjs_1.1_min.js:29)**

Spritesheet animation question

Dear Dan,

Thank you for making this incredible library and its excellent documentation!

I think I'm getting something wrong here... zim_4.1.1.js seems to run the spritesheet animation without any problems, but zim_5.2.2 seems to have problem finding the canvas, it throws up a getContext error. I am sure this is my lack of experience with js.

Thank you for this wonderful resource!

Jim

ball movement with connected physics

hello! I have connected box2d in my project, I need the ball to move at the touch of a button. But nothing works, I've tried a lot of ways, with physics connected, nothing works except impulse and keyboard movement. But I need the ball to move when the button is pressed. Animation doesn't work either.

Rewind fails in fast animation

Continuing the issue I raised from Youtube,

If the double click time is under a 300 ms then the protect aspect of the loop or rewind is not activated yet.

please update typing definition for typescript user

Hi there,

I reference https://zimjs.com/typescript.html to start my ZIMjs project.
I find out some typing is not correct. like...

// zim/index.d.ts
export function zimify(obj:createjs.DisplayObject, list:boolean):DisplayObject

I follow this typing to write code.

const exportRooot: createjs.MovieClip = ...
const zContainer = zimify(exportRoot, false);
zContainer.setBounds(0,0,stageW,stageH).center();

It doesn't work. Because zContainer is null. And I change my code to...

const exportRooot: createjs.MovieClip = ...
const zContainer = zimify(exportRoot);
zContainer.setBounds(0,0,stageW,stageH).center();

It work well. But zimify function typing definition is not existed.

I know maintain typing definition is hard and boring.
So..Could you update ZIMjs typing definition or let me send "pull request" etc.

Thanks.

Make Pages be able to transition the same page again

For example, may want to pretend that a new page is loading when you are really just loading the same page again. Should be able to cache the current page and write to BitMap var copy = new createjs.BitMap(page.cacheCanvas); Then animate the Bitmap out and the page in.

Add Custom Font loading and Broken Icon for missing Files

ZIM 6.4.0 has launched with custom font loading through frame.loadAssets(). Here is a bubbling video https://www.youtube.com/watch?v=ZEhcxxnqjn0&index=46&list=PLCIzupgRt1pYtMlYPtNTKCtztFBeOtyc0 Thanks to @ami there is a new backdropShow parameter for Pane() - see the docs. The ZIM Bits Custom Font example has been updated to 6.4.0 with the changes and I am about to go through the Pane examples and update those too. Check the updates for a description of changes http://zimjs.com/code/updates.html

zim.timeout error on short-timed events

When using zim.timeout with 100 or less set for the delay I am getting the following error:

zim_5.3.0.js:5 Uncaught TypeError: n.clear is not a function at o (zim_5.3.0.js:5) at Object.e.timeout (zim_5.3.0.js:5) ....

It appears that this is happening due to next() being called on in zim.timeout() before obj,clear() and obj.pause() are set.

Test:
zim.timeout(10, function(){zog("this is a test")});

Possible Fix:
Move the next() call after obj.clear and obj.pause are set.

`
zim.timeout = function(time, call) {

	z_d("9.7");
	if (zot(call)) return;
	if (typeof call != 'function') return;
	if (zot(time)) time = 1000;
	time = zik(time);
	var obj = {startTime:Date.now(), time:0, paused:false};
	var lastTime = obj.startTime;
	function next() {
		var now = Date.now()
		obj.time += now - lastTime;
		lastTime = now;
		if (obj.time >= time) {
			(call)(obj);
			obj.clear();
			return;
		}
		obj.rid = requestAnimationFrame(next);
	}		

	obj.pause = function(state) {
		if (zot(state)) state = true;
		if (state) { // pausing
			cancelAnimationFrame(obj.rid);
		} else { // unpausing
			lastTime = Date.now();
			next();
		}
		obj.paused = state;
	}

	obj.clear = function() {
		if (obj) cancelAnimationFrame(obj.rid);
		for (var i in obj) {
			delete obj[i];
		}
		obj.pause = function() {};
		obj.clear = function() {};
	}
        next();
	return obj;

}
`

The fix seems harmless, but not sure if this may have implications elsewhere in the code.

Slider and Spinner / Picker (menu?) components

Slider would be nice to formalize - have examples with a button and using proportion equations but a component would be good. An option picker beyond the stepper would be good. So one with a certain number of options available and you scrub through them - perhaps with optional 3D effect. I made one in Flash like that - like the iOS date spinner.

ZIM NPM, Vue, Svelte, React and Angular

We have now updated our NPM to be more robust.

https://www.npmjs.com/package/zimjs

There is now a repo of templates for Vue, Svelte, React and Angular here

https://github.com/yoanhg421/zimjs-templates

Thanks @yoanhg421 for working through all this with us - as well as to those in the past for imput. It has been an ongoing issue for devs for some time. We did have solutions but they were work-arounds. Now importing and requiring ZIM should work as expected.

Request for AudioSprite Support

Bart Libert 1:22 AM

Hereby I would like to add a feature request for AudioSprite support, because this feature dramatically decreases load times for projects with multiple audio files and lots of very small files. Like game sound effects or narrator words/interface sounds . These are all very small files, but each take the overhead of 1 single load for each file (which is quite a lot of overhead and time lost) . By loading them all in 1 larger file and defining sections as audioSprites, you can get compact project with all sound in 1 file. I hope this feature request could make the release because audio is as important as gfx nowadays t make interactive material (but I'm pretty confident that it will most probably make it since you update ZIM at a record tempo 😉 ) - Bart on Slack.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.