lewisje / renderengine

Automatically exported from code.google.com/p/renderengine
MIT License
0 stars 0 forks source link

Feature: variable to point out where canvas element must be created #50

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It could be really useful to have ability to point out which document element 
Engine.getDefaultContext() returns.

Possible solutions: 

* new method Engine.setDefaultContext(DOMElement);
* pass element into Engine.getDefaultContext(DOMElement);

Original issue reported on code.google.com by tokei...@gmail.com on 13 Dec 2010 at 4:23

GoogleCodeExporter commented 8 years ago

Original comment by bfatt...@gmail.com on 4 Jan 2011 at 2:30

GoogleCodeExporter commented 8 years ago

Original comment by bfatt...@gmail.com on 4 Jan 2011 at 2:30

GoogleCodeExporter commented 8 years ago
This is not necessary since it is possible to convert an existing element in an 
HTML page into an HTMLElementContext, and then add the CanvasContext to that 
context.  For example:

{{{
// Convert an existing element into a context.  Notice that the second argument
// is the *actual element* and not a jQuery object.  Also note that the Id of
// the element will be assigned the object's Id, overriding any existing 
element Id
var div = R.rendercontexts.HTMLElementContext.create("existingDiv", 
$("div.foo")[0]);
var canvas = R.rendercontexts.CanvasContext.create("playfield", 500, 500);

// Add the canvas to the DIV element
div.add(canvas);

// Make sure the engine knows to update DIV, which will update Canvas
R.Engine.getDefaultContext().add(div);
}}}

Original comment by bfatt...@gmail.com on 2 Jun 2011 at 1:02