Graphics API - version 2 thoughts! #9041
Replies: 6 comments 20 replies
-
I would cherry pick. I think the flash api was the peak programmer friendlyness when it came to drawing primitives so I like the current API, however I like the inclusion for gradient fills and more cool toys. Also to keep in mind, we use pixi to stay away from canvas, if a user wanted to do graphics with canvas they could create a canvas, use the canvas API and just make a texture 🤔 Finally, I think that Graphics is meant to be a somewhat vectory drawing API while canvas is a rastery one. That's why I don't think just putting the canvas API directly into pixi is the right approach. |
Beta Was this translation helpful? Give feedback.
-
I would like to make the case for creating primitive shape objects (e.g., CircleShape, RectangleShape, etc). Not super opinionated about the naming, "primatives", "shapes", "objects", "vectors". Many 3D libraries have setups like this and it makes it really easy to add things to the stage. Also, we would need a PathShape-type object which would contain all the lineTo, moveTo, for manual drawing. There are a couple reasons I think this is a better approach:
Plus, this could be 100% backward compatible with Graphics by making Graphics be a simple Container (e.g., Here's an example: Current import { Application, Graphics } from 'pixi.js';
const app = new Application();
const circle = new Graphics()
.beginFill(0xff0000)
.drawCircle(0, 0, 100)
.endFill();
app.stage.addChild(circle); Proposed import { Application, CircleShape } from 'pixi.js';
const app = new Application();
app.stage.addChild(new CircleShape({
radius: 100,
fill: '#f00',
})); |
Beta Was this translation helpful? Give feedback.
-
I'd like to point out that we actually have very good way of doing AA on simple shapes and masks made with them. easy things like "add circle to the stage without it being a separate graphics" should be taken into account. |
Beta Was this translation helpful? Give feedback.
-
thoughts on possible gradients API? option 1: Object notation for a new function
option 2: Create a gradient object (like Canvas does)
option 3: Use same fill command with additional type
curious to get people thoughts on this one! Do you have a favourite? |
Beta Was this translation helpful? Give feedback.
-
Just thinking out loud now -> option 4: CSS?
|
Beta Was this translation helpful? Give feedback.
-
A thought is that if you use the Canvas2D API as a base the codebase will be smaller in size and "auto-magically" up to date when the Browser vendor updates their browser. |
Beta Was this translation helpful? Give feedback.
-
Hello all! So been reworking Graphics API a little and ended up creating a graphics context that exactly mimics the Canvas 2D context API. So my question to you.
Q1: Which API do you think is better?
a: The canvas API
b: The current PixiJS graphics API
Been noodling on this question for a while heres my top level thoughts
Canvas 2D API has a few really nice features
Graphics API has a few nice features also
Should we keep the original? Or switch to Canvas API? the have both? Should we cherry pick the best features from one and add to the other?
One problem that we think exists with both APIs is it can easily be abused to slow performance of rendering (i.e., “just enough rope for users to hang themselves”). There lots of historical comments on GitHub about rendering 10K circles or something silly.
Should we consider something like making individual display objects? Eg
const myCircle = new CircleObject()
?It would be great to get the community's thoughts on this! Additionally we are keen to understand
Beta Was this translation helpful? Give feedback.
All reactions