-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcustom.js
More file actions
28 lines (24 loc) · 815 Bytes
/
custom.js
File metadata and controls
28 lines (24 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// /\//\+/-//\/\/
var custom = {
init: function(message, messageSize) {
this.Message = message;
this.MessageSize = messageSize;
this.MessageOffset = 50;
return this;
},
draw: function(ctx, duck) {
ctx.fillStyle = duck.color;
ctx.font = this.MessageSize + 'px monospace';
ctx.fillText(this.Message, duck.x + this.MessageOffset, duck.y + duck.bob - this.MessageOffset);
ctx.strokeStyle = duck.color;
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(duck.x - 3, duck.y + duck.bob + 3);
ctx.lineTo(duck.x + (this.MessageOffset - 5), duck.y + duck.bob - (this.MessageOffset - 5));
ctx.stroke();
},
measure: function(ctx, duck) {
ctx.font = this.MessageSize + 'px monospace';
return ctx.measureText(this.Message).width + this.MessageOffset;
},
};