Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Define a Caption 'class'.
- function Caption(message, color, x, y) {
- // Properties.
- this.message = message;
- this.color = color;
- this.x = x;
- this.y = y;
- // Methods.
- this.draw = function() {
- // Draw the caption, using the parameters provided.
- gContextOverlay.beginPath();
- gContextOverlay.rect(this.x, this.y, 180, 40);
- gContextOverlay.fillStyle = this.color;
- gContextOverlay.fill();
- gContextOverlay.lineWidth = 0.5;
- gContextOverlay.strokeStyle = "#505050";
- gContextOverlay.stroke();
- gContextOverlay.font = "10pt Verdana";
- gContextOverlay.fillStyle = "#000000";
- gContextOverlay.fillText(this.message, this.x + 10, this.y + 25);
- /*console.log(gContextOverlay + " Drew caption: "
- + "\'" + this.message + "\' in "
- + this.color + " at " + x + "," + this.y + ".");*/
- };
- this.remove = function() {
- // This actually clears the entire overlay canvas,
- // but this is invoked with {button}.remove() in showCaption(event).
- gContextOverlay.clearRect(0, 0, gDemoOverlay.width, gDemoOverlay.height);
- };
- }
- /* A new Caption is defined like this: */
- var y = new Caption("Y button - Show caption", "#FFFF66", 270, 90);
Add Comment
Please, Sign In to add comment