I have the following code in a simple, html file:
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<div id="container"></div>
<script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.3.0-beta2.js"> </script>
<script>
var stage = new Kinetic.Stage({
container: 'container',
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
var redLine = new Kinetic.Line({
points: [0, 0, 75, 75, 150, 150],
stroke: 'red',
strokeWidth: 2,
lineCap: 'round',
lineJoin: 'round'
});
layer.add(redLine);
stage.add(layer);
</script>
This code is supposed to draw a very simple, single line, from the top, left of the browser space, to 150, 150.
However, when I test this, nothing is drawn on the page.
I'm on Windows Vista Business, up to date, I'm using Google Chrome Version 23.0.1271.97 m.
Now, if I add another set of points in the points array - to look like this:
points: [0, 0, 75, 75, 150, 150, 300, 300],
when I reload the page including this change, the code works as expected.
Now, further play and research, turned that, if I want to keep this array:
points: [0, 0, 75, 75, 150, 150],
I have to add the following, in the line configuration code:
dashArray: [1, 1]
with the "dashArray" property, the line is correctly drawn with the initial array problem.
var redLine = new Kinetic.Line({
points: [0, 0, 75, 75, 150, 150],
stroke: 'red',
strokeWidth: 2,
lineCap: 'round',
lineJoin: 'round',
dashArray: [1, 1]
});
Is this a bug?
Is this expected behavior? I cannot find any documentation about this.
Thank you!