Use the default fill and stroke color

This commit is contained in:
Frederic Junod
2017-03-02 17:14:31 +01:00
parent 49af45c8b7
commit 1d3eb2eb6e
4 changed files with 107 additions and 77 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -37,93 +37,115 @@ describe('ol.rendering.style.RegularShape', function() {
return map;
}
function createFeatures(stroke, fill) {
var feature;
feature = new ol.Feature({
geometry: new ol.geom.Point([-15, 15])
});
// square
feature.setStyle(new ol.style.Style({
image: new ol.style.RegularShape({
fill: fill,
stroke: stroke,
points: 4,
radius: 10,
angle: Math.PI / 4
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature({
geometry: new ol.geom.Point([8, 15])
});
// triangle
feature.setStyle(new ol.style.Style({
image: new ol.style.RegularShape({
fill: fill,
stroke: stroke,
points: 3,
radius: 10,
rotation: Math.PI / 4,
angle: 0
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature({
geometry: new ol.geom.Point([-10, -8])
});
// star
feature.setStyle(new ol.style.Style({
image: new ol.style.RegularShape({
fill: fill,
stroke: stroke,
points: 5,
radius: 10,
radius2: 4,
angle: 0
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature({
geometry: new ol.geom.Point([12, -8])
});
// cross
feature.setStyle(new ol.style.Style({
image: new ol.style.RegularShape({
fill: fill,
stroke: stroke,
points: 4,
radius: 10,
radius2: 0,
angle: 0
})
}));
vectorSource.addFeature(feature);
}
describe('#render', function() {
var stroke = new ol.style.Stroke({width: 2});
var fill = new ol.style.Fill({color: 'red'});
afterEach(function() {
disposeMap(map);
});
function createFeatures() {
var stroke = new ol.style.Stroke({color: 'black', width: 2});
var fill = new ol.style.Fill({color: 'red'});
var feature;
feature = new ol.Feature({
geometry: new ol.geom.Point([-15, 15])
});
// square
feature.setStyle(new ol.style.Style({
image: new ol.style.RegularShape({
fill: fill,
stroke: stroke,
points: 4,
radius: 10,
angle: Math.PI / 4
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature({
geometry: new ol.geom.Point([8, 15])
});
// triangle
feature.setStyle(new ol.style.Style({
image: new ol.style.RegularShape({
fill: fill,
stroke: stroke,
points: 3,
radius: 10,
rotation: Math.PI / 4,
angle: 0
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature({
geometry: new ol.geom.Point([-10, -8])
});
// star
feature.setStyle(new ol.style.Style({
image: new ol.style.RegularShape({
fill: fill,
stroke: stroke,
points: 5,
radius: 10,
radius2: 4,
angle: 0
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature({
geometry: new ol.geom.Point([12, -8])
});
// cross
feature.setStyle(new ol.style.Style({
image: new ol.style.RegularShape({
fill: fill,
stroke: stroke,
points: 4,
radius: 10,
radius2: 0,
angle: 0
})
}));
vectorSource.addFeature(feature);
}
it('tests the canvas renderer', function(done) {
map = createMap('canvas');
createFeatures();
expectResemble(map, 'spec/ol/style/expected/regularshape-canvas.png',
9.4, done);
createFeatures(stroke, fill);
expectResemble(map, 'spec/ol/style/expected/regularshape-canvas.png', 9.4, done);
});
it('tests the WebGL renderer', function(done) {
assertWebGL();
map = createMap('webgl');
createFeatures();
expectResemble(map, 'spec/ol/style/expected/regularshape-webgl.png',
8.2, done);
createFeatures(stroke, fill);
expectResemble(map, 'spec/ol/style/expected/regularshape-webgl.png', 8.2, done);
});
});
describe('uses the default fill and stroke color', function() {
var stroke = new ol.style.Stroke();
var fill = new ol.style.Fill();
afterEach(function() {
disposeMap(map);
});
it('tests the canvas renderer', function(done) {
map = createMap('canvas');
createFeatures(stroke, fill);
expectResemble(map, 'spec/ol/style/expected/regularshape-canvas-default-style.png', 3.0, done);
});
it('tests the WebGL renderer', function(done) {
assertWebGL();
map = createMap('webgl');
createFeatures(stroke, fill);
expectResemble(map, 'spec/ol/style/expected/regularshape-webgl-default-style.png', 3.0, done);
});
});
});