diff --git a/src/OnCanvasTextBox.js b/src/OnCanvasTextBox.js index 4beb427..1c864e5 100644 --- a/src/OnCanvasTextBox.js +++ b/src/OnCanvasTextBox.js @@ -124,14 +124,14 @@ class OnCanvasTextBox extends OnCanvasObject { } function draw_text_wrapped(ctx, text, x, y, maxWidth, lineHeight) { - const original_lines = text.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/); + const original_lines = text.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/); - for (const original_line of original_lines) { - const words = original_line.split(' '); - let line = ''; - let test; - let metrics; - for (let i = 0; i < words.length; i++) { + for (const original_line of original_lines) { + const words = original_line.split(' '); + let line = ''; + let test; + let metrics; + for (let i = 0; i < words.length; i++) { test = words[i]; metrics = ctx.measureText(test); // TODO: break words on hyphens and perhaps other characters @@ -156,7 +156,7 @@ function draw_text_wrapped(ctx, text, x, y, maxWidth, lineHeight) { line = test; } } - ctx.fillText(line, x, y); - y += lineHeight; - } + ctx.fillText(line, x, y); + y += lineHeight; + } } diff --git a/src/functions.js b/src/functions.js index ceac2bb..8746d18 100644 --- a/src/functions.js +++ b/src/functions.js @@ -340,13 +340,13 @@ function open_from_File(file, callback, canceled){ }); } function get_image_file_from_FileList_or_show_error(files, user_input_method_verb_past_tense){ - for (const file of files) { - if(file.type.match(/^image/)){ + for (const file of files) { + if(file.type.match(/^image/)){ return file; } - } + } - if(files.length > 1){ + if(files.length > 1){ show_error_message("None of the files " + user_input_method_verb_past_tense + " appear to be images."); }else{ show_error_message("File " + user_input_method_verb_past_tense + " does not appear to be an image."); diff --git a/src/image-manipulation.js b/src/image-manipulation.js index 7756a8c..e0600eb 100644 --- a/src/image-manipulation.js +++ b/src/image-manipulation.js @@ -242,25 +242,25 @@ function draw_fill(ctx, start_x, start_y, fill_r, fill_g, fill_b, fill_a){ } while(stack.length){ - let new_pos; - let x; - let y; - var pixel_pos; - let reach_left; - let reach_right; - new_pos = stack.pop(); - x = new_pos[0]; - y = new_pos[1]; + let new_pos; + let x; + let y; + var pixel_pos; + let reach_left; + let reach_right; + new_pos = stack.pop(); + x = new_pos[0]; + y = new_pos[1]; - pixel_pos = (y*c_width + x) * 4; - while(matches_start_color(pixel_pos)){ + pixel_pos = (y*c_width + x) * 4; + while(matches_start_color(pixel_pos)){ y--; pixel_pos = (y*c_width + x) * 4; } - reach_left = false; - reach_right = false; - // eslint-disable-next-line no-constant-condition - while(true){ + reach_left = false; + reach_right = false; + // eslint-disable-next-line no-constant-condition + while(true){ y++; pixel_pos = (y*c_width + x) * 4; @@ -294,7 +294,7 @@ function draw_fill(ctx, start_x, start_y, fill_r, fill_g, fill_b, fill_a){ pixel_pos += c_width * 4; } - } + } ctx.putImageData(id, 0, 0); function matches_start_color(pixel_pos){ @@ -715,8 +715,8 @@ function draw_grid(ctx, scale) { const vertexSrc = [ 'attribute vec4 position;', 'void main() {', - ' /* already in normalized coordinates, so just pass through */', - ' gl_Position = position;', + ' /* already in normalized coordinates, so just pass through */', + ' gl_Position = position;', '}' ].join(''); const vertexShader = gl.createShader(gl.VERTEX_SHADER); @@ -734,7 +734,7 @@ function draw_grid(ctx, scale) { const fragmentSrc = [ 'precision mediump float;', 'void main() {', - ' gl_FragColor = vec4(0, 0, 0, 1);', + ' gl_FragColor = vec4(0, 0, 0, 1);', '}' ].join(''); const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); diff --git a/src/sessions.js b/src/sessions.js index 9bbb2eb..a65e1e7 100644 --- a/src/sessions.js +++ b/src/sessions.js @@ -366,25 +366,25 @@ // Load the new image data const img = new Image(); img.onload = () => { - // Cancel any in-progress pointer operations - if (pointer_operations.length) { + // Cancel any in-progress pointer operations + if (pointer_operations.length) { $G.triggerHandler("pointerup", "cancel"); } - // Write the image data to the canvas - ctx.copy(img); - $canvas_area.trigger("resize"); - // (detect_transparency() here would not be ideal - // Perhaps a better way of syncing transparency - // and other options will be established) - // Playback recorded in-progress pointer operations - window.console && console.log("playback", pointer_operations); + // Write the image data to the canvas + ctx.copy(img); + $canvas_area.trigger("resize"); + // (detect_transparency() here would not be ideal + // Perhaps a better way of syncing transparency + // and other options will be established) + // Playback recorded in-progress pointer operations + window.console && console.log("playback", pointer_operations); - for (const e of pointer_operations) { - // Trigger the event at each place it is listened for - $canvas.triggerHandler(e, ["synthetic"]); - $G.triggerHandler(e, ["synthetic"]); - } - }; + for (const e of pointer_operations) { + // Trigger the event at each place it is listened for + $canvas.triggerHandler(e, ["synthetic"]); + $G.triggerHandler(e, ["synthetic"]); + } + }; img.src = uri; } }, error => {