Skip to content

Commit 830fe3f

Browse files
committed
- chg: restored missing getCoords method of HotSpot
1 parent 9ddda90 commit 830fe3f

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.9.59] - 2024-09-19
8+
### Fixed
9+
- restored missing `getCoords` method of `HotSpot`
10+
711
## [0.9.58] - 2024-09-19
812
### Changed
913
- rename of `HotSpot` object (from `KmlVec2`) & optimization in it's usage

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Library for [Locus Map](https://www.locusmap.app) application for Android device
1616

1717
## Current version
1818

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

2222
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).

Diff for: gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ GRADLE_NEXUS_STAGING = 0.30.0
2323
LOCUS_LOGGER = 2.2
2424

2525
# Version
26-
API_CODE = 105
27-
API_VERSION = 0.9.58
26+
API_CODE = 106
27+
API_VERSION = 0.9.59
2828

2929
# ANDROID SUPPORT LIBS
3030
# https://developer.android.com/topic/libraries/support-library/revisions.html

Diff for: locus-api-core/src/main/java/locus/api/objects/styles/HotSpot.kt

+41
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,47 @@ data class HotSpot(
1414
FRACTION, PIXELS, INSET_PIXELS
1515
}
1616

17+
/**
18+
* Compute reference coordinates of certain image based on the defined hotSpot parameters.
19+
*/
20+
fun HotSpot.getCoords(sourceWidth: Double, sourceHeight: Double, result: DoubleArray? = DoubleArray(2)): DoubleArray {
21+
var resultNew = result
22+
23+
// check container for results
24+
if (resultNew == null || resultNew.size != 2) {
25+
resultNew = DoubleArray(2)
26+
}
27+
28+
// set X units
29+
when (xUnits) {
30+
Units.FRACTION -> {
31+
resultNew[0] = sourceWidth * x
32+
}
33+
Units.PIXELS -> {
34+
resultNew[0] = x
35+
}
36+
Units.INSET_PIXELS -> {
37+
resultNew[0] = sourceWidth - x
38+
}
39+
}
40+
41+
// set Y units
42+
when (yUnits) {
43+
Units.FRACTION -> {
44+
resultNew[1] = sourceHeight * (1.0 - y)
45+
}
46+
Units.PIXELS -> {
47+
resultNew[1] = sourceHeight - y
48+
}
49+
Units.INSET_PIXELS -> {
50+
resultNew[1] = y
51+
}
52+
}
53+
54+
// return result
55+
return resultNew
56+
}
57+
1758
companion object {
1859

1960
val HOT_STOP_BOTTOM_CENTER = HotSpot(

0 commit comments

Comments
 (0)