Skip to content

Commit 109e97c

Browse files
committed
Remove DefaultPenAttributes
1 parent 2790b9b commit 109e97c

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/PenSkin.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@ const ShaderManager = require('./ShaderManager');
1212
* @property {Array<number>} [color4f] - The pen color as an array of [r,g,b,a], each component in the range [0,1].
1313
*/
1414

15-
/**
16-
* The pen attributes to use when unspecified.
17-
* @type {PenSkin#PenAttributes}
18-
* @memberof PenSkin
19-
* @private
20-
* @const
21-
*/
22-
const DefaultPenAttributes = {
23-
color4f: [0, 0, 1, 1],
24-
diameter: 1
25-
};
26-
2715
/**
2816
* Reused memory location for storing a premultiplied pen color.
2917
* @type {FloatArray}
@@ -161,7 +149,7 @@ class PenSkin extends Skin {
161149
drawLine (penAttributes, x0, y0, x1, y1) {
162150
// For compatibility with Scratch 2.0, offset pen lines of width 1 and 3 so they're pixel-aligned.
163151
// See https://github.com/LLK/scratch-render/pull/314
164-
const diameter = penAttributes.diameter || DefaultPenAttributes.diameter;
152+
const diameter = penAttributes.diameter;
165153
const offset = (diameter === 1 || diameter === 3) ? 0.5 : 0;
166154

167155
this._drawLineOnBuffer(
@@ -222,15 +210,15 @@ class PenSkin extends Skin {
222210
this._renderer.enterDrawRegion(this._lineOnBufferDrawRegionId);
223211

224212
// Premultiply pen color by pen transparency
225-
const penColor = penAttributes.color4f || DefaultPenAttributes.color4f;
213+
const penColor = penAttributes.color4f;
226214
__premultipliedColor[0] = penColor[0] * penColor[3];
227215
__premultipliedColor[1] = penColor[1] * penColor[3];
228216
__premultipliedColor[2] = penColor[2] * penColor[3];
229217
__premultipliedColor[3] = penColor[3];
230218

231219
const uniforms = {
232220
u_lineColor: __premultipliedColor,
233-
u_lineThickness: penAttributes.diameter || DefaultPenAttributes.diameter,
221+
u_lineThickness: penAttributes.diameter,
234222
u_penPoints: [x0, -y0, x1, -y1]
235223
};
236224

0 commit comments

Comments
 (0)