From 830fe3fc96ae6a8557565b11f5da3e7de12f36d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20M=2E=20aka=20Menion?= Date: Thu, 19 Sep 2024 12:48:26 +0200 Subject: [PATCH] - chg: restored missing `getCoords` method of `HotSpot` --- CHANGELOG.md | 4 ++ README.md | 2 +- gradle.properties | 4 +- .../java/locus/api/objects/styles/HotSpot.kt | 41 +++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bef2f2..3a5f6b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index b67c487..5587768 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/gradle.properties b/gradle.properties index 11e1b65..7c18452 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/locus-api-core/src/main/java/locus/api/objects/styles/HotSpot.kt b/locus-api-core/src/main/java/locus/api/objects/styles/HotSpot.kt index b9b2fe7..9d498f7 100644 --- a/locus-api-core/src/main/java/locus/api/objects/styles/HotSpot.kt +++ b/locus-api-core/src/main/java/locus/api/objects/styles/HotSpot.kt @@ -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(