-
Notifications
You must be signed in to change notification settings - Fork 33
/
jqscribble.extrabrushes.js
145 lines (122 loc) · 4 KB
/
jqscribble.extrabrushes.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//This is a custom brush that will draw small lines based off the stroke path.
LineBrush.prototype = new jqScribbleBrush;
function LineBrush()
{
LineBrush.prototype.strokeBegin = function(x, y)
{
jqScribbleBrush.prototype.strokeBegin.call(this, x, y);
this.lineRadius = 7;
};
LineBrush.prototype.strokeMove = function(x, y)
{
jqScribbleBrush.prototype.strokeMove.call(this, x, y);
this.context.moveTo(x-this.lineRadius, y-this.lineRadius);
this.context.lineTo(x+this.lineRadius, y+this.lineRadius);
this.context.strokeStyle = this.brushColor;
this.context.stroke();
};
};
//This is a custom brush that will draw small crosses based off the stroke path.
CrossBrush.prototype = new jqScribbleBrush;
function CrossBrush()
{
CrossBrush.prototype.strokeBegin = function(x, y)
{
jqScribbleBrush.prototype.strokeBegin.call(this, x, y);
this.lineRadius = 7;
};
CrossBrush.prototype.strokeMove = function(x, y)
{
jqScribbleBrush.prototype.strokeMove.call(this, x, y);
this.context.moveTo(x-this.lineRadius, y-this.lineRadius);
this.context.lineTo(x+this.lineRadius, y+this.lineRadius);
this.context.moveTo(x-this.lineRadius, y+this.lineRadius);
this.context.lineTo(x+this.lineRadius, y-this.lineRadius);
this.context.strokeStyle = this.brushColor;
this.context.stroke();
};
};
//This is a custom brush that will draw dots.
DotBrush.prototype = new jqScribbleBrush;
function DotBrush()
{
DotBrush.prototype.strokeBegin = function(x, y)
{
jqScribbleBrush.prototype.strokeBegin.call(this, x, y);
this.lineRadius = 1;
};
DotBrush.prototype.strokeMove = function(x, y)
{
jqScribbleBrush.prototype.strokeMove.call(this, x, y);
this.context.moveTo(x-this.lineRadius, y+this.lineRadius);
this.context.lineTo(x+this.lineRadius, y-this.lineRadius);
this.context.strokeStyle = this.brushColor;
this.context.stroke();
};
};
//This is a custom brush that will draw circles.
CircleBrush.prototype = new jqScribbleBrush;
function CircleBrush()
{
CircleBrush.prototype.strokeBegin = function(x, y)
{
//For custom brushes make sure to call the parent brush methods
jqScribbleBrush.prototype.strokeBegin.call(this, x, y);
this.prevX = x;
this.prevY = y;
this.lineRadius = 20;
};
CircleBrush.prototype.strokeMove = function(x, y)
{
//For custom brushes make sure to call the parent brush methods
jqScribbleBrush.prototype.strokeMove.call(this, x, y);
this.context.beginPath();
this.context.arc(x, y, this.lineRadius, 0, 2 * Math.PI, false);
this.context.strokeStyle = this.brushColor;
this.context.stroke();
};
};
//This is a custom brush that will draw semicircles.
SemiCircleBrush.prototype = new jqScribbleBrush;
function SemiCircleBrush()
{
SemiCircleBrush.prototype.strokeBegin = function(x, y)
{
//For custom brushes make sure to call the parent brush methods
jqScribbleBrush.prototype.strokeBegin.call(this, x, y);
this.prevX = x;
this.prevY = y;
this.lineRadius = 20;
};
SemiCircleBrush.prototype.strokeMove = function(x, y)
{
//For custom brushes make sure to call the parent brush methods
jqScribbleBrush.prototype.strokeMove.call(this, x, y);
this.context.beginPath();
this.context.arc(x, y, this.lineRadius, 0, Math.PI, false);
this.context.strokeStyle = this.brushColor;
this.context.stroke();
};
};
//This is a custom brush that will draw rectangles.
RectangleBrush.prototype = new jqScribbleBrush;
function RectangleBrush()
{
RectangleBrush.prototype.strokeBegin = function(x, y)
{
//For custom brushes make sure to call the parent brush methods
jqScribbleBrush.prototype.strokeBegin.call(this, x, y);
this.prevX = x;
this.prevY = y;
this.lineRadius = 20;
};
RectangleBrush.prototype.strokeMove = function(x, y)
{
//For custom brushes make sure to call the parent brush methods
jqScribbleBrush.prototype.strokeMove.call(this, x, y);
this.context.beginPath();
this.context.rect(x, y, this.lineRadius, this.lineRadius);
this.context.strokeStyle = this.brushColor;
this.context.stroke();
};
};