Borders made of oriented triangles rather than circles (#2104)

This commit is contained in:
Federico Luongo 2020-03-08 19:36:50 +01:00 committed by GitHub
parent 61565c0ee6
commit 0cf27789e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 676 additions and 662 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 906 KiB

After

Width:  |  Height:  |  Size: 907 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 KiB

After

Width:  |  Height:  |  Size: 369 KiB

View file

@ -15,7 +15,8 @@ import com.unciv.models.ruleset.unit.UnitType
import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.ImageGetter
import com.unciv.ui.utils.center import com.unciv.ui.utils.center
import com.unciv.ui.utils.centerX import com.unciv.ui.utils.centerX
import kotlin.math.PI
import kotlin.math.atan
open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) : Group() { open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) : Group() {
@ -385,8 +386,13 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
val images = mutableListOf<Image>() val images = mutableListOf<Image>()
borderImages[neighbor] = images borderImages[neighbor] = images
for (i in -2..2) { for (i in -2..2) {
val image = ImageGetter.getCircle() val image = ImageGetter.getTriangle()
val sign = if (relativeWorldPosition.x < 0) -1 else 1
val angle = sign * (atan(sign * relativeWorldPosition.y / relativeWorldPosition.x) * 180 / PI - 90.0)
image.setSize(5f, 5f) image.setSize(5f, 5f)
image.setOrigin(image.width/2,image.height/2)
image.rotateBy(angle.toFloat())
image.center(this) image.center(this)
// in addTiles, we set the position of groups by relative world position *0.8*groupSize, filter groupSize = 50 // in addTiles, we set the position of groups by relative world position *0.8*groupSize, filter groupSize = 50
// Here, we want to have the borders start HALFWAY THERE and extend towards the tiles, so we give them a position of 0.8*25. // Here, we want to have the borders start HALFWAY THERE and extend towards the tiles, so we give them a position of 0.8*25.

View file

@ -184,6 +184,7 @@ object ImageGetter {
fun getBlue() = Color(0x004085bf) fun getBlue() = Color(0x004085bf)
fun getCircle() = getImage("OtherIcons/Circle") fun getCircle() = getImage("OtherIcons/Circle")
fun getTriangle() = getImage("OtherIcons/Triangle")
fun getBackground(color:Color): Drawable { fun getBackground(color:Color): Drawable {
val drawable = getDrawable("OtherIcons/TableBackground") val drawable = getDrawable("OtherIcons/TableBackground")