Skip to content

Commit

Permalink
Final 0.1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
samirelanduk committed Oct 29, 2017
1 parent ca2c012 commit b978706
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 3 deletions.
127 changes: 127 additions & 0 deletions README.rst
@@ -0,0 +1,127 @@
.. |travis| image:: https://api.travis-ci.org/samirelanduk/imagipy.svg?branch=0.1

.. |coveralls| image:: https://coveralls.io/repos/github/samirelanduk/imagipy/badge.svg?branch=0.1

.. |pypi| image:: https://img.shields.io/pypi/pyversions/imagipy.svg


|travis| |coveralls| |pypi|

imagipy
=======

imagipy is an image and color processing library.

Example
-------

>>> import imagipy
>>> red = Color(255, 0, 0)
>>> green = Color.from_hex("#00FF00")
>>> blue = Color.from_hex("0000FF")
>>> red.mutate()
<Color (249, 2, 7)>





Installing
----------

pip
~~~

imagipy can be installed using pip:

``$ pip3 install imagipy``

imagipy is written for Python 3, and does not support Python 2. It is currently
tested on Python 3.5 and above.

If you get permission errors, try using ``sudo``:

``$ sudo pip3 install imagipy``


Development
~~~~~~~~~~~

The repository for imagipy, containing the most recent iteration, can be
found `here <http://github.com/samirelanduk/imagipy/>`_. To clone the
imagipy repository directly from there, use:

``$ git clone git://github.com/samirelanduk/imagipy.git``


Requirements
~~~~~~~~~~~~

imagipy currently has no dependencies.


Overview
--------

imagipy is an image processing library. It currently has tools for dealing with
colors.

Colors
~~~~~~

Colors are created with the ``Color`` class:

>>> import imagipy
>>> purple = imagipy.Color(255, 0, 255)
>>> purple
<Color (255, 0, 255)>

You can also create colors from hex strings:

>>> orange = imagipy.Color.from_hex("#E67E22")
>>> orange
<Color (230, 126, 34)>

imagipy comes with some pre-set colors:

>>> imagipy.Color.YELLOW
<Color (241, 196, 15)>
>>> imagipy.Color.GRAY
<Color (204, 204, 204)>
>>> imagipy.Color.BROWN
<Color (124, 63, 0)>

You can get a random color, or mutate an existing color to get a slight variant
on it:

>>> imagipy.Color.random()
<Color (45, 217, 230)>
>>> imagipy.Color.random()
<Color (249, 244, 177)>
>>> imagipy.Color.random()
<Color (112, 178, 218)>
>>> orange.mutate()
<Color (229, 131, 43)>
>>> orange.mutate()
<Color (216, 127, 28)>
>>> orange.mutate()
<Color (235, 127, 29)>

Colors can be converted to RGB or hex:

>>> orange.rgb()
(230, 126, 34)
>>> orange.hex()
'#E67E22'


Changelog
---------

Release 0.1.0
~~~~~~~~~~~~~

`29 October 2017`

* Added basic Color class.
* Added Color generation from RGB, hex, random, and mutation.
4 changes: 2 additions & 2 deletions imagipy/colors.py
Expand Up @@ -23,7 +23,7 @@ def __init__(self, r, g, b):
@staticmethod
def from_hex(hexcolor):
"""An alternate constructor which creates a color from a hex string
such as ``'#0B9586'``. The preceding `#` is optional.
such as ``'#0B9586'``. The preceding ``#`` is optional.
:param str hexcolor: The hex string representing the desired color.
:raises TypeError: if a non-string is given.
Expand Down Expand Up @@ -77,7 +77,7 @@ def mutate(self):
direction.
:rtype: ``Color``"""

r = randint(self._r - 16, self._r + 16)
g = randint(self._g - 16, self._g + 16)
b = randint(self._b - 16, self._b + 16)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -15,5 +15,5 @@
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6"],
packages=["imagipy", "imagipy.models"],
packages=["imagipy"],
install_requires=[])

0 comments on commit b978706

Please sign in to comment.