Skip to content

Commit

Permalink
Vectorize magnification options
Browse files Browse the repository at this point in the history
  • Loading branch information
1j01 committed Dec 2, 2021
1 parent c10a48e commit 92baef4
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 8 deletions.
131 changes: 131 additions & 0 deletions images/options-magnification.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions src/tool-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const ChooserDiv = (
const svg_url = url;
const on_zoom_etc = () => {
const use_svg = (window.devicePixelRatio >= 3 || (window.devicePixelRatio % 1) !== 0) &&
(get_theme() === "classic.css" || get_theme() === "dark.css");
(get_theme() === "classic.css" || get_theme() === "dark.css" || (get_theme() === "winter.css" && url.match(/magnification/)));
div.style.backgroundImage = `url(${use_svg ? svg_url : png_url})`;
};
if (div._on_zoom_etc) { // condition is needed, otherwise it will remove all listeners! (leading to only the last graphic being updated when zooming)
Expand Down Expand Up @@ -302,21 +302,21 @@ const $choose_stroke_size = $Choose(
const magnifications = [1, 2, 6, 8, 10];
const $choose_magnification = $Choose(
magnifications,
(scale, is_chosen, reuse_canvas) => {
(scale, is_chosen, reuse_canvas, reuse_div) => {
const i = magnifications.indexOf(scale);
const secret = scale === 10; // 10x is secret
const chooser_canvas = ChooserCanvas(
"images/options-magnification.png",
const chooser_el = ChooserDiv(
"images/options-magnification.svg",
is_chosen, // invert if chosen
39, (secret ? 2 : 13), // width, height of destination canvas
i*23, 0, 23, 9, // x, y, width, height from source image
8, 2, 23, 9, // x, y, width, height on destination
reuse_canvas,
reuse_div,
);
if(secret){
$(chooser_canvas).addClass("secret-option");
$(chooser_el).addClass("secret-option");
}
return chooser_canvas;
return chooser_el;
},
scale => {
set_magnification(scale);
Expand All @@ -330,7 +330,7 @@ $choose_magnification.on("update", () => {
$choose_magnification
.find(".secret-option")
.parent()
.css({position: "absolute", bottom: "-2px", left: 0, opacity: 0});
.css({position: "absolute", bottom: "-2px", left: 0, opacity: 0, height: 2, overflow: "hidden" });
});

const airbrush_sizes = [9, 16, 24];
Expand Down

0 comments on commit 92baef4

Please sign in to comment.