Skip to content

Instantly share code, notes, and snippets.

@rezoner
Created April 3, 2015 18:40
Show Gist options
  • Save rezoner/ed86e0a72a13ef58fce5 to your computer and use it in GitHub Desktop.
Save rezoner/ed86e0a72a13ef58fce5 to your computer and use it in GitHub Desktop.
Playground Plugins v3
/*
Here is a simple plugin that creates scanlines image
and draws it after everything has been rendered
I am still not sure what will be the standard for configuration.
*/
PLAYGROUND.Scanlines = function(app) {
this.app = app;
app.on("resize", this.resize.bind(this));
app.on("postrender", this.postrender.bind(this));
};
PLAYGROUND.Scanlines.plugin = true;
PLAYGROUND.Scanlines.prototype = {
resize: function() {
this.image = cq(this.app.width, this.app.height);
this.image.globalAlpha(0.1);
this.image.fillStyle("#000");
for (var i = 1; i < this.image.canvas.height; i += 2){
this.image.fillRect(0, i, this.image.canvas.width, 1);
}
this.image = this.image.cache();
},
postrender: function() {
if (this.image) {
this.app.layer.drawImage(this.image, 0, 0);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment