diff --git a/app/src/main/kotlin/tripaint/app/Actions.kt b/app/src/main/kotlin/tripaint/app/Actions.kt index 64039f1..1656268 100644 --- a/app/src/main/kotlin/tripaint/app/Actions.kt +++ b/app/src/main/kotlin/tripaint/app/Actions.kt @@ -78,22 +78,24 @@ object Actions { } fun openImage( - model: TriPaintModel, + fileSystem: FileSystem, + imagePool: ImagePool, + imageGrid: ImageGrid, file: File, fileOpenSettings: FileOpenSettings, whereToPutImage: GridCoords ) { val (offset, format) = fileOpenSettings val location = ImagePool.SaveLocation(file, offset) - val imageSize = model.imageGrid.imageSize + val imageSize = imageGrid.imageSize CachedLoader.apply( - cached = { model.imagePool.imageAt(location) }, - load = { loadImageFromFile(location, format, imageSize, model.fileSystem) } + cached = { imagePool.imageAt(location) }, + load = { loadImageFromFile(location, format, imageSize, fileSystem) } ).onSuccess { val (image, found) = it - if (!found) model.imagePool.set(image, location, ImagePool.SaveInfo(format)) - model.imageGrid.set(GridCell(whereToPutImage, image)) + if (!found) imagePool.set(image, location, ImagePool.SaveInfo(format)) + imageGrid.set(GridCell(whereToPutImage, image)) }.onFailure { it.printStackTrace() } @@ -109,8 +111,11 @@ object Actions { return ImageStorage.fromRegularImage(im, location.offset, format, imageSize) } - fun openHexagon(model: TriPaintModel, file: File, fileOpenSettings: FileOpenSettings, coords: GridCoords) { - val imageSize = model.imageGrid.imageSize + fun openHexagon( + fileSystem: FileSystem, imagePool: ImagePool, imageGrid: ImageGrid, + file: File, fileOpenSettings: FileOpenSettings, coords: GridCoords + ) { + val imageSize = imageGrid.imageSize val (offset, format) = fileOpenSettings fun coordOffset(idx: Int): Pair { @@ -131,12 +136,12 @@ object Actions { val off = coordOffset(idx) val whereToPutImage = GridCoords.from(coords.x + off.first, coords.y + off.second) - openImage(model, file, FileOpenSettings(imageOffset, format), whereToPutImage) + openImage(fileSystem, imagePool, imageGrid, file, FileOpenSettings(imageOffset, format), whereToPutImage) } } - fun applyEffect(model: TriPaintModel, effect: Effect) { - val grid = model.imageGrid + fun applyEffect(imageGrid: ImageGrid, effect: Effect) { + val grid = imageGrid val images = grid.selectedImages() val before = images.map { im -> im.storage.allPixels().map { pix -> im.storage.getColor(pix) } } diff --git a/app/src/main/kotlin/tripaint/app/MainStage.kt b/app/src/main/kotlin/tripaint/app/MainStage.kt index 8132f24..74637a7 100644 --- a/app/src/main/kotlin/tripaint/app/MainStage.kt +++ b/app/src/main/kotlin/tripaint/app/MainStage.kt @@ -13,6 +13,7 @@ import tripaint.effects.BlurEffect import tripaint.effects.MotionBlurEffect import tripaint.effects.RandomNoiseEffect import tripaint.grid.GridCell +import tripaint.grid.ImageGrid import tripaint.image.ImagePool import tripaint.image.ImageStorage import tripaint.image.format.RecursiveStorageFormat @@ -29,31 +30,34 @@ import java.io.File class MainStage( private val controls: TriPaintViewListener, - private val model: TriPaintModel, + private val fileSystem: FileSystem, + private val imagePool: ImagePool, + private val imageGrid: ImageGrid, private val stage: Stage, ) : TriPaintView { private val currentEditMode: Resource private val setCurrentEditMode: (EditMode) -> Unit init { - val res = Resource.createResource(EditMode.Draw) - this.currentEditMode = res.first - this.setCurrentEditMode = res.second + Resource.createResource(EditMode.Draw).let { + this.currentEditMode = it.first + this.setCurrentEditMode = it.second + } } - private val imageDisplay: ImageGridPane = ImageGridPane(model.imageGrid, currentEditMode) + private val imageDisplay: ImageGridPane = ImageGridPane(imageGrid, currentEditMode) private val menuBar: MenuBar = TheMenuBar.create(controls) private val toolBar: ToolBar = TheToolBar.create(controls) private val toolBox: TilePane = ToolBox.create(EditMode.all(), currentEditMode, setCurrentEditMode) private val imageTabs: TilePane = - ImageTabs.fromImagePool(model.imageGrid, model.imagePool, controls::requestImageRemoval) + ImageTabs.fromImagePool(imageGrid, imagePool, controls::requestImageRemoval) private val colorBox: VBox = makeColorBox() private var currentFolder: File? = null init { - stage.setTitle("TriPaint") + stage.title = "TriPaint" stage.setOnCloseRequest { e -> if (!controls.requestExit()) e.consume() } @@ -80,7 +84,7 @@ class MainStage( val sceneContents = BorderPane(centerPane, topPane, null, null, null) val scene = Scene(sceneContents, 720.0, 720.0) - scene.stylesheets.add(MainStage::class.java.getResource("/styles/application.css").toExternalForm()) + scene.stylesheets.add(MainStage::class.java.getResource("/styles/application.css")!!.toExternalForm()) for (m in EditMode.all()) { if (m.shortCut != null) { @@ -105,11 +109,11 @@ class MainStage( } imageDisplay.colors.primaryColor.addListener { _, from, to -> - if (from != to) colorPicker1.setValue(to.toFXColor()) + if (from != to) colorPicker1.value = to.toFXColor() } imageDisplay.colors.secondaryColor.addListener { _, from, to -> - if (from != to) colorPicker2.setValue(to.toFXColor()) + if (from != to) colorPicker2.value = to.toFXColor() } return VBox( @@ -160,10 +164,10 @@ class MainStage( } override fun askForBlurRadius(): Int? { - val selectedImagesCoords = model.imageGrid.selectedImages().map { it.coords } + val selectedImagesCoords = imageGrid.selectedImages().map { it.coords } return DialogUtils.getValueFromDialog( - model.imagePool, - model.imageGrid.selectedImages(), + imagePool, + imageGrid.selectedImages(), "Blur images", "How much should the images be blurred?", "Radius:", @@ -174,10 +178,10 @@ class MainStage( } override fun askForMotionBlurRadius(): Int? { - val selectedImagesCoords = model.imageGrid.selectedImages().map { it.coords } + val selectedImagesCoords = imageGrid.selectedImages().map { it.coords } return DialogUtils.getValueFromDialog( - model.imagePool, - model.imageGrid.selectedImages(), + imagePool, + imageGrid.selectedImages(), "Motion blur images", "How much should the images be motion blurred?", "Radius:", @@ -188,12 +192,12 @@ class MainStage( } override fun askForRandomNoiseColors(): Pair? { - val images = model.imageGrid.selectedImages() - val selectedImagesCoords = model.imageGrid.selectedImages().map { it.coords } + val images = imageGrid.selectedImages() + val selectedImagesCoords = imageGrid.selectedImages().map { it.coords } val loColorPicker = ColorPicker(Color.Black.toFXColor()) val hiColorPicker = ColorPicker(Color.White.toFXColor()) - val (previewPane, updatePreview) = DialogUtils.makeImagePreviewList(images, model.imagePool) + val (previewPane, updatePreview) = DialogUtils.makeImagePreviewList(images, imagePool) fun updatePreviewFromInputs() { val lo = fromFXColor(loColorPicker.value) @@ -244,7 +248,7 @@ class MainStage( } private fun saveBeforeClosingAlert(images: List): Alert { - val (previewPane, _) = DialogUtils.makeImagePreviewList(images, model.imagePool) + val (previewPane, _) = DialogUtils.makeImagePreviewList(images, imagePool) val alert = Alert(Alert.AlertType.CONFIRMATION) alert.title = "Save before closing?" @@ -273,7 +277,7 @@ class MainStage( Pair(RecursiveStorageFormat, "Recursive format") ), 0 - ) { model.fileSystem.readImage(it) } + ) { fileSystem.readImage(it) } } override fun shouldReplaceImage( @@ -281,9 +285,9 @@ class MainStage( newImage: ImageStorage, location: ImagePool.SaveLocation ): Boolean? { - val tri1 = model.imageGrid.findByStorage(newImage)!! - val tri2 = model.imageGrid.findByStorage(currentImage)!! - val (previewPane, _) = DialogUtils.makeImagePreviewList(listOf(tri1, tri2), model.imagePool) + val tri1 = imageGrid.findByStorage(newImage)!! + val tri2 = imageGrid.findByStorage(currentImage)!! + val (previewPane, _) = DialogUtils.makeImagePreviewList(listOf(tri1, tri2), imagePool) val alert = Alert(Alert.AlertType.CONFIRMATION) alert.title = "Collision" @@ -295,7 +299,7 @@ class MainStage( ButtonType("Right", ButtonBar.ButtonData.NO), ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE) ) - return alert.showAndWait().orElse(null)?.buttonData == ButtonBar.ButtonData.YES + return alert.showAndWait().map { it.buttonData == ButtonBar.ButtonData.YES }.orElse(null) } override fun askForImageSize(): Int? { diff --git a/app/src/main/kotlin/tripaint/app/TriPaint.kt b/app/src/main/kotlin/tripaint/app/TriPaint.kt index 2a3e62c..58de527 100644 --- a/app/src/main/kotlin/tripaint/app/TriPaint.kt +++ b/app/src/main/kotlin/tripaint/app/TriPaint.kt @@ -1,7 +1,6 @@ package tripaint.app import javafx.application.Application -import javafx.application.Platform import javafx.stage.Stage object TriPaint { @@ -13,12 +12,7 @@ object TriPaint { class App : Application() { override fun start(stage: Stage) { - val model: TriPaintModel = TriPaintModel.create() - val controller = TriPaintController(model) { c, m -> MainStage(c, m, stage) } - - Platform.runLater { - model.imageGrid.setImageSizeIfEmpty(controller.view.askForImageSize() ?: 32) - } + TriPaintController(stage, FileSystem.create()) stage.show() } diff --git a/app/src/main/kotlin/tripaint/app/TriPaintController.kt b/app/src/main/kotlin/tripaint/app/TriPaintController.kt index 9910112..1499df4 100644 --- a/app/src/main/kotlin/tripaint/app/TriPaintController.kt +++ b/app/src/main/kotlin/tripaint/app/TriPaintController.kt @@ -1,14 +1,27 @@ package tripaint.app +import javafx.application.Platform +import javafx.stage.Stage import tripaint.coords.GridCoords import tripaint.effects.* import tripaint.grid.GridCell +import tripaint.grid.ImageGrid +import tripaint.image.ImagePool import tripaint.view.TriPaintView import tripaint.view.TriPaintViewListener import tripaint.view.gui.UIAction -class TriPaintController(val model: TriPaintModel, viewFactory: TriPaintViewFactory) : TriPaintViewListener { - val view: TriPaintView = viewFactory.createView(this, model) +class TriPaintController(stage: Stage, private val fileSystem: FileSystem) : TriPaintViewListener { + private val imagePool: ImagePool = ImagePool() + private val imageGrid: ImageGrid = ImageGrid(-1) + + private val view: TriPaintView = MainStage(this, fileSystem, imagePool, imageGrid, stage) + + init { + Platform.runLater { + imageGrid.setImageSizeIfEmpty(view.askForImageSize() ?: 32) + } + } override fun perform(action: UIAction) { when (action) { @@ -16,16 +29,16 @@ class TriPaintController(val model: TriPaintModel, viewFactory: TriPaintViewFact view.askForWhereToPutImage()?.let { (x, y) -> val backgroundColor = view.backgroundColor() val coords = GridCoords.from(x, y) - Actions.createNewImage(model.imageGrid, backgroundColor, coords) + Actions.createNewImage(imageGrid, backgroundColor, coords) } } UIAction.Open -> { view.askForFileToOpen()?.let { file -> - view.askForFileOpenSettings(file, model.imageGrid.imageSize, 1, 1)?.let { fileOpenSettings -> + view.askForFileOpenSettings(file, imageGrid.imageSize, 1, 1)?.let { fileOpenSettings -> view.askForWhereToPutImage()?.let { (x, y) -> val coords = GridCoords.from(x, y) - Actions.openImage(model, file, fileOpenSettings, coords) + Actions.openImage(fileSystem, imagePool, imageGrid, file, fileOpenSettings, coords) } } } @@ -33,10 +46,10 @@ class TriPaintController(val model: TriPaintModel, viewFactory: TriPaintViewFact UIAction.OpenHexagon -> { view.askForFileToOpen()?.let { file -> - view.askForFileOpenSettings(file, model.imageGrid.imageSize, 6, 1)?.let { fileOpenSettings -> + view.askForFileOpenSettings(file, imageGrid.imageSize, 6, 1)?.let { fileOpenSettings -> view.askForWhereToPutImage()?.let { (x, y) -> val coords = GridCoords.from(x, y) - Actions.openHexagon(model, file, fileOpenSettings, coords) + Actions.openHexagon(fileSystem, imagePool, imageGrid, file, fileOpenSettings, coords) } } } @@ -44,10 +57,10 @@ class TriPaintController(val model: TriPaintModel, viewFactory: TriPaintViewFact UIAction.Save -> { Actions.save( - model.imageGrid, - model.imagePool, - model.imageGrid.selectedImages().filter { it.changed }, - model.fileSystem, + imageGrid, + imagePool, + imageGrid.selectedImages().filter { it.changed }, + fileSystem, { image -> view.askForSaveFile(image) }, { file, image -> view.askForFileSaveSettings(file, image) }, view, @@ -55,12 +68,12 @@ class TriPaintController(val model: TriPaintModel, viewFactory: TriPaintViewFact } UIAction.SaveAs -> { - for (im in model.imageGrid.selectedImages()) { + for (im in imageGrid.selectedImages()) { Actions.saveAs( - model.imageGrid, - model.imagePool, + imageGrid, + imagePool, im, - model.fileSystem, + fileSystem, { image -> view.askForSaveFile(image) }, { file, image -> view.askForFileSaveSettings(file, image) }, view @@ -75,37 +88,37 @@ class TriPaintController(val model: TriPaintModel, viewFactory: TriPaintViewFact } UIAction.Undo -> { - model.imageGrid.undo() + imageGrid.undo() } UIAction.Redo -> { - model.imageGrid.redo() + imageGrid.redo() } UIAction.Blur -> { view.askForBlurRadius()?.let { radius -> - Actions.applyEffect(model, BlurEffect(radius)) + Actions.applyEffect(imageGrid, BlurEffect(radius)) } } UIAction.MotionBlur -> { view.askForMotionBlurRadius()?.let { radius -> - Actions.applyEffect(model, MotionBlurEffect(radius)) + Actions.applyEffect(imageGrid, MotionBlurEffect(radius)) } } UIAction.RandomNoise -> { view.askForRandomNoiseColors()?.let { (lo, hi) -> - Actions.applyEffect(model, RandomNoiseEffect(lo, hi)) + Actions.applyEffect(imageGrid, RandomNoiseEffect(lo, hi)) } } UIAction.Scramble -> { - Actions.applyEffect(model, ScrambleEffect) + Actions.applyEffect(imageGrid, ScrambleEffect) } UIAction.Cell -> { - Actions.applyEffect(model, CellEffect()) + Actions.applyEffect(imageGrid, CellEffect()) } else -> {} @@ -120,10 +133,10 @@ class TriPaintController(val model: TriPaintModel, viewFactory: TriPaintViewFact val shouldSave = view.askSaveBeforeClosing(listOf(image)) if (shouldSave != null) { if (shouldSave && !Actions.save( - model.imageGrid, - model.imagePool, + imageGrid, + imagePool, listOf(image), - model.fileSystem, + fileSystem, { view.askForSaveFile(it) }, { file, im -> view.askForFileSaveSettings(file, im) }, view, @@ -137,19 +150,19 @@ class TriPaintController(val model: TriPaintModel, viewFactory: TriPaintViewFact } if (!abortRemoval) { - model.imageGrid.remove(image.coords) + imageGrid.remove(image.coords) } } private fun doExit(): Boolean { - val images = model.imageGrid.changedImages() + val images = imageGrid.changedImages() if (images.isEmpty()) return true val shouldSave = view.askSaveBeforeClosing(images) return if (shouldSave != null) { if (shouldSave) { Actions.save( - model.imageGrid, model.imagePool, images, model.fileSystem, + imageGrid, imagePool, images, fileSystem, { image -> view.askForSaveFile(image) }, { file, image -> view.askForFileSaveSettings(file, image) }, view diff --git a/app/src/main/kotlin/tripaint/app/TriPaintModel.kt b/app/src/main/kotlin/tripaint/app/TriPaintModel.kt deleted file mode 100644 index b20b813..0000000 --- a/app/src/main/kotlin/tripaint/app/TriPaintModel.kt +++ /dev/null @@ -1,18 +0,0 @@ -package tripaint.app - -import tripaint.grid.ImageGrid -import tripaint.image.ImagePool - -class TriPaintModel(val fileSystem: FileSystem, initialImageSize: Int) { - val imagePool: ImagePool = ImagePool() - val imageGrid: ImageGrid = ImageGrid(initialImageSize) - - companion object { - fun create(): TriPaintModel = TriPaintModel(FileSystem.create(), -1) - - fun createNull( - imageSize: Int, - fileSystemArgs: FileSystem.NullArgs = FileSystem.NullArgs() - ): TriPaintModel = TriPaintModel(FileSystem.createNull(fileSystemArgs), imageSize) - } -} diff --git a/app/src/main/kotlin/tripaint/app/TriPaintViewFactory.kt b/app/src/main/kotlin/tripaint/app/TriPaintViewFactory.kt deleted file mode 100644 index feace3a..0000000 --- a/app/src/main/kotlin/tripaint/app/TriPaintViewFactory.kt +++ /dev/null @@ -1,8 +0,0 @@ -package tripaint.app - -import tripaint.view.TriPaintView -import tripaint.view.TriPaintViewListener - -fun interface TriPaintViewFactory { - fun createView(controls: TriPaintViewListener, model: TriPaintModel): TriPaintView -} diff --git a/app/src/test/kotlin/tripaint/app/ActionsTest.kt b/app/src/test/kotlin/tripaint/app/ActionsTest.kt index ab94ead..a42a3f8 100644 --- a/app/src/test/kotlin/tripaint/app/ActionsTest.kt +++ b/app/src/test/kotlin/tripaint/app/ActionsTest.kt @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Nested import tripaint.color.Color import tripaint.coords.GridCoords import tripaint.coords.StorageCoords +import tripaint.grid.ImageGrid import tripaint.image.ImagePool import tripaint.image.ImageStorage import tripaint.image.RegularImage @@ -24,17 +25,18 @@ class ActionsTest { val location = ImagePool.SaveLocation(File("a.png")) val imageSize = 16 - val model = TriPaintModel.createNull(imageSize, FileSystem.NullArgs(initialImages = mapOf())) - val pool = model.imagePool + val fileSystem = FileSystem.createNull(FileSystem.NullArgs(initialImages = mapOf())) + val imagePool = ImagePool() + val imageGrid = ImageGrid(imageSize) Actions.openImage( - model, + fileSystem, imagePool, imageGrid, location.file, FileOpenSettings(location.offset, storageFormat), GridCoords.from(0, 0) ) - assertEquals(null, pool.imageAt(location)) + assertEquals(null, imagePool.imageAt(location)) } @Test @@ -46,19 +48,20 @@ class ActionsTest { val image = ImageStorage.fill(imageSize, Color.Yellow) val regularImage = image.toRegularImage(storageFormat) - val model = - TriPaintModel.createNull( - imageSize, - FileSystem.NullArgs(initialImages = mapOf(Pair(file, regularImage))) - ) + val fileSystem = run { + val initialImages = mapOf(Pair(file, regularImage)) + FileSystem.createNull(FileSystem.NullArgs(initialImages)) + } + val imagePool = ImagePool() + val imageGrid = ImageGrid(imageSize) Actions.openImage( - model, + fileSystem, imagePool, imageGrid, location.file, FileOpenSettings(location.offset, storageFormat), GridCoords.from(0, 0) ) - val loadedImage = model.imagePool.imageAt(location)!! + val loadedImage = imagePool.imageAt(location)!! assertEquals(regularImage, loadedImage.toRegularImage(storageFormat)) } @@ -76,19 +79,17 @@ class ActionsTest { val storedImage = RegularImage.ofSize(imageSize + offset.x, imageSize + offset.y) storedImage.pasteImage(offset, regularImage) - val model = TriPaintModel.createNull( - imageSize, - FileSystem.NullArgs(initialImages = mapOf(Pair(file, storedImage))) - ) - val pool = model.imagePool + val fileSystem = FileSystem.createNull(FileSystem.NullArgs(initialImages = mapOf(Pair(file, storedImage)))) + val imagePool = ImagePool() + val imageGrid = ImageGrid(imageSize) Actions.openImage( - model, + fileSystem, imagePool, imageGrid, location.file, FileOpenSettings(location.offset, storageFormat), GridCoords.from(0, 0) ) - val loadedImage = pool.imageAt(location)!! + val loadedImage = imagePool.imageAt(location)!! assertEquals(regularImage, loadedImage.toRegularImage(storageFormat)) } diff --git a/app/src/test/kotlin/tripaint/app/NewActionTest.kt b/app/src/test/kotlin/tripaint/app/NewActionTest.kt index 71524d7..7b165aa 100644 --- a/app/src/test/kotlin/tripaint/app/NewActionTest.kt +++ b/app/src/test/kotlin/tripaint/app/NewActionTest.kt @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Nested import tripaint.color.Color import tripaint.coords.GridCoords +import tripaint.grid.ImageGrid import tripaint.image.RegularImage import tripaint.image.format.SimpleStorageFormat import kotlin.test.Test @@ -13,16 +14,16 @@ class NewActionTest { inner class NewAction { @Test fun `adds a new image to the grid`() { - val model = TriPaintModel.createNull(8) + val imageGrid = ImageGrid(8) - val imageSize = model.imageGrid.imageSize + val imageSize = imageGrid.imageSize val backgroundColor = Color.Cyan - Actions.createNewImage(model.imageGrid, backgroundColor, GridCoords.from(3, 4)) + Actions.createNewImage(imageGrid, backgroundColor, GridCoords.from(3, 4)) val expectedImage = RegularImage.fill(imageSize, imageSize, backgroundColor) - val cell = model.imageGrid.apply(GridCoords.from(3, 4))!! + val cell = imageGrid.apply(GridCoords.from(3, 4))!! val actualImage = cell.storage.toRegularImage(SimpleStorageFormat) assertEquals(expectedImage, actualImage) @@ -31,17 +32,17 @@ class NewActionTest { // TODO: Is this really how it should work? @Test fun `replaces any existing image at the location`() { - val model = TriPaintModel.createNull(8) + val imageGrid = ImageGrid(8) - val imageSize = model.imageGrid.imageSize + val imageSize = imageGrid.imageSize val backgroundColor = Color.Cyan - Actions.createNewImage(model.imageGrid, backgroundColor, GridCoords.from(3, 4)) - Actions.createNewImage(model.imageGrid, backgroundColor, GridCoords.from(3, 4)) + Actions.createNewImage(imageGrid, backgroundColor, GridCoords.from(3, 4)) + Actions.createNewImage(imageGrid, backgroundColor, GridCoords.from(3, 4)) val expectedImage = RegularImage.fill(imageSize, imageSize, backgroundColor) - val cell = model.imageGrid.apply(GridCoords.from(3, 4))!! + val cell = imageGrid.apply(GridCoords.from(3, 4))!! val actualImage = cell.storage.toRegularImage(SimpleStorageFormat) assertEquals(expectedImage, actualImage) diff --git a/app/src/test/kotlin/tripaint/app/OpenActionTest.kt b/app/src/test/kotlin/tripaint/app/OpenActionTest.kt index a469c8f..eb2832c 100644 --- a/app/src/test/kotlin/tripaint/app/OpenActionTest.kt +++ b/app/src/test/kotlin/tripaint/app/OpenActionTest.kt @@ -5,6 +5,8 @@ import org.junit.jupiter.api.Nested import tripaint.color.Color import tripaint.coords.GridCoords import tripaint.coords.StorageCoords +import tripaint.grid.ImageGrid +import tripaint.image.ImagePool import tripaint.image.RegularImage import tripaint.image.format.SimpleStorageFormat import tripaint.view.FileOpenSettings @@ -20,17 +22,18 @@ class OpenActionTest { val image = RegularImage.fill(8, 8, Color.Yellow) image.setColor(5, 6, Color.Cyan) - val model = - TriPaintModel.createNull(8, FileSystem.NullArgs(initialImages = mapOf(Pair(file, image)))) + val fileSystem = FileSystem.createNull(FileSystem.NullArgs(initialImages = mapOf(Pair(file, image)))) + val imagePool = ImagePool() + val imageGrid = ImageGrid(8) Actions.openImage( - model, + fileSystem, imagePool, imageGrid, file, FileOpenSettings(StorageCoords.from(0, 0), SimpleStorageFormat), GridCoords.from(3, 4) ) - val cell = model.imageGrid.apply(GridCoords.from(3, 4))!! + val cell = imageGrid.apply(GridCoords.from(3, 4))!! val actualImage = cell.storage.toRegularImage(SimpleStorageFormat) assertEquals(image, actualImage) @@ -46,17 +49,18 @@ class OpenActionTest { val offset = StorageCoords.from(1, 2) storedImage.pasteImage(offset, image) - val model = - TriPaintModel.createNull(8, FileSystem.NullArgs(initialImages = mapOf(Pair(file, storedImage)))) + val fileSystem = FileSystem.createNull(FileSystem.NullArgs(initialImages = mapOf(Pair(file, storedImage)))) + val imagePool = ImagePool() + val imageGrid = ImageGrid(8) Actions.openImage( - model, + fileSystem, imagePool, imageGrid, file, FileOpenSettings(offset, SimpleStorageFormat), GridCoords.from(3, 4) ) - val cell = model.imageGrid.apply(GridCoords.from(3, 4))!! + val cell = imageGrid.apply(GridCoords.from(3, 4))!! val actualImage = cell.storage.toRegularImage(SimpleStorageFormat) assertEquals(image, actualImage)