Support for rotatable canvas objects would be incredibly useful for many games. Originally in fact I'd considered an asteroids clone for the demo game, instead of space invaders, but hadn't yet settled on how to handle this in the API.
Proposal:
new element: :rotate - wraps its body element and applies a rotation effect to it
one property: :angle - Specifies the clockwise rotation angle in radians, as per CanvasRenderingContext2D.rotate()
implementation: Render the body element to a temporary canvas and apply the rotation effect to it, then draw the temp canvas to the main context.
challenges: determining the correct canvas size for the temporary canvas could be difficult, there are no sane defaults. Possibly however, dimensions could be reflected on through the properties of the body element.
Alternate proposal:
new property on rotatable elements: :rotate - causes the element to be rotated by the specified angle
supported elements: :sprite, :map, :rect, :image
implementation: behavior implemented manually per-element, as optional call to ctx.rotate() when property as present
challenges: longer development time and more repetitive code, as behavior must be written manually per element supported, much as color and font currently are.
Support for rotatable canvas objects would be incredibly useful for many games. Originally in fact I'd considered an asteroids clone for the demo game, instead of space invaders, but hadn't yet settled on how to handle this in the API.
Proposal:
:rotate
- wraps its body element and applies a rotation effect to it:angle
- Specifies the clockwise rotation angle in radians, as perCanvasRenderingContext2D.rotate()
Alternate proposal:
:rotate
- causes the element to be rotated by the specified angle:sprite, :map, :rect, :image
ctx.rotate()
when property as present