Skip to content

Commit 9374943

Browse files
H3r3zyzbjornson
authored andcommitted
Parse rgba(r,g,b,0) correctly
1 parent 6862532 commit 9374943

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ package-lock.json
1616
*.swp
1717
*.un~
1818
npm-debug.log
19+
20+
.idea

src/color.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ parse_clipped_percentage(const char** pStr, float *pFraction) {
228228
if (*str >= '1' && *str <= '9') { \
229229
NAME = 1; \
230230
} else { \
231-
if ('0' == *str) ++str; \
231+
if ('0' == *str) { \
232+
NAME = 0; \
233+
++str; \
234+
} \
232235
if ('.' == *str) { \
233236
++str; \
234237
NAME = 0; \

test/canvas.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ describe('Canvas', function () {
210210
ctx.fillStyle = 'rgba(255, 250, 255)';
211211
assert.equal('#fffaff', ctx.fillStyle);
212212

213+
ctx.fillStyle = 'rgba(124, 58, 26, 0)';
214+
assert.equal('rgba(124, 58, 26, 0.00)', ctx.fillStyle);
215+
213216
// hsl / hsla tests
214217

215218
ctx.fillStyle = 'hsl(0, 0%, 0%)'
@@ -985,7 +988,7 @@ describe('Canvas', function () {
985988
const cm = ctx.measureText('aaaa')
986989
assertApprox(cm.actualBoundingBoxLeft, 9, 6)
987990
assertApprox(cm.actualBoundingBoxRight, 11, 6)
988-
991+
989992
ctx.textAlign = 'right'
990993
const rm = ctx.measureText('aaaa')
991994
assertApprox(rm.actualBoundingBoxLeft, 19, 6)

0 commit comments

Comments
 (0)