🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

js-ui-engine

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-ui-engine

Javascript UI Engine

latest
Source
npmnpm
Version
2.20250522.1
Version published
Weekly downloads
14
366.67%
Maintainers
1
Weekly downloads
 
Created
Source

Javascript-UI-Engine

This was just a simple Javascript library I put together for myself to help make the HTML5 Canvas use objects so that it can be somewhat event driven.

Feel free to use this library and if you find any bugs please let me know and I will fix them.

Creation Date: 21/09/2014

URL: https://github.com/Slyke/Javascript-UI-Engine

NPM: npm install js-ui-engine

Version: 2.20250522.1

Description:

This is a simple canvas control class for Javascript. This class can be used as an instantiated object or as a singleton.

Example Usage:

  const canvasControl = new CanvasControl(); // Create the class
  const c = document.getElementById("canvasDraw"); // Get the canvas DOM element
  canvasControl.setupCanvas({ canvas: c }); // Setup the canvas

  // Add event listeners
  c.addEventListener('click', e => {
    canvasControl.mouseEventHandler({ e, type: "Click" });
  });
  c.addEventListener('mousemove', e => {
    canvasControl.mouseEventHandler({ e, type: "Move" });
  });

  // Create the new object
  const newSquare = {
    x: 50,
    y: 50,
    w: 250,
    h: 250,
    shape: "rect",
    render(self) {
      canvasControl.drawRect({
        key: self.key,
        x: self.x,
        y: self.y,
        w: self.w,
        h: self.h
      });
    },
    clickEvent(x, y, self) {
      console.log(x, y, self, "click");
    },
    moveEvent(x, y, self) {
      console.log(x, y, self, "move");
    },
    visible: true
  };

  // Add to canvasObjects map
  canvasControl.addCanvasObject({ object: newSquare });

  // Redraw screen
  canvasControl.refreshScreen();

Checkout the examples folder for more.

License:

The MIT License (MIT)

  Copyright (c) 2014 Steven Lawler (Slyke)

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.

FAQs

Package last updated on 26 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts