Add hit-detection image to atlas (RegularShape)
This commit is contained in:
@@ -5,18 +5,40 @@ describe('ol.style.RegularShape', function() {
|
||||
|
||||
describe('#constructor', function() {
|
||||
|
||||
it('creates a canvas if no atlas is used', function() {
|
||||
it('creates a canvas if no atlas is used (no fill-style)', function() {
|
||||
var style = new ol.style.RegularShape({radius: 10});
|
||||
expect(style.getImage()).to.be.an(HTMLCanvasElement);
|
||||
expect(style.getSize()).to.eql([21, 21]);
|
||||
expect(style.getImageSize()).to.eql([21, 21]);
|
||||
expect(style.getOrigin()).to.eql([0, 0]);
|
||||
expect(style.getAnchor()).to.eql([10.5, 10.5]);
|
||||
// hit-detection image is created, because no fill style is set
|
||||
expect(style.getImage()).to.not.be(style.getHitDetectionImage());
|
||||
expect(style.getHitDetectionImage()).to.be.an(HTMLCanvasElement);
|
||||
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
|
||||
expect(style.getHitDetectionOrigin()).to.eql([0, 0]);
|
||||
});
|
||||
|
||||
it('adds itself to an atlas manager', function() {
|
||||
it('creates a canvas if no atlas is used (fill-style)', function() {
|
||||
var style = new ol.style.RegularShape({
|
||||
radius: 10,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#FFFF00'
|
||||
})
|
||||
});
|
||||
expect(style.getImage()).to.be.an(HTMLCanvasElement);
|
||||
expect(style.getSize()).to.eql([21, 21]);
|
||||
expect(style.getImageSize()).to.eql([21, 21]);
|
||||
expect(style.getOrigin()).to.eql([0, 0]);
|
||||
expect(style.getAnchor()).to.eql([10.5, 10.5]);
|
||||
// no hit-detection image is created, because fill style is set
|
||||
expect(style.getImage()).to.be(style.getHitDetectionImage());
|
||||
expect(style.getHitDetectionImage()).to.be.an(HTMLCanvasElement);
|
||||
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
|
||||
expect(style.getHitDetectionOrigin()).to.eql([0, 0]);
|
||||
});
|
||||
|
||||
it('adds itself to an atlas manager (no fill-style)', function() {
|
||||
var atlasManager = new ol.style.AtlasManager({size: 512});
|
||||
var style = new ol.style.RegularShape(
|
||||
{radius: 10, atlasManager: atlasManager});
|
||||
@@ -25,8 +47,32 @@ describe('ol.style.RegularShape', function() {
|
||||
expect(style.getImageSize()).to.eql([512, 512]);
|
||||
expect(style.getOrigin()).to.eql([1, 1]);
|
||||
expect(style.getAnchor()).to.eql([10.5, 10.5]);
|
||||
// hit-detection image is created, because no fill style is set
|
||||
expect(style.getImage()).to.not.be(style.getHitDetectionImage());
|
||||
expect(style.getHitDetectionImage()).to.be.an(HTMLCanvasElement);
|
||||
expect(style.getHitDetectionImageSize()).to.eql([512, 512]);
|
||||
expect(style.getHitDetectionOrigin()).to.eql([1, 1]);
|
||||
});
|
||||
|
||||
it('adds itself to an atlas manager (fill-style)', function() {
|
||||
var atlasManager = new ol.style.AtlasManager({size: 512});
|
||||
var style = new ol.style.RegularShape({
|
||||
radius: 10,
|
||||
atlasManager: atlasManager,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#FFFF00'
|
||||
})
|
||||
});
|
||||
expect(style.getImage()).to.be.an(HTMLCanvasElement);
|
||||
expect(style.getSize()).to.eql([21, 21]);
|
||||
expect(style.getImageSize()).to.eql([512, 512]);
|
||||
expect(style.getOrigin()).to.eql([1, 1]);
|
||||
expect(style.getAnchor()).to.eql([10.5, 10.5]);
|
||||
// no hit-detection image is created, because fill style is set
|
||||
expect(style.getImage()).to.be(style.getHitDetectionImage());
|
||||
expect(style.getHitDetectionImage()).to.be.an(HTMLCanvasElement);
|
||||
expect(style.getHitDetectionImageSize()).to.eql([512, 512]);
|
||||
expect(style.getHitDetectionOrigin()).to.eql([1, 1]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user