GithubHelp home page GithubHelp logo

hitendradeveloper / hsrange Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 1.0 7.41 MB

Simple and Elegant Range(A,B) to Range(P,Q) mapper in less then five lines of code.

Home Page: https://medium.com/@hitendrahckr

License: MIT License

Swift 94.42% Ruby 5.58%
mathematics calculations range mapping range-map converter easy-to-use elegant ios macos

hsrange's Introduction

HSRange

CI Version

Description

HSRange

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

HSRange HSColorRange

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.
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. To install it follow below steps.

  1. simply add the following line to your Podfile:
pod 'HSRange'
  1. Open terminal, change your current directory to project directory using cd.
  2. Install pod.
pod install
Possible Error:

[!] Unable to find a specification for 'HSRange'

Solution:
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.

hsrange's People

Contributors

hitendradeveloper avatar hitendraspaceo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

carabina

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.