ctx.setLineDash([ 2 ]);
assert(0 === ctx.lineDashOffset, "dashOffset is 0");
ctx.lineDashOffset = 1;
assert(1 === ctx.lineDashOffset, "Setting dashOffset succeeded");
ctx.setLineDash([ ]);
assert(1 === ctx.lineDashOffset, "Changing dash does not reset dashOffset");
// NB: might want to add a |.dash = number| special case,
// don't test that it fails here. Might also want to add a
// |.dash = [0]| special case for resetting, so don't test
// that either. var badVals = [ -1,
null,
undefined, "", "string",
{ obj: true },
function() {}
]
ctx.setLineDash([ 2 ]);
for (var i = 0; i < badVals.length; ++i) { var error = false;
try { ctx.setLineDash(badVals[i]); }
catch(e) { error = true; }
assert(error &&
2 === ctx.getLineDash().length &&
2 === ctx.getLineDash()[0] &&
2 === ctx.getLineDash()[1], "Expected setLineDash("+ badVals[i] +") to throw exception and not change dash");
}
var ignoredVals = [
[ "array of string" ],
[ -1 ],
[ 2, "string" ],
];
ctx.setLineDash([ 2 ]);
for (var i = 0; i < ignoredVals.length; ++i) {
ctx.setLineDash(ignoredVals[i]);
assert(2 === ctx.getLineDash().length &&
2 === ctx.getLineDash()[0] &&
2 === ctx.getLineDash()[1], "Expected |setLineDash(" + ignoredVals[i] + ") to not change dash");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.