1
Fork 0

Move rows/columns variables to SilicaDocument

This commit is contained in:
Joshua Goins 2022-06-15 12:07:09 -04:00
parent ac740e653a
commit beac4f568e
2 changed files with 15 additions and 15 deletions

View file

@ -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]

View file

@ -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)