Skip to content

Commit

Permalink
Add slider for outline darkness
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-munro committed May 13, 2022
1 parent 6dbdfac commit 4c9a4cc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<!-- </p> -->
<br>
<!-- <p> -->
Copyright 2021 Daniel Munro under the MIT free software license</a>.
Copyright 2022 Daniel Munro under the MIT free software license</a>.
<a href="https://github.com/daniel-munro/pbnify" target="_blank">Source code.</a>
<!-- </p> -->
</div>
Expand Down
6 changes: 3 additions & 3 deletions scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ angular.module('pbnApp')
c3.height = c2.height;

// draw outlines
// gray value was 191, changed to 150.
var gray = Math.round(255 * (1 - document.getElementById("darknessSlider").value / 100));
var bw = [{ r: 255, g: 255, b: 255 },
{ r: 150, g: 150, b: 150 }];
{ r: gray, g: gray, b: gray }];
var ctx3 = c3.getContext("2d");
var imgData = matToImageData(matLine, bw, ctx3);
ctx3.putImageData(imgData, 0, 0);

// draw numbers
ctx3.font = "12px Georgia";
ctx3.fillStyle = "rgb(150, 150, 150)";
ctx3.fillStyle = "rgb("+gray+", "+gray+", "+gray+")";
for (var i = 0; i < labelLocs.length; i++) {
ctx3.fillText(labelLocs[i].value + 1,
labelLocs[i].x - 3,
Expand Down
10 changes: 10 additions & 0 deletions styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ body {
max-width: 400px;
}

#darknessSliderLabel {
width: 180px; /* Use fixed width so slider doesn't jump back and forth. */
}

#darknessSlider {
vertical-align: middle;
width: 100%;
max-width: 400px;
}

#loader {
height: 300px;
/*border: 4px dashed gray;*/
Expand Down
8 changes: 8 additions & 0 deletions views/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
oninput="document.getElementById('widthSliderNumber').innerHTML = this.value;">
</div>

<div class="col" ng-show="step == 'load'">
<label id="darknessSliderLabel" for="darknessSlider">Outline darkness:
<span id="darknessSliderNumber" style="color: rgb(153, 153, 153);">40</span></label>
<input type="range" min="1" max="100" step="1" value="40" id="darknessSlider"
oninput="document.getElementById('darknessSliderNumber').innerHTML = this.value; var gray = Math.round(255 * (1 - this.value / 100)); document.getElementById('darknessSliderNumber').style.color = 'rgb('+gray+', '+gray+', '+gray+')';">
</div>


<div class="col" id="loader" ng-show="step == 'load'" ng-style="loaderStyle" image-loaded="imageLoaded(img)" load-file>
<p>Drop image here to load,<br>or browse for image.</p>
<button type="button" class="btn btn-secondary">
Expand Down

0 comments on commit 4c9a4cc

Please sign in to comment.