Giter VIP home page Giter VIP logo

nmap's Introduction

nmap

Map a number from one range to another

>>> from nmap import nmap
>>> mapfn = nmap(0, 100, 500, 1000)
>>> mapfn(0)
500.0
>>> mapfn(50)
750.0
>>> mapfn(100)
1000.0

Example using the normfn argument to cast output to int

>>> from nmap import nmap
>>> mapfn = nmap(500, 1000, 1, 10, normfn=int)
>>> mapfn(500)
1
>>> mapfn(750)
5
>>> mapfn(1000)
10

Example using easing functions as curvefn

import matplotlib.pyplot as plt
import numpy as np
import math

from ease import *
from nmap import nmap

x = np.linspace(0, 1)
yaxis = (np.linspace(0, 0), np.linspace(-10, 10))
easefns = [cubic_in, cubic_out, cubic_in_out, out_back]
fns = [nmap(0, 1, 500, 1500, fn) for fn in easefns]
size = math.ceil(math.sqrt(len(fns)))
size = size * 100 + size * 10

for i, fn in enumerate(fns):
    plt.subplot(size + i + 1)
    plt.plot(*yaxis, 'black')
    plt.plot(*reversed(yaxis), 'black')
    plt.plot(x, np.array([fn(xn) for xn in x]))
    plt.axis([0, 1, 500, 1720])

plt.show()

easing functions

nmap's People

Contributors

antonagestam avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nmap's Issues

Rename this module

I strongly suggest that you rename your module for the following reasons:

  • there is a well-known tool out there called nmap. your choice looks very much that you want to piggyback on their name and search engine results
  • your module will never make it into the repositories of the distributions because py-nmap or python-nmap is already taken by the binding of the tool mentioned above

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.