Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hitendradeveloper/hsrange
Simple and Elegant Range(A,B) to Range(P,Q) mapper in less then five lines of code.
https://github.com/hitendradeveloper/hsrange
calculations converter easy-to-use elegant hitendra hitendra-solanki hitendra-solanki-ios ios macos mapping mathematics mobile-apps mobile-development programming range range-map solanki swift-5 swift-struct technology
Last synced: about 1 month ago
JSON representation
Simple and Elegant Range(A,B) to Range(P,Q) mapper in less then five lines of code.
- Host: GitHub
- URL: https://github.com/hitendradeveloper/hsrange
- Owner: hitendradeveloper
- License: mit
- Created: 2018-04-16T10:49:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-21T19:27:39.000Z (over 3 years ago)
- Last Synced: 2024-11-09T06:18:47.684Z (2 months ago)
- Topics: calculations, converter, easy-to-use, elegant, hitendra, hitendra-solanki, hitendra-solanki-ios, ios, macos, mapping, mathematics, mobile-apps, mobile-development, programming, range, range-map, solanki, swift-5, swift-struct, technology
- Language: Swift
- Homepage: https://medium.com/@hitendrahckr
- Size: 7.24 MB
- Stars: 11
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# HSRange
[![CI](https://github.com/hitendradeveloper/HSRange/actions/workflows/HSRange_CI.yml/badge.svg)](https://github.com/hitendradeveloper/HSRange/actions/workflows/HSRange_CI.yml)
[![Version](https://img.shields.io/cocoapods/v/HSRange.svg?style=flat)](http://cocoapods.org/pods/HSRange)## Description
**HSRangeConvertor** Simple and Elegant Range[A,B] to Range[P,Q] mapper in less then three lines of code.
E.g. Suppose we have Range[10,90] and Range[20,80],
Value 60 of Range[10,90] will be mapped to value 57.5 of Range[20,80].**HSColorRangeConvertor** Simple and Elegant Range[A,B] to ColorRange[Color1, Color2] mapper in less then five lines of code.
## Demo
## Example Project
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
| Swift | XCode | Tag/Pod version |
| --- | ------------- | ------ |
| 4.0 to 5.4 | 9.0 to 12 | 5.4.0 |
| 3.x | >= 8.x | 1.1 |## How to use HSRange | HSRangeConvertor?
1. Create object of HSRangeConverter by passing two object of HSRange
- Object of first range [A,B]
- Object of second range [P,Q]
2. Convert your value from one range to other range.```Swift
let firstRange = HSRange(low: 10, high: 80)
let secondRange = HSRange(low: 0.5, high: 0.9)//Step1:
let rangeConverter = HSRangeConverter(range1: firstRange, range2: secondRange)
//Step2:
let valueInFirstRange = rangeConverter.toRange2(of: 45) //this will give 0.7
let valueInSecondRange = rangeConverter.toRange1(of: 0.9) //this will give 80
```## How to use HSColorRange | HSColorRangeConvertor?
Check the demo project. Its has identical steps as above example, just second range is a range of two colors instead of two double values.## Installation
HSRange is available through [CocoaPods](http://cocoapods.org). To install
it follow below steps.1. simply add the following line to your Podfile:
```ruby
pod 'HSRange'
```
2. Open terminal, change your current directory to project directory using `cd`.
3. Install pod.```ruby
pod install
```
##### Possible Error:
`[!] Unable to find a specification for 'HSRange'`
##### Solution:```ruby
pod setup
```## Major Release
pod version 5.4.0 support swift 4 and swift 5 both as well XCode9 to XCode12 all versions.## Author
Hitendra Solanki, [email protected] | twitter: @hitendrahckr
## License
HSRange is available under the MIT license. See the LICENSE file for more info.