Giter Site home page Giter Site logo

quinton-ashley / native-canvas Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mcchatman8009/native-canvas

0.0 1.0 0.0 12.52 MB

A canvas library that allows for a HTML canvas to run natively on NodeJs, without a WebBrowser

License: MIT License

Shell 0.03% TypeScript 99.97%

native-canvas's Introduction

native-canvas

Overview

The purpose and intent of this project was to create a library that allows for developers to create a browser canvas element that runs natively, without the need of a WebBrowser. Allowing for developers to code and develop portable canvas based applications that can run both on the WebBrowser and natively on any NodeJS platform.

Requirements

  • NodeJS 10+

Getting Stated

  • Install the native-canvas library
npm install native-canvas

A Simple Example

// Load the library
require('native-canvas');

// Use the globally exposed canvas
const ctx = canvas.getContext("2d");

ctx.lineWidth = 1;
ctx.fillStyle = "#FF0000";
ctx.fillRect(0, 0, 150, 75);

View the samples directory to see more examples.

Running a Browser Example

// Load the library
require('native-canvas');

// Title the title attribute
document.title = 'Create Canvas with Document';

// Provides the current running canvas
const canvas = document.createElement('canvas');
const ctx = canvas.getContext("2d");

canvas.height = 150;

ctx.lineWidth = 1;

ctx.clearRect(0, 0, 400, 400);
ctx.beginPath();
ctx.arc(40, 40, 40, 0, 2 * Math.PI);
ctx.closePath();
ctx.stroke();

Mac OS [Apple Silicon]

To install you need to install system deps first.

brew install python
arch -arm64 brew install pkg-config cairo pango jpeg giflib librsvg libffi

Raspberry Pi

To install on Raspberry Pi, you need to prep your environment by installing a few dev libraries.

sudo apt install \
  libpixman-1-dev \
  libcairo2-dev \
  libpango1.0-dev \
  libjpeg-dev \
  libgif-dev \
  libsdl2-dev

Screenshots

Bouncing Ball Mario

Example

Acknowledgments

Special Thanks to @dmcquillan314 for the support!

native-canvas's People

Contributors

mcchatman8009 avatar quinton-ashley avatar fordi avatar

Watchers

 avatar

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.