Hit detect everything with a pixel ratio of 1

This commit is contained in:
Andreas Hocevar
2020-07-27 19:56:35 +02:00
parent cad5057a96
commit ac5f52a21f
7 changed files with 50 additions and 71 deletions

View File

@@ -12,8 +12,8 @@ describe('ol.style.Circle', function () {
expect(style.getOrigin()).to.eql([0, 0]);
expect(style.getAnchor()).to.eql([10.5, 10.5]);
// no hit-detection image is created, because no fill style is set
expect(style.getImage(1)).to.be(style.getHitDetectionImage(1));
expect(style.getHitDetectionImage(1)).to.be.an(HTMLCanvasElement);
expect(style.getImage(1)).to.be(style.getHitDetectionImage());
expect(style.getHitDetectionImage()).to.be.an(HTMLCanvasElement);
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
});
@@ -30,8 +30,8 @@ describe('ol.style.Circle', function () {
expect(style.getOrigin()).to.eql([0, 0]);
expect(style.getAnchor()).to.eql([10.5, 10.5]);
// hit-detection image is created, because transparent fill style is set
expect(style.getImage(1)).to.not.be(style.getHitDetectionImage(1));
expect(style.getHitDetectionImage(1)).to.be.an(HTMLCanvasElement);
expect(style.getImage(1)).to.not.be(style.getHitDetectionImage());
expect(style.getHitDetectionImage()).to.be.an(HTMLCanvasElement);
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
});
@@ -48,8 +48,8 @@ describe('ol.style.Circle', function () {
expect(style.getOrigin()).to.eql([0, 0]);
expect(style.getAnchor()).to.eql([10.5, 10.5]);
// no hit-detection image is created, because non-transparent fill style is set
expect(style.getImage(1)).to.be(style.getHitDetectionImage(1));
expect(style.getHitDetectionImage(1)).to.be.an(HTMLCanvasElement);
expect(style.getImage(1)).to.be(style.getHitDetectionImage());
expect(style.getHitDetectionImage()).to.be.an(HTMLCanvasElement);
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
});
});

View File

@@ -38,8 +38,8 @@ describe('ol.style.RegularShape', function () {
expect(style.getOrigin()).to.eql([0, 0]);
expect(style.getAnchor()).to.eql([10.5, 10.5]);
// no hit-detection image is created, because no fill style is set
expect(style.getImage(1)).to.be(style.getHitDetectionImage(1));
expect(style.getHitDetectionImage(1)).to.be.an(HTMLCanvasElement);
expect(style.getImage(1)).to.be(style.getHitDetectionImage());
expect(style.getHitDetectionImage()).to.be.an(HTMLCanvasElement);
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
});
@@ -59,11 +59,10 @@ describe('ol.style.RegularShape', function () {
expect(style.getOrigin()).to.eql([0, 0]);
expect(style.getAnchor()).to.eql([10.5, 10.5]);
// hit-detection image is created, because transparent fill style is set
expect(style.getImage(1)).to.not.be(style.getHitDetectionImage(1));
expect(style.getHitDetectionImage(1)).to.be.an(HTMLCanvasElement);
expect(style.getImage(1)).to.not.be(style.getHitDetectionImage());
expect(style.getHitDetectionImage()).to.be.an(HTMLCanvasElement);
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
expect(style.getHitDetectionImage(1).width).to.be(21);
expect(style.getHitDetectionImage(2).width).to.be(42);
expect(style.getHitDetectionImage().width).to.be(21);
});
it('creates a canvas (non-transparent fill-style)', function () {
@@ -79,8 +78,8 @@ describe('ol.style.RegularShape', function () {
expect(style.getOrigin()).to.eql([0, 0]);
expect(style.getAnchor()).to.eql([10.5, 10.5]);
// no hit-detection image is created, because non-transparent fill style is set
expect(style.getImage(1)).to.be(style.getHitDetectionImage(1));
expect(style.getHitDetectionImage(1)).to.be.an(HTMLCanvasElement);
expect(style.getImage(1)).to.be(style.getHitDetectionImage());
expect(style.getHitDetectionImage()).to.be.an(HTMLCanvasElement);
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
});