Guest User

Untitled

a guest
Nov 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. // Define a Caption 'class'.
  2. function Caption(message, color, x, y) {
  3.  
  4. // Properties.
  5. this.message = message;
  6. this.color = color;
  7. this.x = x;
  8. this.y = y;
  9.  
  10. // Methods.
  11. this.draw = function() {
  12. // Draw the caption, using the parameters provided.
  13. gContextOverlay.beginPath();
  14. gContextOverlay.rect(this.x, this.y, 180, 40);
  15. gContextOverlay.fillStyle = this.color;
  16. gContextOverlay.fill();
  17. gContextOverlay.lineWidth = 0.5;
  18. gContextOverlay.strokeStyle = "#505050";
  19. gContextOverlay.stroke();
  20.  
  21. gContextOverlay.font = "10pt Verdana";
  22. gContextOverlay.fillStyle = "#000000";
  23. gContextOverlay.fillText(this.message, this.x + 10, this.y + 25);
  24.  
  25. /*console.log(gContextOverlay + " Drew caption: "
  26. + "\'" + this.message + "\' in "
  27. + this.color + " at " + x + "," + this.y + ".");*/
  28. };
  29. this.remove = function() {
  30. // This actually clears the entire overlay canvas,
  31. // but this is invoked with {button}.remove() in showCaption(event).
  32. gContextOverlay.clearRect(0, 0, gDemoOverlay.width, gDemoOverlay.height);
  33. };
  34. }
  35.  
  36. /* A new Caption is defined like this: */
  37. var y = new Caption("Y button - Show caption", "#FFFF66", 270, 90);
Add Comment
Please, Sign In to add comment