Video player ui fix

This commit is contained in:
Brahim Hadriche committed 2026-11-20 16:18:27 -05:00
1 parent a049147149
commit 12d9b25762
69 files changed
+430 -19

No files matched your search

+3
View File
@@ -5,6 +5,9 @@ on:
branches: ["main"]
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
+1
View File
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- DRM playback errors on certain TVs, by filtering out FairPlay-only streams
- Player seek bar and backdrop missing on some devices
## [0.48.10] - 2026-10-17
@@ -19,13 +19,13 @@
<!-- Dim side panels paint first (behind the tiles): VOD storyboard tiles cover them; on live (empty
tiles) they show through as the filmstrip structure. -->
<Poster id="bifSideL2" translation="[-36, 42]" width="250" height="141" opacity="0.15"
uri="/RokuOS/Artwork/SceneGraph/GenevaTheme/Base/FHD/imageFootprint.9.png" loadDisplayMode="noScale" />
uri="pkg:/images/player/imageFootprint.9.png" loadDisplayMode="noScale" />
<Poster id="bifSideL1" translation="[226, 42]" width="250" height="141" opacity="0.15"
uri="/RokuOS/Artwork/SceneGraph/GenevaTheme/Base/FHD/imageFootprint.9.png" loadDisplayMode="noScale" />
uri="pkg:/images/player/imageFootprint.9.png" loadDisplayMode="noScale" />
<Poster id="bifSideR1" translation="[804, 42]" width="250" height="141" opacity="0.15"
uri="/RokuOS/Artwork/SceneGraph/GenevaTheme/Base/FHD/imageFootprint.9.png" loadDisplayMode="noScale" />
uri="pkg:/images/player/imageFootprint.9.png" loadDisplayMode="noScale" />
<Poster id="bifSideR2" translation="[1066, 42]" width="250" height="141" opacity="0.15"
uri="/RokuOS/Artwork/SceneGraph/GenevaTheme/Base/FHD/imageFootprint.9.png" loadDisplayMode="noScale" />
uri="pkg:/images/player/imageFootprint.9.png" loadDisplayMode="noScale" />
<!-- Storyboard tiles, oversized + clippingRect picks the cell; center has a gradient overlay + frame. -->
<Poster id="bifTileL2" loadDisplayMode="scaleToFill" />
<Poster id="bifTileL1" loadDisplayMode="scaleToFill" />
@@ -33,9 +33,9 @@
<!-- ABOVE the center tile (the stock layering): keeps the white scan glyph legible over a bright
frame. The glyph itself rides the TrickPlayBar handle, a later Chrome sibling. -->
<Poster id="bifCenterGradient" translation="[488, 12]" width="304" height="171"
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/PauseGradientThumbnail.9.png" loadDisplayMode="noScale" />
uri="pkg:/images/player/PauseGradientThumbnail.png" loadDisplayMode="noScale" />
<Poster id="bifFrame" translation="[476, 0]" width="328" height="196"
uri="/RokuOS/Artwork/SceneGraph/GenevaTheme/Base/FHD/focus_grid.9.png" loadDisplayMode="noScale" />
uri="pkg:/images/player/focus_grid.$$RES$$.9.png" loadDisplayMode="noScale" />
<Poster id="bifTileR1" loadDisplayMode="scaleToFill" />
<Poster id="bifTileR2" loadDisplayMode="scaleToFill" />
</children>
@@ -23,7 +23,7 @@
<Timer id="hold" duration="1.0" repeat="false" />
<Poster id="poster" visible="false" opacity="0"
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/LargePause.png"
uri="pkg:/images/icons/player/LargePause.png"
width="80" height="80" translation="[600, 320]" scaleRotateCenter="[40, 40]"
scale="[0.75, 0.75]" blendColor="0xFFFFFFFF" loadDisplayMode="noScale" />
</children>
@@ -14,9 +14,12 @@ end enum
function Init()
m.loadingGroup = m.top.findNode("loadingTitleArea")
m.spinner = m.top.findNode("spinner")
' blendColor lives on the BusySpinner's poster child, not the spinner node.
' blendColor and size live on the BusySpinner's poster child, not the spinner node. Sized explicitly: the
' bitmap's size in design units varies with the device's UI resolution.
if m.spinner <> invalid and m.spinner.poster <> invalid
m.spinner.poster.blendColor = "#FF1C30FF"
m.spinner.poster.width = 80
m.spinner.poster.height = 80
end if
m.top.ObserveField("mode", FuncName(OnMode))
OnMode()
@@ -21,6 +21,6 @@
</LayoutGroup>
<!-- Shared by both modes; translation centers the 80x80 spinner. -->
<BusySpinner id="spinner" translation="[600, 320]" visible="false" spinInterval="1"
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/Spinner_MH.webp" />
uri="pkg:/images/icons/player/Spinner_MH.png" />
</children>
</component>
@@ -6,7 +6,7 @@ import "pkg:/source/utils/Types.bs"
' Every input field is observed in Init and repaints on change, except glyph, focused and the SponsorBlock
' tint, which update only their own piece.
const GLYPH_ASSET_BASE = "/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/"
const GLYPH_ASSET_BASE = "pkg:/images/icons/player/"
function Init()
m.trackFill = m.top.findNode("trackFill")
@@ -131,6 +131,23 @@ namespace Tests
m.assertEqual(handle.translation[1], 22.0)
end function
@it("points every glyph, the handle, the track and the LIVE bullet at a bundled file")
function _()
file = CreateObject("roByteArray")
sg = m.top.findNode("scanGlyph")
for glyph = TransportController.Glyph.SkipBack to TransportController.Glyph.Replay
m.top.glyph = glyph
m.assertTrue(file.ReadFile(sg.uri), sg.uri)
end for
m.top.glyph = TransportController.Glyph.None
track = m.top.findNode("trackBg").uri
for each res in ["480p", "720p", "1080p"]
m.assertTrue(file.ReadFile(track.Replace("$$RES$$", res)), track)
end for
m.assertTrue(file.ReadFile(m.top.findNode("handle").uri))
m.assertTrue(file.ReadFile(m.top.findNode("bullet").uri))
end function
@describe("TrickPlayBar — LIVE projection")
@it("BEHIND the edge: fill/playhead are PROPORTIONAL to cursor within the DVR window + offset label")
@@ -24,11 +24,11 @@
</interface>
<children>
<Poster id="trackBg"
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/osd_sliderControl_small.9.png"
uri="pkg:/images/player/osd_sliderControl_small.$$RES$$.9.png"
width="1144" height="12" opacity="0.3" loadDisplayMode="noScale" />
<!-- same asset tinted red, clipped to progress width in code. -->
<Poster id="trackFill"
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/osd_sliderControl_small.9.png"
uri="pkg:/images/player/osd_sliderControl_small.$$RES$$.9.png"
width="1144" height="12" blendColor="0xFF1C30FF" clippingRect="[0,0,0,12]" loadDisplayMode="noScale" />
<!-- the cursor: a 12px dot that swells half-again while the bar tier holds focus. PositionPlayhead
moves it; the grow/shrink animations scale it about its center. -->
@@ -44,7 +44,7 @@
</Animation>
<!-- handle: pinned at bar-center. {547,22} rest, {547,-54} active. -->
<Poster id="handle"
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/videoProgressBarHandle.9.png"
uri="pkg:/images/player/videoProgressBarHandle.9.png"
translation="[547, 22]" width="50" height="30" loadDisplayMode="noScale">
<Poster id="scanGlyph" visible="false" width="50" height="30" loadDisplayMode="noScale" />
</Poster>
@@ -61,8 +61,8 @@
</Label>
<!-- LIVE bullet: shown only at the edge. -->
<Poster id="bullet" visible="false"
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/icon_inline_unselected_bullet.webp"
translation="[1056, 24]" blendColor="0xD53E5AFF" loadDisplayMode="noScale" />
uri="pkg:/images/icons/player/icon_inline_unselected_bullet.png"
translation="[1056, 24]" width="24" height="24" blendColor="0xD53E5AFF" loadDisplayMode="noScale" />
<!-- LIVE badge: shown only at the edge. -->
<Label id="liveLabel" visible="false" translation="[1080, 24]" height="30"
text="LIVE" color="0xFEFEFEFF" horizAlign="left" vertAlign="top">
@@ -77,7 +77,7 @@
<Group id="Chrome" opacity="0" visible="false">
<!-- Full-screen darkening scrim, chrome-gated (rides the fade), not pause-gated. -->
<Poster id="pauseGradient"
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/PauseGradient.9.png"
uri="pkg:/images/player/PauseGradient.png"
width="1280" height="720" />
<!-- First content sibling: its full-screen black backdrop must paint UNDER the title/bar/buttons
Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
<g fill="#FFF" stroke="#000" stroke-opacity="0.12" stroke-width="3" paint-order="stroke"><rect x="3" y="3" width="48" height="114" rx="4"/><rect x="69" y="3" width="48" height="114" rx="4"/></g>
</svg>

After

Width:  |  Height:  |  Size: 290 B

@@ -0,0 +1,11 @@
{
inputHash: '365d573b68143d3d9833785535315f05',
outputs: [
{
outputFilePath: 'images/icons/player/LargePause.png',
outputHash: 'e5d6bcc5e4d32775aa355aed829d6786',
width: 120,
height: 120,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
<foreignObject width="120" height="120"><div xmlns="http://www.w3.org/1999/xhtml" style="width:120px;height:120px;border-radius:50%;background:conic-gradient(rgba(255,255,255,0) 10deg,#FFF 360deg);-webkit-mask:radial-gradient(closest-side,transparent calc(100% - 7.5px),#000 calc(100% - 6.5px));mask:radial-gradient(closest-side,transparent calc(100% - 7.5px),#000 calc(100% - 6.5px))"/></foreignObject><circle cx="60" cy="3.5" r="3.5" fill="#FFF"/>
</svg>

After

Width:  |  Height:  |  Size: 545 B

@@ -0,0 +1,11 @@
{
inputHash: '05e22fbe084aba15195e28fed76638d3',
outputs: [
{
outputFilePath: 'images/icons/player/Spinner_MH.png',
outputHash: '11ace03cf9aeab9866ffdde4a78345d9',
width: 120,
height: 120,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
<g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><g opacity="0.2"><path d="M25 3.5 L48 22.5 L25 41.5 Z"/><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g><path d="M5 3.5 L28 22.5 L5 41.5 Z"/></g>
</svg>

After

Width:  |  Height:  |  Size: 308 B

@@ -0,0 +1,11 @@
{
inputHash: '0986e8af2b2ff759cba17d83ef63c2fd',
outputs: [
{
outputFilePath: 'images/icons/player/icon_FFx1.png',
outputHash: '0977d7dd03d3bd50c6c17a24977e78f1',
width: 75,
height: 45,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
<g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><g opacity="0.2"><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g><path d="M5 3.5 L28 22.5 L5 41.5 Z"/><path d="M25 3.5 L48 22.5 L25 41.5 Z"/></g>
</svg>

After

Width:  |  Height:  |  Size: 308 B

@@ -0,0 +1,11 @@
{
inputHash: '469eb45aa9d725130b41ea54bd193270',
outputs: [
{
outputFilePath: 'images/icons/player/icon_FFx2.png',
outputHash: 'eba816c002bd6fc834ef956681fb2dc0',
width: 75,
height: 45,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
<g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><path d="M5 3.5 L28 22.5 L5 41.5 Z"/><path d="M25 3.5 L48 22.5 L25 41.5 Z"/><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g>
</svg>

After

Width:  |  Height:  |  Size: 287 B

@@ -0,0 +1,11 @@
{
inputHash: '980f9d24e3a1cb5c63b20009d9a16133',
outputs: [
{
outputFilePath: 'images/icons/player/icon_FFx3.png',
outputHash: '251be69bc462cd2e0f757c57eb24ad2c',
width: 75,
height: 45,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
<g transform="translate(75 0) scale(-1 1)"><g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><g opacity="0.2"><path d="M25 3.5 L48 22.5 L25 41.5 Z"/><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g><path d="M5 3.5 L28 22.5 L5 41.5 Z"/></g></g>
</svg>

After

Width:  |  Height:  |  Size: 355 B

@@ -0,0 +1,11 @@
{
inputHash: 'fe8c1802a9432a779db5b47a8aee3cf2',
outputs: [
{
outputFilePath: 'images/icons/player/icon_RWx1.png',
outputHash: '69d38e14fa66c0fd8132b4baf6d5b2e4',
width: 75,
height: 45,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
<g transform="translate(75 0) scale(-1 1)"><g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><g opacity="0.2"><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g><path d="M5 3.5 L28 22.5 L5 41.5 Z"/><path d="M25 3.5 L48 22.5 L25 41.5 Z"/></g></g>
</svg>

After

Width:  |  Height:  |  Size: 355 B

@@ -0,0 +1,11 @@
{
inputHash: '8008033b27507ebaee97e12b928037cc',
outputs: [
{
outputFilePath: 'images/icons/player/icon_RWx2.png',
outputHash: '5a65af95686da53580b631d54d2b85cc',
width: 75,
height: 45,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
<g transform="translate(75 0) scale(-1 1)"><g fill="#EFEFEF" stroke="#EFEFEF" stroke-width="2" stroke-linejoin="round"><path d="M5 3.5 L28 22.5 L5 41.5 Z"/><path d="M25 3.5 L48 22.5 L25 41.5 Z"/><path d="M45 3.5 L68 22.5 L45 41.5 Z"/></g></g>
</svg>

After

Width:  |  Height:  |  Size: 334 B

@@ -0,0 +1,11 @@
{
inputHash: '56cd45de7037c14773f5491e19998fce',
outputs: [
{
outputFilePath: 'images/icons/player/icon_RWx3.png',
outputHash: 'df054ef7dbdcf7f72ea68ff411d5fba1',
width: 75,
height: 45,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
<circle cx="18" cy="18" r="8" fill="#ABABAB"/>
</svg>

After

Width:  |  Height:  |  Size: 138 B

@@ -0,0 +1,11 @@
{
inputHash: 'fc641b4b8ae0068b538a47f8e9651e5f',
outputs: [
{
outputFilePath: 'images/icons/player/icon_inline_unselected_bullet.png',
outputHash: '44c1d2244a8107af370b49e0fc3675e1',
width: 36,
height: 36,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
<path d="M20 21.5 A17.5 17.5 0 1 1 25.13 34.87" fill="none" stroke="#EFEFEF" stroke-width="5.5" stroke-linecap="round"/><path d="M14.5 20.5 L27.5 20.5 L21 29.5 Z" fill="#EFEFEF" stroke="#EFEFEF" stroke-width="1.5" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 331 B

@@ -0,0 +1,11 @@
{
inputHash: '1cffb669ee3c117ac532eda41ec434fe',
outputs: [
{
outputFilePath: 'images/icons/player/icon_replay.png',
outputHash: 'daa27ea7c4054f8b136858e6493d8659',
width: 75,
height: 45,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
<g fill="#EFEFEF"><rect x="24" y="4" width="12" height="37" rx="2"/><rect x="43" y="4" width="12" height="37" rx="2"/><path d="M61 13.5 L72 22.5 L61 31.5 Z" stroke="#EFEFEF" stroke-width="1.5" stroke-linejoin="round"/></g>
</svg>

After

Width:  |  Height:  |  Size: 314 B

@@ -0,0 +1,11 @@
{
inputHash: 'fb19f5f7f3362920f0ef2a6f03d820d4',
outputs: [
{
outputFilePath: 'images/icons/player/icon_skipAhead.png',
outputHash: '51451f2ca9549a22309c8ed2a8870173',
width: 75,
height: 45,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="75" height="45" viewBox="0 0 75 45">
<g transform="translate(75 0) scale(-1 1)"><g fill="#EFEFEF"><rect x="24" y="4" width="12" height="37" rx="2"/><rect x="43" y="4" width="12" height="37" rx="2"/><path d="M61 13.5 L72 22.5 L61 31.5 Z" stroke="#EFEFEF" stroke-width="1.5" stroke-linejoin="round"/></g></g>
</svg>

After

Width:  |  Height:  |  Size: 361 B

@@ -0,0 +1,11 @@
{
inputHash: '8cf579b165111dc7afdf0841d1bc72cb',
outputs: [
{
outputFilePath: 'images/icons/player/icon_skipBack.png',
outputHash: '88283d74a134cc21e5a46103661cc909',
width: 75,
height: 45,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1080" viewBox="0 0 1 1080" preserveAspectRatio="none">
<defs><linearGradient id="g" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-opacity="0.86"/><stop offset="0.12" stop-opacity="0.58"/><stop offset="0.24" stop-opacity="0.2"/><stop offset="0.32" stop-opacity="0"/><stop offset="0.54" stop-opacity="0"/><stop offset="0.66" stop-opacity="0.3"/><stop offset="0.82" stop-opacity="0.65"/><stop offset="1" stop-opacity="0.92"/></linearGradient></defs><rect width="1" height="1080" fill="url(#g)"/>
</svg>

After

Width:  |  Height:  |  Size: 562 B

@@ -0,0 +1,11 @@
{
inputHash: '16ca2d9e1b2b5e93a605ab7d6767222d',
outputs: [
{
outputFilePath: 'images/player/PauseGradient.png',
outputHash: '44e41195c8ce4a12ffed9c941d048551',
width: 1,
height: 1080,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1" height="256" viewBox="0 0 1 256" preserveAspectRatio="none">
<defs><linearGradient id="g" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-opacity="0.27"/><stop offset="0.4" stop-opacity="0.27"/><stop offset="1" stop-opacity="0.8"/></linearGradient></defs><rect width="1" height="256" fill="url(#g)"/>
</svg>

After

Width:  |  Height:  |  Size: 360 B

@@ -0,0 +1,11 @@
{
inputHash: 'e5090064415e37e798eb2e4b774c4aac',
outputs: [
{
outputFilePath: 'images/player/PauseGradientThumbnail.png',
outputHash: 'bb3995a997312a893bdf4cb532ec7d5b',
width: 1,
height: 256,
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="116" height="116" viewBox="0 0 116 116">
<rect x="14" y="14" width="88" height="88" rx="4" fill="none" stroke="#E5E5E5" stroke-width="8"/>
</svg>

After

Width:  |  Height:  |  Size: 193 B

@@ -0,0 +1,53 @@
{
inputHash: 'f5b1f5756c16612292fea5336cd98871',
outputs: [
{
outputFilePath: 'images/player/focus_grid.1080p.9.png',
outputHash: '7abd5a4d6ca7ab32cea0c90ab939d88f',
width: 116,
height: 116,
ninePatch: {
stretchX: [
22,
94,
],
stretchY: [
22,
94,
],
},
},
{
outputFilePath: 'images/player/focus_grid.720p.9.png',
outputHash: '87d182912e384c0e86d62b1ca07d25dd',
width: 78,
height: 78,
ninePatch: {
stretchX: [
15,
63,
],
stretchY: [
15,
63,
],
},
},
{
outputFilePath: 'images/player/focus_grid.480p.9.png',
outputHash: 'ea56f2cc5830904e9a9e9c17899390ac',
width: 52,
height: 52,
ninePatch: {
stretchX: [
10,
42,
],
stretchY: [
10,
42,
],
},
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="148" height="148" viewBox="0 0 148 148">
<defs><linearGradient id="v" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#474747"/><stop offset="1" stop-color="#959595"/></linearGradient><linearGradient id="h" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-opacity="0.1"/><stop offset="0.5" stop-opacity="0"/><stop offset="1" stop-opacity="0.1"/></linearGradient></defs><rect width="148" height="148" fill="url(#v)"/><rect width="148" height="148" fill="url(#h)"/><rect x="0.5" y="0.5" width="147" height="147" fill="none" stroke="#353535"/>
</svg>

After

Width:  |  Height:  |  Size: 605 B

@@ -0,0 +1,21 @@
{
inputHash: 'f62d717b21b7b84f825b210f6bc718ac',
outputs: [
{
outputFilePath: 'images/player/imageFootprint.9.png',
outputHash: 'fdce5cfb2d7fbe883958801f03bab4dc',
width: 148,
height: 148,
ninePatch: {
stretchX: [
1,
147,
],
stretchY: [
1,
147,
],
},
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18">
<circle cx="9" cy="9" r="9" fill="#EFEFEF"/>
</svg>

After

Width:  |  Height:  |  Size: 136 B

@@ -0,0 +1,53 @@
{
inputHash: '5d03669840209dd1094cff25bc61bf4a',
outputs: [
{
outputFilePath: 'images/player/osd_sliderControl_small.1080p.9.png',
outputHash: 'f64105cd2bf745cf76624142c28c41fd',
width: 18,
height: 18,
ninePatch: {
stretchX: [
8,
10,
],
stretchY: [
8,
10,
],
},
},
{
outputFilePath: 'images/player/osd_sliderControl_small.720p.9.png',
outputHash: 'd1900a308c4bb146dac988e8c7f2b86e',
width: 12,
height: 12,
ninePatch: {
stretchX: [
5,
7,
],
stretchY: [
5,
7,
],
},
},
{
outputFilePath: 'images/player/osd_sliderControl_small.480p.9.png',
outputHash: '2aa635bd423cfcf9352f9691c8eb78c2',
width: 8,
height: 8,
ninePatch: {
stretchX: [
3,
5,
],
stretchY: [
3,
5,
],
},
},
],
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
<rect x="4" y="0" width="40" height="1" fill="#000" fill-opacity="0.0627451"/><rect x="0" y="4" width="1" height="40" fill="#000" fill-opacity="0.0627451"/>
</svg>

After

Width:  |  Height:  |  Size: 248 B

@@ -0,0 +1,21 @@
{
inputHash: '3fcf626b9b6e5e251b19fcb02be65eb6',
outputs: [
{
outputFilePath: 'images/player/videoProgressBarHandle.9.png',
outputHash: 'c7151c08865a56fb7f4542b741db279c',
width: 48,
height: 48,
ninePatch: {
stretchX: [
4,
44,
],
stretchY: [
4,
44,
],
},
},
],
}
+34 -3
View File
@@ -1,8 +1,8 @@
// Description: Converts SVGs to PNGs and resizes them to the correct dimensions.
// Description: Converts SVGs to PNGs (optionally framed as 9-patches) and resizes them to the correct dimensions.
const { ArgumentParser, BooleanOptionalAction } = require('argparse')
const { globSync } = require('glob');
const { convertFile } = require('convert-svg-to-png');
const { convert, convertFile } = require('convert-svg-to-png');
const { existsSync, writeFileSync, readFileSync } = require('fs');
const json5 = require('json5');
const md5 = require('crypto-js/md5');
@@ -88,7 +88,8 @@ async function generateImages(svgFile, meta, metafile, force) {
await generateImage(svgFile.file, output, svgFile.rootDir);
outputHash = checkFileHash(outputFilePath, output.outputHash);
console.log(`Generated ${outputFilePath} (${output.width}x${output.height})`);
const border = output.ninePatch ? 2 : 0;
console.log(`Generated ${outputFilePath} (${output.width + border}x${output.height + border})`);
output.outputHash = outputHash.hash;
metaChanged = true;
@@ -121,5 +122,35 @@ async function generateImage(inputImage, options, rootDir) {
...options
};
opts.outputFilePath = path.join(rootDir, opts.outputFilePath);
if (opts.ninePatch) {
await generateNinePatch(inputImage, opts);
return;
}
await convertFile(inputImage, opts);
}
// ninePatch: { stretchX: [start, end], stretchY: [start, end] } in content pixels, end exclusive. The file
// is width+2 x height+2: top/left markers span the stretchable region, bottom/right the content region (the
// same spans). display:block — the converter inlines the SVG in <body>, where a canvas shorter than the line
// box would sit on the text baseline and render shifted down.
async function generateNinePatch(inputImage, opts) {
const { width, height, ninePatch, outputFilePath, outputHash, ...convertOptions } = opts;
const [x0, x1] = ninePatch.stretchX;
const [y0, y1] = ninePatch.stretchY;
const validSpan = (start, end, size) => Number.isInteger(start) && Number.isInteger(end) && 0 <= start && start < end && end <= size;
if (!Number.isInteger(width) || !Number.isInteger(height) || !validSpan(x0, x1, width) || !validSpan(y0, y1, height)) {
throw new Error(`${inputImage}: invalid ninePatch ${JSON.stringify(ninePatch)} for ${width}x${height}`);
}
if (convertOptions.scale !== undefined && convertOptions.scale !== 1) {
throw new Error(`${inputImage}: a 9-patch must render at scale 1 (its markers are 1px)`);
}
const content = readFileSync(inputImage).toString('base64');
const marker = (x, y, w, h) => `<rect x="${x}" y="${y}" width="${w}" height="${h}" fill="#000"/>`;
const framed = `<svg xmlns="http://www.w3.org/2000/svg" width="${width + 2}" height="${height + 2}" shape-rendering="crispEdges" style="display:block">`
+ `<image href="data:image/svg+xml;base64,${content}" x="1" y="1" width="${width}" height="${height}" preserveAspectRatio="none"/>`
+ marker(1 + x0, 0, x1 - x0, 1) + marker(0, 1 + y0, 1, y1 - y0)
+ marker(1 + x0, height + 1, x1 - x0, 1) + marker(width + 1, 1 + y0, 1, y1 - y0)
+ '</svg>';
const png = await convert(framed, { ...convertOptions, width: width + 2, height: height + 2 });
writeFileSync(outputFilePath, png);
}