Created
April 3, 2015 18:40
-
-
Save rezoner/ed86e0a72a13ef58fce5 to your computer and use it in GitHub Desktop.
Playground Plugins v3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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