Skip to content

Commit 554d4ec

Browse files
committed
The icons can be now zoomed with different scaling to improve usability.
1 parent caa1e12 commit 554d4ec

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

data/icons.html

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ <h2 class="mt-3">Overview</h2>
5252
<p>These icons are stored on the Pixelix device in the <strong>/configuration</strong> directory.</p>
5353
<p>They can be used to customize the appearance of some plugins.</p>
5454
<p>The number in [ ] brackets represents the icon file id, required by the plugins to display the correct icon.</p>
55+
<div class="mb-3">
56+
<label class="form-label">Zoom Level:</label>
57+
<div class="btn-group" role="group" aria-label="Zoom controls">
58+
<input type="radio" class="btn-check" name="zoomOptions" id="zoomOriginal" value="1" checked autocomplete="off" onchange="updateZoom()">
59+
<label class="btn btn-outline-primary" for="zoomOriginal">Original</label>
60+
61+
<input type="radio" class="btn-check" name="zoomOptions" id="zoom2x" value="2" autocomplete="off" onchange="updateZoom()">
62+
<label class="btn btn-outline-primary" for="zoom2x">2x</label>
63+
64+
<input type="radio" class="btn-check" name="zoomOptions" id="zoom4x" value="4" autocomplete="off" onchange="updateZoom()">
65+
<label class="btn btn-outline-primary" for="zoom4x">4x</label>
66+
67+
<input type="radio" class="btn-check" name="zoomOptions" id="zoom8x" value="8" autocomplete="off" onchange="updateZoom()">
68+
<label class="btn btn-outline-primary" for="zoom8x">8x</label>
69+
</div>
70+
</div>
5571
<div class="h-100 p-2 bg-body-tertiary border rounded-3 d-flex flex-wrap" id="overview">
5672
</div>
5773
<h2 class="mt-3">Upload</h2>
@@ -120,6 +136,25 @@ <h2 class="mt-3">LaMetric Icons</h2>
120136
var restClient = new pixelix.rest.Client();
121137
var lametricIconUrl = "";
122138
var lametricIconFileName = "";
139+
var currentZoom = 1;
140+
141+
function updateZoom() {
142+
var selectedZoom = parseInt(document.querySelector('input[name="zoomOptions"]:checked').value);
143+
currentZoom = selectedZoom;
144+
145+
var images = document.querySelectorAll('#overview img');
146+
images.forEach(function(img) {
147+
if (currentZoom === 1) {
148+
img.style.imageRendering = 'auto';
149+
img.style.width = 'auto';
150+
img.style.height = 'auto';
151+
} else {
152+
img.style.imageRendering = 'pixelated';
153+
img.style.width = (img.naturalWidth * currentZoom) + 'px';
154+
img.style.height = (img.naturalHeight * currentZoom) + 'px';
155+
}
156+
});
157+
}
123158

124159
function enableUI() {
125160
utils.enableForm("myFormIcon", true);
@@ -185,7 +220,18 @@ <h2 class="mt-3">LaMetric Icons</h2>
185220
.text("[" + idx + "]");
186221
$img = $("<img>")
187222
.attr("src", jsonRsp.fileTable[idx].fullPath)
188-
.attr("alt", "Preview");
223+
.attr("alt", "Preview")
224+
.on('load', function() {
225+
if (currentZoom === 1) {
226+
this.style.imageRendering = 'auto';
227+
this.style.width = 'auto';
228+
this.style.height = 'auto';
229+
} else {
230+
this.style.imageRendering = 'pixelated';
231+
this.style.width = (this.naturalWidth * currentZoom) + 'px';
232+
this.style.height = (this.naturalHeight * currentZoom) + 'px';
233+
}
234+
});
189235
$name = $("<p>")
190236
.text(jsonRsp.fileTable[idx].fullPath.replace(/^.*[\\\/]/, ''));
191237
$div = $("<div>")

0 commit comments

Comments
 (0)