From beac4f568e2b950a9a9d705e5457806087facfad Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 15 Jun 2022 12:07:09 -0400 Subject: [PATCH] Move rows/columns variables to SilicaDocument --- SilicaViewer/Document.swift | 24 +++++++++--------------- SilicaViewer/SilicaDocument.swift | 6 ++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/SilicaViewer/Document.swift b/SilicaViewer/Document.swift index aa03594..75e1f93 100644 --- a/SilicaViewer/Document.swift +++ b/SilicaViewer/Document.swift @@ -19,12 +19,6 @@ class Document: NSDocument { var info = SilicaDocument() - var rows: Int = 0 - var columns: Int = 0 - - var remainderWidth: Int = 0 - var remainderHeight: Int = 0 - struct SilicaParsingError: Error, LocalizedError { enum Kind { case invalid @@ -97,12 +91,12 @@ class Document: NSDocument { var width: Int = info.tileSize var height: Int = info.tileSize - if((x + 1) == columns) { - width = info.tileSize - remainderWidth + if((x + 1) == info.columns) { + width = info.tileSize - info.remainderWidth } - if(y == rows) { - height = info.tileSize - remainderHeight + if(y == info.rows) { + height = info.tileSize - info.remainderHeight } return (width, height) @@ -139,7 +133,7 @@ class Document: NSDocument { let (width, height) = getTileSize(x, y) - if y == rows { + if y == info.rows { y = 0 } @@ -415,15 +409,15 @@ class Document: NSDocument { info.width = width info.height = height - columns = Int(ceil(Float(info.width) / Float(info.tileSize))) - rows = Int(ceil(Float(info.height) / Float(info.tileSize))) + 1 // TODO: lol why + info.columns = Int(ceil(Float(info.width) / Float(info.tileSize))) + info.rows = Int(ceil(Float(info.height) / Float(info.tileSize))) + 1 // TODO: lol why if info.width % info.tileSize != 0 { - remainderWidth = (columns * info.tileSize) - info.width + info.remainderWidth = (info.columns * info.tileSize) - info.width } if info.height % info.tileSize != 0 { - remainderHeight = (rows * info.tileSize) - info.height + info.remainderHeight = (info.rows * info.tileSize) - info.height } let layersClassKey = dict[LayersKey] diff --git a/SilicaViewer/SilicaDocument.swift b/SilicaViewer/SilicaDocument.swift index f1bb0be..cfac6e1 100644 --- a/SilicaViewer/SilicaDocument.swift +++ b/SilicaViewer/SilicaDocument.swift @@ -77,6 +77,12 @@ struct SilicaDocument { var width: Int = 0 var height: Int = 0 + var rows: Int = 0 + var columns: Int = 0 + + var remainderWidth: Int = 0 + var remainderHeight: Int = 0 + var layers: [SilicaLayer] = [] var videoFrame: (Int, Int) = (0, 0)