Skip to content

Commit

Permalink
Bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Aug 16, 2024
1 parent 5e5cffb commit 75d3aef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/src/main/kotlin/kr/toxicity/hud/image/SplitType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ enum class SplitType {
override fun split(target: NamedLoadedImage, split: Int): List<NamedLoadedImage> {
val saveName = target.name.substringBefore('.')
return (1..split).map {
val targetImage = target.image.circleCut(2 * PI * (split - it + 1).toDouble() / split.toDouble()) ?: throw RuntimeException()
val targetImage = target.image.circleCut(2 * PI * it.toDouble() / split.toDouble(), true) ?: throw RuntimeException()
NamedLoadedImage(
"${saveName}_$it.png",
targetImage
Expand Down
3 changes: 2 additions & 1 deletion dist/src/main/kotlin/kr/toxicity/hud/util/Images.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ fun BufferedImage.withOpacity(opacity: Double): BufferedImage {
}
}

fun LoadedImage.circleCut(degree: Double) = BufferedImage(image.width, image.height, BufferedImage.TYPE_INT_ARGB).also {
fun LoadedImage.circleCut(degree: Double, reversed: Boolean = false) = BufferedImage(image.width, image.height, BufferedImage.TYPE_INT_ARGB).also {
val hw = image.width.toDouble() / 2
val hh = image.height.toDouble() / 2
for (w in 0..<image.width) {
for (h in 0..<image.height) {
var d = -(atan2(h.toDouble() - hh, w.toDouble() - hw) + PI / 2)
if (reversed) d *= -1
if (d < 0) d += 2 * PI
if (d > 2 * PI) d -= 2 * PI
if (d <= degree) it.setRGB(w, h, image.getRGB(w, h))
Expand Down

0 comments on commit 75d3aef

Please sign in to comment.