From 5e2a3e46e169f443044bb6901ecd5d03a9d2ec22 Mon Sep 17 00:00:00 2001 From: unsettledgames <47360416+unsettledgames@users.noreply.github.com> Date: Tue, 15 Sep 2020 11:56:05 +0200 Subject: [PATCH] Finished basic canvas resizing Must test pivots for negative values --- css/pixel-editor.scss | 61 +++++++++++++------- js/_resizeCanvas.js | 125 ++++++++++++++++++++++++++++++++++++++--- views/pixel-editor.hbs | 59 ++++++++++++------- 3 files changed, 195 insertions(+), 50 deletions(-) diff --git a/css/pixel-editor.scss b/css/pixel-editor.scss index b0e05d1..557832e 100644 --- a/css/pixel-editor.scss +++ b/css/pixel-editor.scss @@ -959,19 +959,20 @@ svg { flex-wrap:wrap; vertical-align:middle; text-align:center; - width:150px; + width:130px; + float:left; button { margin-right:10px; margin-bottom:10px; position:relative; - width:40px; - height:40px; - background-color:color(base, background); - border:none; + width:32px; + height:32px; + background:$basehover; + border:none; path { - fill:color(menu, foreground); + fill:$basehovericon; } transition: background 150ms ease-in-out, transform 150ms ease; @@ -980,11 +981,12 @@ svg { } button:hover, - button:focus { + button:focus, + button.rc-selected-pivot { cursor:pointer; - background-color: color(base, foreground); + background-color: $baseicon; path { - fill:color(base, foreground, bold); + fill:$basehovericonhover; } border: 2px solid color(base, foreground); } @@ -993,13 +995,11 @@ svg { } } -#borders-menu { +#borders-menu, #rc-size-menu { display:flex; position:relative; flex-wrap: wrap; width:250px; - float:right; - vertical-align:middle; font-size:15px; left:10px; text-align:center; @@ -1007,8 +1007,9 @@ svg { input { position:relative; margin-left:10px; - height:10px; - width:20px; + height:15px; + width:40px; + padding:8px; } input::-webkit-outer-spin-button, @@ -1021,21 +1022,39 @@ svg { -moz-appearance: textfield; } - h2 { - position:relative; - display:inline-block; - } - span { padding-right:10px; float:left; position:relative; - display: flex; vertical-align:middle; - height:40px; + height:40px; + width:100px; + display: inline-flex; + align-items: center; } } +#rc-size-menu { + span { + width:115px; + } +} + +#borders-menu { + width:400px; + justify-content: center; + + div { + float: none; + width: 330px; + padding-left:50px; + + span { + padding-right:20px; + } + } +} + #resize-canvas-confirm { background: color(button); border: none; diff --git a/js/_resizeCanvas.js b/js/_resizeCanvas.js index 672cbe1..2e0460c 100644 --- a/js/_resizeCanvas.js +++ b/js/_resizeCanvas.js @@ -1,5 +1,6 @@ let resizeCanvasContainer = document.getElementById("resize-canvas"); let pivot = "middle"; +let currentPivotObject; let resizeCanvasInitialized = false; let borders = {left: 0, right: 0, top: 0, bottom: 0}; @@ -16,14 +17,61 @@ function initResizeCanvasInputs() { for (let i=0; i{{svg "arrows/top.svg" width="20" height="20"}} - + + + +

Size

+
+ + Width: + + + + Height: + +
+
- - Left: - - - - Right: - - - - Top: - - - - Bottom: - - +

Borders offsets

+
+ + Left: + + + + Right: + + + + Top: + + + + Bottom: + +