From 58de6e5d7ebe4438d9c8145dfb7a724735d8153c Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Thu, 28 Nov 2019 12:16:06 -0500 Subject: [PATCH 1/2] fix stretchable collisions --- src/symbol/collision_feature.js | 8 + src/symbol/shaping.js | 17 +- .../expected.png | Bin 0 -> 7785 bytes .../style.json | 156 ++++++++++++++++++ 4 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 test/integration/render-tests/icon-text-fit/stretch-nine-part-content-collision/expected.png create mode 100644 test/integration/render-tests/icon-text-fit/stretch-nine-part-content-collision/style.json diff --git a/src/symbol/collision_feature.js b/src/symbol/collision_feature.js index 47ebf2dafe0..82432831c38 100644 --- a/src/symbol/collision_feature.js +++ b/src/symbol/collision_feature.js @@ -43,6 +43,14 @@ class CollisionFeature { let x1 = shaped.left * boxScale - padding; let x2 = shaped.right * boxScale + padding; + const collisionPadding = shaped.collisionPadding; + if (collisionPadding) { + x1 -= collisionPadding[0] * boxScale; + y1 -= collisionPadding[1] * boxScale; + x2 += collisionPadding[2] * boxScale; + y2 += collisionPadding[3] * boxScale; + } + this.boxStartIndex = collisionBoxArray.length; if (alignLine) { diff --git a/src/symbol/shaping.js b/src/symbol/shaping.js index 47541b98c16..06a63c8fde8 100644 --- a/src/symbol/shaping.js +++ b/src/symbol/shaping.js @@ -745,7 +745,8 @@ export type PositionedIcon = { top: number, bottom: number, left: number, - right: number + right: number, + collisionPadding?: [number, number, number, number] }; function shapeIcon(image: ImagePosition, iconOffset: [number, number], iconAnchor: SymbolAnchor): PositionedIcon { @@ -769,6 +770,18 @@ function fitIconToText(shapedIcon: PositionedIcon, shapedText: Shaping, const image = shapedIcon.image; + let collisionPadding; + if (image.content) { + const content = image.content; + const pixelRatio = image.pixelRatio || 1; + collisionPadding = [ + content[0] / pixelRatio, + content[1] / pixelRatio, + image.displaySize[0] - content[2] / pixelRatio, + image.displaySize[1] - content[3] / pixelRatio + ]; + } + // We don't respect the icon-anchor, because icon-text-fit is set. Instead, // the icon will be centered on the text, then stretched in the given // dimensions. @@ -799,5 +812,5 @@ function fitIconToText(shapedIcon: PositionedIcon, shapedText: Shaping, bottom = top + image.displaySize[1]; } - return {image, top, right, bottom, left}; + return {image, top, right, bottom, left, collisionPadding}; } diff --git a/test/integration/render-tests/icon-text-fit/stretch-nine-part-content-collision/expected.png b/test/integration/render-tests/icon-text-fit/stretch-nine-part-content-collision/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..efa33d5b53aafc124176a7fe6d263fa6825b45ec GIT binary patch literal 7785 zcmcI}c{r5s|F0y5EQ3kogBbf{8~eUX##*C7BxA2+PeUSM5F*CDeaO-xyHNIh30bmb z-`8P?kmYylch0%4@A>Oo=Q`)QjJY1q{oLNqdwIRzuh$)R!|*yC%|A3`WMp(`9W4y_ zZU>)u2qpNPGTz2YMs@{-)>6NPJGar`?HjicuuPiTsqHl@-9#V|0Y$-N=SCZ|xUybY z|0obGn|5q7Dj#~5H>{Y(x_fu2r>w^}_tV=Qx2so;?|!*nI-eNKs$ck}HW{J}pD0|17oO_M0 zPfFzK|C=Qpc3boVQn27^8YErt@^HWq9C zEQ-mfpP=;(^hN%h!b-rM{0~p}Bx8oHRr&J0w2P zRU*P;mET@~{K>@09d>22?$IIbqZ4&-OQOHk7?m0Q&D2TL+W2|x70c(pFC?4) zvsGymy4xzA=Scl_L%A~UsmcK#9_3o41VKO{Fd77H?q!(A+G^yyy@7Rh{AbDP!^!Yl zw>HUOkaMq$kU=O@si%CwkHV`61kBt40h$%owH(M%w{YBlpZRm6Md`A3t#{jR_{Lz; z+oRd1Mgs%GVLuldP_$}LtQoc+)9Tjr&HCYLaAZ-5laotQ)TH%?GpyWCG1a5AD zM@;_SP5%@aw6XBYJlS`=&@B?Fvr^9qx87_pN;EDD>J#p2ED_cZv32glq|ytV{F^bf z$8RWeB{RPSHl@aSx+Zo?9nyr>(tF0-dvdfXKWQ5NK-XTs_EmK%5{_@E`YbufQP@1U zH|s9PRnM167@JspBs62J`(9Ziw8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}GEb8eZ zrsT8X^!$o~p%gpzASh*45^OJ@-1f}dR@TsA&OA!)bQ{`2p|eKp`=JSJfe&Q z(-+KMbd*=@oU-W~j{`Vi{gf$Xd3j}atB;18g{9ES-IDPw62?i~7vZ?~X>c&E*z@Ee ze)r&u{7iK(Ik>im*qPBDP`&%4+Ma%%6L9H!Y8t*0x!4k4k^=BW zpC=J^N=o5$`?(q!(VHClKvyG^tLAtD^ssjQCK+Ctn|Dk!fwFvt5*IJKiC39j(C^7W z@4k7yu4vjB<1LHIugVF?v&2y}p{Rq&!DGvu%Ro6@WD&`-!lL&2ZXSGPalUK&7!nVMFoN;(*A zS*{eG6%ojMpu~rOBbd6vkRGBJNaDounJeoW*5~72zOo5H>+0CK`!UY-dsM-jPyoJ~ zlS&0hbidp`moqj=fkfj6A>ks+fmyl;C#}ezVb?;8c_^t>To@eP{2?BitBjmn1!5a` z^~~a`D+mh1kd%l)rxFSGs=>c<>wEF7+81-$@-8DL>Mn`+#n%Y`ozPq);{jUcq&R>Z1cYmg^vTtMm;Rmk>T4ytE*2+rAW+HjCG&Jo*8jN`>$hlB{ zW$Ex!?@d)Enh+gyXFY;L$#+V1j)7J@=0P%UqPQ71R|))Q_Ss50yztBG_&t7~Lxtje z6liC_0A7Jy&Ar7hc==sK@D9NB0`@as?5*jA!IU?dwgSyuH!d^`5?xnJ>R6NL*yv|Cd4boHq z)EEDNGLc`mnE8^_C|hOV#W=V3;2e+Pm_cIf-eN_EY*%sYM8K}^dR@jF7&$Ifs4pa7 zlj}xAS&Ty>=Lwyc`&Ffkj6bJw7nPfH{`V6^!Df4H9h%}}dA!|LUK0r^}2MF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/render-tests/icon-text-fit/stretch-nine-part-content-collision/style.json b/test/integration/render-tests/icon-text-fit/stretch-nine-part-content-collision/style.json new file mode 100644 index 00000000000..b7d16e7207c --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/stretch-nine-part-content-collision/style.json @@ -0,0 +1,156 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/stretch", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "ABC", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "icon-image": "nine-part-content", + "icon-text-fit": "both" + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "ABC", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "icon-image": "nine-part-content", + "icon-text-fit": "both" + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "ABC", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "icon-image": "nine-part-content", + "icon-text-fit": "both" + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "ABC", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "icon-image": "nine-part-content", + "icon-text-fit": "both" + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "ABC", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "icon-image": "nine-part-content", + "icon-text-fit": "both" + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "ABC", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "icon-image": "nine-part-content", + "icon-text-fit": "both" + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "ABC", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "icon-image": "nine-part-content", + "icon-text-fit": "both" + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "ABC", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "icon-image": "nine-part-content", + "icon-text-fit": "both" + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "ABC", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "icon-image": "nine-part-content", + "icon-text-fit": "both" + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} From 2c4278dccc1c1ccd70b21fb121b6b1d575998459 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Thu, 28 Nov 2019 12:26:59 -0500 Subject: [PATCH 2/2] fix tests --- test/unit/symbol/shaping.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/symbol/shaping.test.js b/test/unit/symbol/shaping.test.js index 6dce3ef180e..f427d516f14 100644 --- a/test/unit/symbol/shaping.test.js +++ b/test/unit/symbol/shaping.test.js @@ -216,6 +216,7 @@ test('fitIconToText', (t) => { bottom: 10, left: -10, right: 10, + collisionPadding: undefined, image: Object.freeze({ pixelRatio: 1, displaySize: [ 20, 20 ], @@ -233,6 +234,7 @@ test('fitIconToText', (t) => { t.test('icon-text-fit: width', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'width', [0, 0, 0, 0], [0, 0], 24 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: 0, right: 20, bottom: 20, @@ -241,6 +243,7 @@ test('fitIconToText', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'width', [0, 0, 0, 0], [3, 7], 24 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: 7, right: 23, bottom: 27, @@ -249,6 +252,7 @@ test('fitIconToText', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'width', [0, 0, 0, 0], [0, 0], 12 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -5, right: 10, bottom: 15, @@ -258,6 +262,7 @@ test('fitIconToText', (t) => { // Ignores padding for top/bottom, since the icon is only stretched to the text's width but not height t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'width', [ 5, 10, 5, 10 ], [0, 0], 12 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -5, right: 20, bottom: 15, @@ -270,6 +275,7 @@ test('fitIconToText', (t) => { t.test('icon-text-fit: height', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'height', [0, 0, 0, 0], [0, 0], 24 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -10, right: -10, bottom: 30, @@ -278,6 +284,7 @@ test('fitIconToText', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'height', [0, 0, 0, 0], [3, 7], 24 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -3, right: -7, bottom: 37, @@ -286,6 +293,7 @@ test('fitIconToText', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'height', [0, 0, 0, 0], [0, 0], 12 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -5, right: 0, bottom: 15, @@ -295,6 +303,7 @@ test('fitIconToText', (t) => { // Ignores padding for left/right, since the icon is only stretched to the text's height but not width t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'height', [ 5, 10, 5, 10 ], [0, 0], 12 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -10, right: 0, bottom: 20, @@ -307,6 +316,7 @@ test('fitIconToText', (t) => { t.test('icon-text-fit: both', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'both', [0, 0, 0, 0], [0, 0], 24 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -10, right: 20, bottom: 30, @@ -315,6 +325,7 @@ test('fitIconToText', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'both', [0, 0, 0, 0], [3, 7], 24 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -3, right: 23, bottom: 37, @@ -323,6 +334,7 @@ test('fitIconToText', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'both', [0, 0, 0, 0], [0, 0], 12 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -5, right: 10, bottom: 15, @@ -331,6 +343,7 @@ test('fitIconToText', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'both', [ 5, 10, 5, 10 ], [0, 0], 12 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -10, right: 20, bottom: 20, @@ -339,6 +352,7 @@ test('fitIconToText', (t) => { t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'both', [ 0, 5, 10, 15 ], [0, 0], 12 / glyphSize), { image: shapedIcon.image, + collisionPadding: undefined, top: -5, right: 15, bottom: 25,