Format some last bits of code

main
Isaiah Odhner 2022-01-19 09:59:49 -05:00
parent 5ff5f8b0c4
commit 4a9163fb6d
9 changed files with 45 additions and 45 deletions

View File

@ -364,6 +364,7 @@
"Satanas", "Satanas",
"Scribus", "Scribus",
"scrollable", "scrollable",
"scrollbars",
"Sesotho", "Sesotho",
"Setswana", "Setswana",
"shader's", "shader's",
@ -449,6 +450,7 @@
"Valoda", "Valoda",
"vaporwave", "vaporwave",
"Venda", "Venda",
"Verdana",
"verts", "verts",
"Viacam", "Viacam",
"Việt", "Việt",

View File

@ -12,10 +12,10 @@ const ctx = canvas.getContext("2d");
const animate = () => { const animate = () => {
rAF_ID = requestAnimationFrame(animate); rAF_ID = requestAnimationFrame(animate);
if( if (
canvas.width !== mask_img.width || canvas.width !== mask_img.width ||
canvas.height !== mask_img.height canvas.height !== mask_img.height
){ ) {
canvas.width = mask_img.width; canvas.width = mask_img.width;
canvas.height = mask_img.height; canvas.height = mask_img.height;
} }
@ -28,10 +28,10 @@ const animate = () => {
const x_interval_ms = 19000; const x_interval_ms = 19000;
const y_interval_ms = 7000; const y_interval_ms = 7000;
const now = performance.now(); const now = performance.now();
if(!( if (!(
mask_img.complete && mask_img.naturalWidth > 1 && mask_img.complete && mask_img.naturalWidth > 1 &&
clouds_img.complete && clouds_img.naturalWidth > 1 clouds_img.complete && clouds_img.naturalWidth > 1
)){ )) {
return; return;
} }
ctx.drawImage( ctx.drawImage(
@ -41,7 +41,7 @@ const animate = () => {
clouds_width, clouds_width,
clouds_height clouds_height
); );
if(something_img.complete && something_img.naturalWidth > 1){ if (something_img.complete && something_img.naturalWidth > 1) {
let t = now / 5000; let t = now / 5000;
ctx.globalAlpha = 0.3 + Math.max(0, Math.sin(-t) * 1); ctx.globalAlpha = 0.3 + Math.max(0, Math.sin(-t) * 1);
ctx.drawImage( ctx.drawImage(

View File

@ -1,8 +1,7 @@
// Based on: https://github.com/evernote/serge/blob/master/lib/Serge/Engine/Plugin/parse_rc.pm // Based on: https://github.com/evernote/serge/blob/master/lib/Serge/Engine/Plugin/parse_rc.pm
module.exports = module.exports = function parse_rc_file(rc_file_text, callback, lang) {
function parse_rc_file(rc_file_text, callback, lang) {
// if (!callback) { // if (!callback) {
// throw new TypeError('callback not specified'); // throw new TypeError('callback not specified');
// } // }
@ -81,9 +80,9 @@ function parse_rc_file(rc_file_text, callback, lang) {
} }
// STRINGTABLE BEGIN...END block contents // STRINGTABLE BEGIN...END block contents
// } else if (stringtable && block_level) { // } else if (stringtable && block_level) {
// actually just do any time, find any strings // actually just do any time, find any strings
}{ } {
// let match = line.match(/^[\t ]*(\w+)[\t ]+(L?"([^"]*?("")*)*?")/); // let match = line.match(/^[\t ]*(\w+)[\t ]+(L?"([^"]*?("")*)*?")/);
let match = line.match(/(L?"(.*)")/); let match = line.match(/(L?"(.*)")/);
if (match) { // test for one-line string definitions if (match) { // test for one-line string definitions

View File

@ -3,8 +3,8 @@ const glob = require("glob");
const parse_rc_file = require("./parse-rc-file"); const parse_rc_file = require("./parse-rc-file");
const base_lang = "en"; const base_lang = "en";
const available_langs = fs.readdirSync(__dirname).filter((dir)=> dir.match(/^\w+(-\w+)?$/)); const available_langs = fs.readdirSync(__dirname).filter((dir) => dir.match(/^\w+(-\w+)?$/));
const target_langs = available_langs.filter((lang)=> lang !== base_lang); const target_langs = available_langs.filter((lang) => lang !== base_lang);
console.log("Target languages:", target_langs); console.log("Target languages:", target_langs);
@ -27,11 +27,11 @@ function remove_hotkey(text) {
} }
const remove_ellipsis = str => str.replace("...", ""); const remove_ellipsis = str => str.replace("...", "");
const only_unique = (value, index, self)=> self.indexOf(value) === index; const only_unique = (value, index, self) => self.indexOf(value) === index;
const get_strings = (lang)=> { const get_strings = (lang) => {
return glob.sync(`${__dirname}/${lang}/**/*.rc`).map( return glob.sync(`${__dirname}/${lang}/**/*.rc`).map(
(rc_file)=> parse_rc_file(fs.readFileSync(rc_file, "utf16le").replace(/\ufeff/g, "")) (rc_file) => parse_rc_file(fs.readFileSync(rc_file, "utf16le").replace(/\ufeff/g, ""))
).flat(); ).flat();
}; };
@ -39,11 +39,11 @@ const base_strings = get_strings(base_lang);
for (const target_lang of target_langs) { for (const target_lang of target_langs) {
const target_strings = get_strings(target_lang); const target_strings = get_strings(target_lang);
const localizations = {}; const localizations = {};
const add_localization = (base_string, target_string, fudgedness)=> { const add_localization = (base_string, target_string, fudgedness) => {
localizations[base_string] = localizations[base_string] || []; localizations[base_string] = localizations[base_string] || [];
localizations[base_string].push({target_string, fudgedness}); localizations[base_string].push({ target_string, fudgedness });
}; };
const add_localizations = (base_strings, target_strings)=> { const add_localizations = (base_strings, target_strings) => {
for (let i = 0; i < target_strings.length; i++) { for (let i = 0; i < target_strings.length; i++) {
const base_string = base_strings[i]; const base_string = base_strings[i];
const target_string = target_strings[i]; const target_string = target_strings[i];
@ -71,8 +71,8 @@ for (const target_lang of target_langs) {
for (const base_string in localizations) { for (const base_string in localizations) {
const options = localizations[base_string]; const options = localizations[base_string];
options.sort((a, b)=> a.fudgedness - b.fudgedness); options.sort((a, b) => a.fudgedness - b.fudgedness);
const unique_strings = options.map(({target_string})=> target_string).filter(only_unique); const unique_strings = options.map(({ target_string }) => target_string).filter(only_unique);
if (unique_strings.length > 1) { if (unique_strings.length > 1) {
console.warn(`Collision for "${base_string}": ${JSON.stringify(unique_strings, null, "\t")}`); console.warn(`Collision for "${base_string}": ${JSON.stringify(unique_strings, null, "\t")}`);
} }

View File

@ -153,9 +153,9 @@ class OnCanvasSelection extends OnCanvasObject {
// and should end up as the cut out image data for the selection // and should end up as the cut out image data for the selection
// canvasImageData is initially the portion of image data on the canvas, // canvasImageData is initially the portion of image data on the canvas,
// and should end up as... the portion of image data on the canvas that it should end up as. // and should end up as... the portion of image data on the canvas that it should end up as.
// @TODO: could simplify by making the later (shared) condition just if(colored_cutout){} // @TODO: could simplify by making the later (shared) condition just if (colored_cutout)
// but might change how it works anyways so whatever // but might change how it works anyways so whatever
// if(!transparency){ // now if !transparency or if tool_transparent_mode // if (!transparency) { // now if !transparency or if tool_transparent_mode
// this is mainly in order to support patterns as the background color // this is mainly in order to support patterns as the background color
// NOTE: must come before cutout canvas is modified // NOTE: must come before cutout canvas is modified
const colored_cutout = make_canvas(cutout); const colored_cutout = make_canvas(cutout);

View File

@ -895,7 +895,7 @@ function draw_line(ctx, x1, y1, x2, y2, stroke_size) {
draw_line_without_pattern_support(op_ctx_2d, x1, y1, x2, y2, stroke_size); draw_line_without_pattern_support(op_ctx_2d, x1, y1, x2, y2, stroke_size);
}); });
// also works: // also works:
// draw_line_strip(ctx, [{x: x1, y: y1}, {x: x2, y: y2}]); // draw_line_strip(ctx, [{ x: x1, y: y1 }, { x: x2, y: y2 }]);
} }
let grid_pattern; let grid_pattern;

View File

@ -445,26 +445,25 @@
// const label = synthetic ? "(synthetic)" : "(normal)"; // const label = synthetic ? "(synthetic)" : "(normal)";
// window.console && console.debug && console.debug(e.type, label); // window.console && console.debug && console.debug(e.type, label);
}; };
$canvas_area.on("pointerdown.session-hook", "*", (e, synthetic) => { $canvas_area.on("pointerdown.session-hook", "*", (e, synthetic) => {
debug_event(e, synthetic); debug_event(e, synthetic);
if(synthetic){ return; } if (synthetic) { return; }
pointer_operations = [e]; pointer_operations = [e];
const pointermove = (e, synthetic) => { const pointermove = (e, synthetic) => {
debug_event(e, synthetic); debug_event(e, synthetic);
if(synthetic){ return; } if (synthetic) { return; }
pointer_operations.push(e); pointer_operations.push(e);
}; };
$G.on("pointermove.session-hook", pointermove); $G.on("pointermove.session-hook", pointermove);
$G.one("pointerup.session-hook", (e, synthetic) => { $G.one("pointerup.session-hook", (e, synthetic) => {
debug_event(e, synthetic); debug_event(e, synthetic);
if(synthetic){ return; } if (synthetic) { return; }
$G.off("pointermove.session-hook", pointermove); $G.off("pointermove.session-hook", pointermove);
}); });
}
}); });
*/ */
} }

View File

@ -31,7 +31,7 @@ const ChooserCanvas = (
); );
// eslint-disable-next-line no-empty // eslint-disable-next-line no-empty
} catch (error) { } } catch (error) { }
// if(invert){ // if (invert) {
// invert_rgb(c.ctx); // can fail due to tainted canvas if running from file: protocol // invert_rgb(c.ctx); // can fail due to tainted canvas if running from file: protocol
// } // }
c.style.filter = invert ? "invert()" : ""; c.style.filter = invert ? "invert()" : "";

View File

@ -573,8 +573,8 @@
} }
// for debug: fill rect // for debug: fill rect
// for(let x=0, x_limit=id_dest.width; x<x_limit; x+=1){ // for (let x = 0, x_limit = id_dest.width; x < x_limit; x += 1) {
// for(let y=1, y_limit=id_dest.height-1; y<y_limit; y+=1){ // for (let y = 1, y_limit = id_dest.height - 1; y < y_limit; y += 1) {
// copyPixelInverted(x, y); // copyPixelInverted(x, y);
// } // }
// } // }
@ -787,7 +787,7 @@
} }
}, },
drawPreviewUnderGrid(ctx, x, y, grid_visible, scale, translate_x, translate_y) { drawPreviewUnderGrid(ctx, x, y, grid_visible, scale, translate_x, translate_y) {
// if(!pointer_active && !pointer_over_canvas){return;} // if (!pointer_active && !pointer_over_canvas) { return; }
if (!this.preview_canvas) { return; } if (!this.preview_canvas) { return; }
ctx.scale(scale, scale); ctx.scale(scale, scale);
ctx.translate(translate_x, translate_y); ctx.translate(translate_x, translate_y);
@ -955,7 +955,7 @@
} }
}, },
drawPreviewUnderGrid(ctx, x, y, grid_visible, scale, translate_x, translate_y) { drawPreviewUnderGrid(ctx, x, y, grid_visible, scale, translate_x, translate_y) {
// if(!pointer_active && !pointer_over_canvas){return;} // if (!pointer_active && !pointer_over_canvas) { return; }
if (!this.preview_canvas) { return; } if (!this.preview_canvas) { return; }
ctx.scale(scale, scale); ctx.scale(scale, scale);