Browse Source

Fixed lineWidth setter, ignores <= 0

v1.x
Tj Holowaychuk 14 years ago
parent
commit
fb95c0bf25
  1. 7
      src/context2d.cc
  2. 6
      test/canvas.test.js

7
src/context2d.cc

@ -262,8 +262,11 @@ Context2d::GetLineWidth(Local<String> prop, const AccessorInfo &info) {
void
Context2d::SetLineWidth(Local<String> prop, Local<Value> val, const AccessorInfo &info) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
cairo_set_line_width(context->getContext(), val->NumberValue());
double n = val->NumberValue();
if (n > 0) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
cairo_set_line_width(context->getContext(), n);
}
}
/*

6
test/canvas.test.js

@ -260,6 +260,12 @@ module.exports = {
ctx.beginPath();
ctx.lineWidth = 10.0;
assert.equal(10, ctx.lineWidth);
// ctx.lineWidth = Infinity;
assert.equal(10, ctx.lineWidth);
ctx.lineWidth = -5;
assert.equal(10, ctx.lineWidth);
ctx.lineWidth = 0;
assert.equal(10, ctx.lineWidth);
ctx.moveTo(50, 50);
ctx.lineTo(50, 100);
ctx.lineTo(80, 120);

Loading…
Cancel
Save