From 9e12f093f614e1335f3e7f9ea023596f0e5d43ea Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Tue, 4 Feb 2020 19:55:32 -0500 Subject: [PATCH] Cleanup --- src/PenSkin.js | 5 +++-- src/shaders/sprite.vert | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PenSkin.js b/src/PenSkin.js index 93aa6a6..90184f2 100644 --- a/src/PenSkin.js +++ b/src/PenSkin.js @@ -210,9 +210,10 @@ class PenSkin extends Skin { * @param {number} y1 - the Y coordinate of the end of the line. */ drawLine (penAttributes, x0, y0, x1, y1) { - // Width 1 and 3 lines need to be offset by 0.5. + // For compatibility with Scratch 2.0, offset pen lines of width 1 and 3 so they're pixel-aligned. + // See https://github.com/LLK/scratch-render/pull/314 const diameter = penAttributes.diameter || DefaultPenAttributes.diameter; - const offset = (Math.max(4 - diameter, 0) % 2) / 2; + const offset = (diameter === 1 || diameter === 3) ? 0.5 : 0; this._drawLineOnBuffer( penAttributes, diff --git a/src/shaders/sprite.vert b/src/shaders/sprite.vert index a48933d..37e662f 100644 --- a/src/shaders/sprite.vert +++ b/src/shaders/sprite.vert @@ -6,10 +6,10 @@ uniform vec2 u_stageSize; #ifndef DRAW_MODE_line uniform mat4 u_projectionMatrix; +attribute vec2 a_texCoord; #endif attribute vec2 a_position; -attribute vec2 a_texCoord; varying vec2 v_texCoord;