Skip to content

Commit

Permalink
- chg: restored missing getCoords method of HotSpot
Browse files Browse the repository at this point in the history
  • Loading branch information
menion committed Sep 19, 2024
1 parent 9ddda90 commit 830fe3f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.9.59] - 2024-09-19
### Fixed
- restored missing `getCoords` method of `HotSpot`

## [0.9.58] - 2024-09-19
### Changed
- rename of `HotSpot` object (from `KmlVec2`) & optimization in it's usage
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Library for [Locus Map](https://www.locusmap.app) application for Android device

## Current version

Latest stable LT version: **0.9.58**
Latest stable LT version: **0.9.59**
Available versions on the maven repository: [here](https://repo1.maven.org/maven2/com/asamm/).

How to **update to new 0.9.x** version? More about it [here](https://github.com/asamm/locus-api/wiki/Update-to-version-0.9.0).
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ GRADLE_NEXUS_STAGING = 0.30.0
LOCUS_LOGGER = 2.2

# Version
API_CODE = 105
API_VERSION = 0.9.58
API_CODE = 106
API_VERSION = 0.9.59

# ANDROID SUPPORT LIBS
# https://developer.android.com/topic/libraries/support-library/revisions.html
Expand Down
41 changes: 41 additions & 0 deletions locus-api-core/src/main/java/locus/api/objects/styles/HotSpot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,47 @@ data class HotSpot(
FRACTION, PIXELS, INSET_PIXELS
}

/**
* Compute reference coordinates of certain image based on the defined hotSpot parameters.
*/
fun HotSpot.getCoords(sourceWidth: Double, sourceHeight: Double, result: DoubleArray? = DoubleArray(2)): DoubleArray {
var resultNew = result

// check container for results
if (resultNew == null || resultNew.size != 2) {
resultNew = DoubleArray(2)
}

// set X units
when (xUnits) {
Units.FRACTION -> {
resultNew[0] = sourceWidth * x
}
Units.PIXELS -> {
resultNew[0] = x
}
Units.INSET_PIXELS -> {
resultNew[0] = sourceWidth - x
}
}

// set Y units
when (yUnits) {
Units.FRACTION -> {
resultNew[1] = sourceHeight * (1.0 - y)
}
Units.PIXELS -> {
resultNew[1] = sourceHeight - y
}
Units.INSET_PIXELS -> {
resultNew[1] = y
}
}

// return result
return resultNew
}

companion object {

val HOT_STOP_BOTTOM_CENTER = HotSpot(
Expand Down

0 comments on commit 830fe3f

Please sign in to comment.