mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
90 lines
2.2 KiB
JavaScript
90 lines
2.2 KiB
JavaScript
suite('RegularPolygon', function() {
|
|
// ======================================================
|
|
test('add regular polygon triangle', function() {
|
|
var stage = buildStage();
|
|
|
|
var layer = new Kinetic.Layer();
|
|
|
|
var poly = new Kinetic.RegularPolygon({
|
|
x: 200,
|
|
y: 100,
|
|
sides: 3,
|
|
radius: 50,
|
|
fill: 'green',
|
|
stroke: 'blue',
|
|
strokeWidth: 5,
|
|
name: 'foobar',
|
|
offset: {
|
|
x: 0,
|
|
y: -50
|
|
}
|
|
});
|
|
|
|
layer.add(poly);
|
|
stage.add(layer);
|
|
|
|
assert.equal(poly.getClassName(), 'RegularPolygon');
|
|
|
|
});
|
|
|
|
// ======================================================
|
|
test('add regular polygon square', function() {
|
|
var stage = buildStage();
|
|
var layer = new Kinetic.Layer();
|
|
|
|
var poly = new Kinetic.RegularPolygon({
|
|
x: 200,
|
|
y: 100,
|
|
sides: 4,
|
|
radius: 50,
|
|
fill: 'green',
|
|
stroke: 'blue',
|
|
strokeWidth: 5,
|
|
name: 'foobar'
|
|
});
|
|
|
|
layer.add(poly);
|
|
stage.add(layer);
|
|
});
|
|
|
|
// ======================================================
|
|
test('add regular polygon pentagon', function() {
|
|
var stage = buildStage();
|
|
var layer = new Kinetic.Layer();
|
|
|
|
var poly = new Kinetic.RegularPolygon({
|
|
x: 200,
|
|
y: 100,
|
|
sides: 5,
|
|
radius: 50,
|
|
fill: 'green',
|
|
stroke: 'blue',
|
|
strokeWidth: 5,
|
|
name: 'foobar'
|
|
});
|
|
|
|
layer.add(poly);
|
|
stage.add(layer);
|
|
});
|
|
|
|
// ======================================================
|
|
test('add regular polygon octogon', function() {
|
|
var stage = buildStage();
|
|
var layer = new Kinetic.Layer();
|
|
|
|
var poly = new Kinetic.RegularPolygon({
|
|
x: 200,
|
|
y: 100,
|
|
sides: 8,
|
|
radius: 50,
|
|
fill: 'green',
|
|
stroke: 'blue',
|
|
strokeWidth: 5,
|
|
name: 'foobar'
|
|
});
|
|
|
|
layer.add(poly);
|
|
stage.add(layer);
|
|
});
|
|
|
|
}); |