Merge pull request #173 from patrickas/patch-1

Add default when ctrl is clicked while expanding canvas
This commit is contained in:
tim h 2023-01-16 17:08:00 -06:00 committed by GitHub
commit ab0a53e6be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -72,7 +72,8 @@ const uiCtx = uiCanvas.getContext("2d", {desynchronized: true});
let expandSize = localStorage.getItem("openoutpaint/expand-size") || 1024;
expandSize = parseInt(expandSize, 10);
const askSize = () => {
const askSize = (e) => {
if (e.ctrlKey ) return expandSize;
const by = prompt("How much do you want to expand by?", expandSize);
if (!by) return null;
@ -88,9 +89,9 @@ const uiCtx = uiCanvas.getContext("2d", {desynchronized: true});
leftButton.classList.add("expand-button", "left");
leftButton.style.width = "64px";
leftButton.style.height = `${imageCollection.size.h}px`;
leftButton.addEventListener("click", () => {
leftButton.addEventListener("click", (e) => {
let size = null;
if ((size = askSize())) {
if ((size = askSize(e))) {
imageCollection.expand(size, 0, 0, 0);
drawBackground();
const newLeft = -imageCollection.inputOffset.x - imageCollection.origin.x;
@ -106,9 +107,9 @@ const uiCtx = uiCanvas.getContext("2d", {desynchronized: true});
rightButton.classList.add("expand-button", "right");
rightButton.style.width = "64px";
rightButton.style.height = `${imageCollection.size.h}px`;
rightButton.addEventListener("click", () => {
rightButton.addEventListener("click", (e) => {
let size = null;
if ((size = askSize())) {
if ((size = askSize(e))) {
imageCollection.expand(0, 0, size, 0);
drawBackground();
rightButton.style.left =
@ -122,9 +123,9 @@ const uiCtx = uiCanvas.getContext("2d", {desynchronized: true});
topButton.classList.add("expand-button", "top");
topButton.style.height = "64px";
topButton.style.width = `${imageCollection.size.w}px`;
topButton.addEventListener("click", () => {
topButton.addEventListener("click", (e) => {
let size = null;
if ((size = askSize())) {
if ((size = askSize(e))) {
imageCollection.expand(0, size, 0, 0);
drawBackground();
const newTop = -imageCollection.inputOffset.y - imageCollection.origin.y;
@ -140,9 +141,9 @@ const uiCtx = uiCanvas.getContext("2d", {desynchronized: true});
bottomButton.classList.add("expand-button", "bottom");
bottomButton.style.height = "64px";
bottomButton.style.width = `${imageCollection.size.w}px`;
bottomButton.addEventListener("click", () => {
bottomButton.addEventListener("click", (e) => {
let size = null;
if ((size = askSize())) {
if ((size = askSize(e))) {
imageCollection.expand(0, 0, 0, size);
drawBackground();
bottomButton.style.top =