It provides a few extra low-level features which are supposed to be designed for game authors. The functions include:
- getPixel(x, y)
Returns the pixel value (colour, opacity) at (x, y). Returned in the form #rrggbb if fully opaque and rgba(r, g, b, a) if it has some alpha transparency.
- setPixel (x, y, colour)
Allows you to set the colour of the pixel at (x, y). The third argument should be a CSS colour – you could provide a string such as ‘red’, a HTML colour code or even a rgba() value.
The folks at Opera have provided 3 examples of how per-pixel manipulation can allow Opera to do some image effects which you’d traditionally have to use an image editor for.
Of course, you’ll need Opera 9 to see these demos. They were pretty slow for me – it took around 4 seconds to apply a sepia filter on a 400×300 pixel image.
Theres also a checkCollision() function which will allow you to determine whether a certain point given by co-ordinates (x, y) is inside a path (a shape). You can also lock the canvas. When the canvas is locked you can work with it as normal but the canvas will not actually be redrawn until you unlock it. This should speed up your script as the browser won’t have to continuously redraw.
It would be interesting to see any games which are created using opera-2dgame.