From 0fdcfac121da1ea28ac598b4cdaba01b2bec57eb Mon Sep 17 00:00:00 2001 From: Deficuet Date: Sat, 6 Jan 2024 21:55:35 -0700 Subject: [PATCH] update --- README.md | 3 ++- build.gradle | 8 ++------ .../io/github/deficuet/unitykt/classes/Sprite.kt | 5 +++++ .../deficuet/unitykt/internal/impl/SpriteImpl.kt | 10 +++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 24f5b2e7..d32d82c1 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,8 @@ So far the objects that can export data includes: - `getImage` - A BufferedImage created from the decompressed data. **It is usually up-side-down**. - If the format of the texture is unsupported, both functions will return `null`. - Sprite - - `getImage` - An **upright** BufferedImage cropped from a `Texture2D` image. The function will return `null` if the `Texture2D` object is not found or the format is unsupported. + - `getImage` - An BufferedImage cropped from a `Texture2D` image. Will return `null` if the `Texture2D` object is not found or the format is unsupported. + - The packing mode `SpritePackingMode.Tight` is not supported yet. - TextAsset - `text(charset)` - This function is used to export content in this object as `String`. A `Charset` can be passed as a parameter, by default it is `Charsets.UTF_8`. - Shader diff --git a/build.gradle b/build.gradle index 2e785180..83ee94ad 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,3 @@ -buildscript { - ext.kotlin_version = "1.8.21" -} - plugins { id 'java' id 'org.jetbrains.kotlin.jvm' version '1.8.21' @@ -9,7 +5,7 @@ plugins { } group 'io.github.deficuet' -version '0.0.1' +version '0.1.0_alpha.5' repositories { mavenCentral() @@ -21,7 +17,7 @@ dependencies { implementation 'org.json:json:20230618' implementation 'org.lz4:lz4-java:1.8.0' implementation 'com.nixxcode.jvmbrotli:jvmbrotli:0.2.0' - implementation 'com.github.Deficuet:JImageUtils:0.0.3.a' + implementation 'com.github.Deficuet:JImageUtils:0.0.4' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2' } diff --git a/src/main/kotlin/io/github/deficuet/unitykt/classes/Sprite.kt b/src/main/kotlin/io/github/deficuet/unitykt/classes/Sprite.kt index a00bdd3f..254f45e4 100644 --- a/src/main/kotlin/io/github/deficuet/unitykt/classes/Sprite.kt +++ b/src/main/kotlin/io/github/deficuet/unitykt/classes/Sprite.kt @@ -21,6 +21,11 @@ interface Sprite: NamedObject { val mRD: SpriteRenderData val mPhysicsShape: Array> + /** + * Has the same orientation as the parent [Texture2D] + * + * i.e. usually up-side-down + */ fun getImage(): BufferedImage? } diff --git a/src/main/kotlin/io/github/deficuet/unitykt/internal/impl/SpriteImpl.kt b/src/main/kotlin/io/github/deficuet/unitykt/internal/impl/SpriteImpl.kt index 524ec2e9..599ae322 100644 --- a/src/main/kotlin/io/github/deficuet/unitykt/internal/impl/SpriteImpl.kt +++ b/src/main/kotlin/io/github/deficuet/unitykt/internal/impl/SpriteImpl.kt @@ -155,16 +155,16 @@ internal class SpriteImpl( if (settingsRow.packed == 1u) { when (settingsRow.packingRotation) { SpritePackingRotation.FlipHorizontal -> { - spriteImage = spriteImage.use { flipX() } + spriteImage = spriteImage.flipX().apply(true) } SpritePackingRotation.FlipVertical -> { - spriteImage = spriteImage.use { flipY() } + spriteImage = spriteImage.flipY().apply(true) } SpritePackingRotation.Rotate90 -> { - spriteImage = spriteImage.use { quadrantRotate(3) } + spriteImage = spriteImage.quadrantRotate(3).apply(true) } SpritePackingRotation.Rotate180 -> { - spriteImage = spriteImage.use { quadrantRotate(2) } + spriteImage = spriteImage.quadrantRotate(2).apply(true) } else -> { } } @@ -172,7 +172,7 @@ internal class SpriteImpl( // if (settingsRow.packingMode == SpritePackingMode.Tight) { // TODO("Sprite image tight") // } - return spriteImage.use { flipY() } + return spriteImage } return null }