Top Related Projects
The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.
Konva.js is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser
a fresh, modern & lightweight HTML5 game engine
The Easel Javascript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier.
Quick Overview
The maierfelix/poxi
repository is a lightweight and fast WebGL-based 2D rendering library for the web. It provides a simple and efficient way to create and manage 2D graphics and animations in the browser.
Pros
- Performance: Poxi is built on top of WebGL, which allows for hardware-accelerated rendering, resulting in high performance and smooth animations.
- Simplicity: The library has a straightforward and intuitive API, making it easy to use and integrate into web projects.
- Flexibility: Poxi supports a wide range of 2D graphics features, including sprites, shapes, text, and more, allowing developers to create a variety of 2D applications.
- Lightweight: The library is relatively small in size, making it suitable for use in performance-critical web applications.
Cons
- Limited Documentation: The project's documentation could be more comprehensive, which may make it challenging for new users to get started.
- Lack of Community: Poxi has a relatively small user base and community, which could limit the availability of support and resources.
- Potential Compatibility Issues: As a WebGL-based library, Poxi may have compatibility issues with older browsers or devices with limited WebGL support.
- Ongoing Development: The project appears to have had limited updates in recent years, which could raise concerns about its long-term maintenance and support.
Code Examples
Here are a few code examples demonstrating the usage of Poxi:
Creating a simple scene with a sprite and a shape:
import { Scene, Sprite, Rectangle } from 'poxi';
const scene = new Scene();
// Add a sprite
const sprite = new Sprite('path/to/image.png');
sprite.position.set(100, 100);
scene.add(sprite);
// Add a rectangle
const rect = new Rectangle(50, 50);
rect.position.set(200, 200);
rect.color = 0xff0000; // Red
scene.add(rect);
// Render the scene
scene.render();
Animating a sprite:
import { Scene, Sprite } from 'poxi';
const scene = new Scene();
const sprite = new Sprite('path/to/spritesheet.png');
sprite.position.set(100, 100);
sprite.addAnimation('walk', [0, 1, 2, 3], 10); // Define a 'walk' animation
sprite.play('walk'); // Start the 'walk' animation
scene.add(sprite);
// Render the scene and update the animation
function animate() {
requestAnimationFrame(animate);
sprite.update();
scene.render();
}
animate();
Handling user input:
import { Scene, Sprite, Input } from 'poxi';
const scene = new Scene();
const input = new Input(scene.canvas);
const sprite = new Sprite('path/to/image.png');
sprite.position.set(100, 100);
scene.add(sprite);
input.on('mousedown', (event) => {
// Move the sprite to the mouse position
sprite.position.set(event.clientX, event.clientY);
});
input.on('keydown', (event) => {
if (event.key === 'ArrowUp') {
// Move the sprite up
sprite.position.y -= 10;
}
});
scene.render();
Getting Started
To get started with Poxi, you can follow these steps:
- Install the library using npm or yarn:
npm install poxi
- Import the necessary modules and create a new scene:
import { Scene, Sprite, Rectangle } from 'poxi';
const scene = new Scene();
- Add objects to the scene, such as sprites and shapes:
const sprite = new Sprite('path/to/image.png');
sprite.position.set(100, 100);
scene.add(sprite);
const rect = new Rectangle(50, 50);
rect.position.set(200, 200);
rect.color = 0xff0000; // Red
scene.add(rect);
Competitor Comparisons
The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.
Pros of PixiJS
- Mature and widely-used library with a large community and extensive documentation
- Supports a wide range of features, including advanced rendering, animation, and interaction
- Actively maintained and regularly updated with new features and bug fixes
Cons of PixiJS
- Larger file size and more complex setup compared to Poxi
- Steeper learning curve, especially for beginners in web development
Code Comparison
PixiJS (5 lines):
const app = new PIXI.Application();
document.body.appendChild(app.view);
const sprite = PIXI.Sprite.from('image.png');
sprite.x = app.screen.width / 2;
sprite.y = app.screen.height / 2;
Poxi (5 lines):
import { Poxi } from 'poxi';
const app = new Poxi();
app.add(Poxi.Sprite.from('image.png'));
app.start();
Konva.js is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
Pros of Konva
- More mature and widely adopted project with extensive documentation
- Supports complex shapes and animations out of the box
- Offers a plugin system for extending functionality
Cons of Konva
- Larger file size and potentially slower performance for simple use cases
- Steeper learning curve due to more complex API
Code Comparison
Konva:
const stage = new Konva.Stage({
container: 'container',
width: 400,
height: 400
});
const layer = new Konva.Layer();
stage.add(layer);
const rect = new Konva.Rect({
x: 50,
y: 50,
width: 100,
height: 100,
fill: 'red'
});
layer.add(rect);
layer.draw();
Poxi:
const canvas = document.createElement("canvas");
canvas.width = 400;
canvas.height = 400;
document.body.appendChild(canvas);
const ctx = canvas.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(50, 50, 100, 100);
Poxi offers a simpler, more lightweight approach to canvas rendering, which can be beneficial for basic use cases or performance-critical applications. However, Konva provides a more robust set of features and abstractions, making it easier to create complex interactive graphics and animations at the cost of a larger footprint and potentially slower performance for simpler scenarios.
Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser
Pros of fabric.js
- More mature and feature-rich library with extensive documentation
- Larger community and ecosystem, resulting in better support and resources
- Supports both SVG and canvas rendering, offering flexibility for different use cases
Cons of fabric.js
- Larger file size and potentially heavier performance impact
- Steeper learning curve due to its extensive API and features
- May be overkill for simpler projects that don't require all its functionality
Code Comparison
fabric.js:
var canvas = new fabric.Canvas('canvas');
var rect = new fabric.Rect({
left: 100,
top: 100,
fill: 'red',
width: 20,
height: 20
});
canvas.add(rect);
poxi:
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(100, 100, 20, 20);
fabric.js provides a more object-oriented approach with built-in shape objects and canvas management, while poxi uses native canvas API calls for drawing, resulting in a simpler but less feature-rich implementation.
a fresh, modern & lightweight HTML5 game engine
Pros of melonJS
- More mature and feature-rich game engine with a larger community
- Extensive documentation and tutorials available
- Built-in physics engine and collision detection
Cons of melonJS
- Steeper learning curve for beginners
- Larger file size and potentially slower performance for simple games
- Less flexibility for low-level customization
Code Comparison
melonJS:
me.game.onload = function() {
me.state.set(me.state.PLAY, new PlayScreen());
me.state.change(me.state.PLAY);
};
poxi:
const game = new Game();
game.start();
melonJS provides a more structured approach with state management, while poxi offers a simpler setup for quick prototyping.
Key Differences
- melonJS is a full-featured game engine, while poxi is a lightweight WebGL renderer
- melonJS has built-in game-specific features, whereas poxi focuses on efficient rendering
- melonJS is better suited for complex games, while poxi is ideal for simple 2D games or custom engine development
Use Cases
melonJS is best for:
- Developers looking for a complete game development framework
- Projects requiring advanced features like physics and audio management
poxi is better for:
- Developers who want to build their own game engine
- Simple 2D games with custom rendering requirements
- Projects where performance and small file size are critical
The Easel Javascript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier.
Pros of EaselJS
- More mature and established library with a larger community and ecosystem
- Comprehensive documentation and extensive examples available
- Part of the larger CreateJS suite, offering integration with other tools
Cons of EaselJS
- Heavier and more complex, potentially impacting performance for simpler projects
- Less focused on modern web technologies and practices
- Steeper learning curve for beginners due to its extensive feature set
Code Comparison
EaselJS:
var stage = new createjs.Stage("canvas");
var circle = new createjs.Shape();
circle.graphics.beginFill("red").drawCircle(0, 0, 50);
circle.x = 100;
circle.y = 100;
stage.addChild(circle);
stage.update();
Poxi:
const renderer = new POXI.Renderer(canvas);
const circle = new POXI.Graphics();
circle.beginFill(0xff0000).drawCircle(100, 100, 50);
renderer.stage.addChild(circle);
renderer.render();
Both libraries provide similar functionality for creating and rendering shapes, but Poxi's syntax is more concise and modern. EaselJS requires more setup and uses a different approach to positioning elements.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Poxi is a modern, flat pixel art editor for the browser with focus on elegance, simplicity and productivity.
Engine features
- Smart batching
- WebGL-based renderer
- Low-level matrices
- Undo/Redo for all operations
- Infinite grid
- Copy by reference
I've created this pixel editor because of the lack of smooth pixel editors inside the browser. All current implementations lack of speed and just feel clunky and slow. I've created a whole low-level pixel matrix framework from scratch for this, offering incredible speed, a undo/redo state machine and various basic transformation methods. This allows you to work on images even larger than 8000px á 8000px with very low memory consummation.
Coming soon
- Animations
- Selections
- Faster bucket filling
Contributing
Code related pull requests are very welcome, but please make sure they match the existing code style.
License
Top Related Projects
The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.
Konva.js is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser
a fresh, modern & lightweight HTML5 game engine
The Easel Javascript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot