Comments (5)
There are three ways to do it:
-
Use getImageData and change pixels in it, adding new values to it using Alpha Compositing and such formula:
resultColor = oldColor_(1-transparency) + newColor_transparency
-
Create new empty layer and render pixel data there
-
Prerender frames to hidden buffer and then just render buffer as image
Last way is most effective looking at speed - pixel manipulations are slow enough
from libcanvas.
Thanks will try that!
I tried creating new layer, but that did not work, was doing something wrong.... The problem with layers is also current libcanvas api doesnt provide a way of removing then, and I need a dynamic number of layers, one for each 'vehicle' (a vehicle is a set of simple shapers with animations) on the canvas, as the number of vehicles is data driven...
Ended up calling createBuffer on main libcanvas, which creates a new html canvas, then redering the flame inside the new buffer canvas (using getImageData, putImageData) and draw the buffer canvas into the 'main' libcanvas to get the transparency working. That works, but I doubt its good in terms of performance. What do u think?
from libcanvas.
I mean prepender several frames once and then just draw them first-second-third-first-second-...
You should try to avoid pixel manipulations.
from libcanvas.
I got u. The 'problem' is the algorithm is random and each frame is populated based on the previous frame, thus u never end up creating a loop that would smoothly transition between the last and first frame in the buffer...
Lets say I wont prerender, what is the best way to render the fllame each frame?
from libcanvas.
The better way is to change algorithm and run in without many calls of putImageData, but you can use first way, described in comment above - it is most correct.
from libcanvas.
Related Issues (20)
- How to set direction of linear gradient HOT 1
- Typo in Source / Core / Context2D.js ln 509 HOT 1
- События мыши HOT 1
- Rotate Shape (Rectangle) HOT 1
- event.layerX and event.layerY are broken and deprecated in WebKit. HOT 3
- this.shape.hasPoint - ошибка HOT 2
- Fire callback when fifteen puzzle has been completed HOT 1
- getCellBy... не принимает массив в качестве аргумента HOT 1
- Optimizing performance HOT 3
- Optimize drawImage HOT 2
- Баг в Engines.Tile.Element HOT 1
- Line distance to - zero result
- LibCanvas.Shapes.Rectangle.hasPoint HOT 3
- style of lineCap
- [enhancement] Add missing bower.json.
- measureText не верно рассчитывает ширину текста HOT 3
- При вызове getContext('2d-libcanvas') нет возможности передать опции HOT 1
- Ошибка отрисовки в Chrome 43 в примере Dune 2 Map: thousands objects
- npm install и webpack
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libcanvas.