Skip to content

Commit

Permalink
Parse rgba(r,g,b,0) correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
H3r3zy authored and zbjornson committed Sep 7, 2022
1 parent 6862532 commit 9374943
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ package-lock.json
*.swp
*.un~
npm-debug.log

.idea
5 changes: 4 additions & 1 deletion src/color.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ parse_clipped_percentage(const char** pStr, float *pFraction) {
if (*str >= '1' && *str <= '9') { \
NAME = 1; \
} else { \
if ('0' == *str) ++str; \
if ('0' == *str) { \
NAME = 0; \
++str; \
} \
if ('.' == *str) { \
++str; \
NAME = 0; \
Expand Down
5 changes: 4 additions & 1 deletion test/canvas.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ describe('Canvas', function () {
ctx.fillStyle = 'rgba(255, 250, 255)';
assert.equal('#fffaff', ctx.fillStyle);

ctx.fillStyle = 'rgba(124, 58, 26, 0)';
assert.equal('rgba(124, 58, 26, 0.00)', ctx.fillStyle);

// hsl / hsla tests

ctx.fillStyle = 'hsl(0, 0%, 0%)'
Expand Down Expand Up @@ -985,7 +988,7 @@ describe('Canvas', function () {
const cm = ctx.measureText('aaaa')
assertApprox(cm.actualBoundingBoxLeft, 9, 6)
assertApprox(cm.actualBoundingBoxRight, 11, 6)

ctx.textAlign = 'right'
const rm = ctx.measureText('aaaa')
assertApprox(rm.actualBoundingBoxLeft, 19, 6)
Expand Down

0 comments on commit 9374943

Please sign in to comment.