Description

(1.3.1) Cache commands this element in a HTML5Canvas

Usage

Parameters

  • w {Integer} optional

    (optional) Width of the element cached (element width by default)

  • h {Integer}

    (optinal) Height of the element cached (element height by default)

  • free_memory {Boolean} optional

    (optional) Do not keep in mind the commands. uncache method can not be used

Returns

CanvasEngine.Element

Example

In ready method :

    var el = this.createElement(120, 120); // do not forget to give a size to the element
    el.beginPath();
    el.strokeStyle = 'red';
    el.lineWidth = 4;
    el.moveTo(10,10);
    el.lineTo(10,30);
    el.lineTo(30,30);
    el.stroke();
    el.cache(); // cache element

    el.uncache(); // uncache element

    el.cache(true); // cache element without to put commands in memory

    el.uncache(); // error

Discussion