topical media & game development
graphic-canvas-util-liquid-liquid-canvas-plugins.js / js
(function(.registerLiquidCanvasPlugin({
name: "rect",
paint: function(area) {
area.ctx.beginPath();
area.ctx.rect(0, 0, area.width, area.height);
area.ctx.closePath();
if (this.action) this.action.paint(area); // for chaining
}
});
.registerLiquidCanvasPlugin({
name: "fill",
defaultOpts: { color:"#aaa" },
paint: function(area) {
area.ctx.fillStyle = this.opts.color;
this.action.paint(area);
area.ctx.fill();
}
});
.registerLiquidCanvasPlugin({
name: "gradient",
defaultOpts: { from: "#fff", to:"#666" },
paint: function(area) {
var grad = area.ctx.createLinearGradient(0, 0, 0, area.height);
grad.addColorStop(0, this.opts.from);
grad.addColorStop(1, this.opts.to);
area.ctx.fillStyle = grad;
this.action.paint(area);
area.ctx.fill();
}
});
// End of Liquid Canvas Plugin
.registerLiquidCanvasPlugin({
name: "border",
defaultOpts: { color:'#8f4', width:3 },
paint: function(area) {
var bw = this.opts.width;
area.ctx.strokeStyle = this.opts.color;
area.ctx.lineWidth = bw;
this.action.shrink(area, bw / 2);
this.action.paint(area);
area.ctx.stroke();
this.action.shrink(area, bw / 2);
}
});
})(jQuery);
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.