-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from alcarney/color
- Add back the ability to pass in parameter values directly to definitions - Add `lerp` function to do linear interpolation - Add `clamp` function that can be used to limit values in an array - Add `colorramp` function that can map an array of values into a color range - Update tests and docs
- Loading branch information
Showing
14 changed files
with
207 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from ._color import RGB8 # noqa: F401 | ||
from ._core import Collection, Definition, definition # noqa: F401 | ||
from ._expressions import all, any, invert # noqa: F401 | ||
from ._image import Image, Resolutions, fill # noqa: F401 | ||
from ._expressions import all, any, clamp, invert, lerp # noqa: F401 | ||
from ._images import Image, Resolutions, colorramp, fill # noqa: F401 | ||
from ._version import __version__ # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.0.4" | ||
__version__ = "0.0.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.. _stdlib_shapes: | ||
|
||
Shapes | ||
====== | ||
|
||
Built in definitions of basic shapes. | ||
|
||
.. autodefn:: arlunio.lib.shapes.Circle | ||
|
||
.. autodefn:: arlunio.lib.shapes.Ellipse | ||
|
||
.. autodefn:: arlunio.lib.shapes.Rectangle | ||
|
||
.. autodefn:: arlunio.lib.shapes.Square | ||
|
||
.. autodefn:: arlunio.lib.shapes.SuperEllipse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import arlunio as ar | ||
import numpy as np | ||
|
||
|
||
def test_colorramp_defaults(): | ||
"""Ensure that the colorramp method chooses sensible defaults.""" | ||
|
||
values = np.array([[0.0, 0.5], [0.75, 1.0]]) | ||
img = ar.colorramp(values) | ||
|
||
pix = np.array( | ||
[[[0, 0, 0], [127, 127, 127]], [[191, 191, 191], [255, 255, 255]]], | ||
dtype=np.uint8, | ||
) | ||
|
||
assert (img.pixels == pix).all() | ||
|
||
|
||
def test_colorramp(): | ||
"""Ensure that the colorramp parses the colors it is given.""" | ||
|
||
values = np.array([[0.0, 0.5], [0.75, 1.0]]) | ||
img = ar.colorramp(values, start="f00", stop="0f0") | ||
|
||
pix = np.array( | ||
[[[255, 0, 0], [127, 127, 0]], [[63, 191, 0], [0, 255, 0]]], dtype=np.uint8 | ||
) | ||
|
||
assert (img.pixels == pix).all() | ||
|
||
|
||
def test_fill_defaults(): | ||
"""Ensure that the fill method chooses sensible defaults.""" | ||
|
||
mask = np.array([[False, True], [True, False]]) | ||
img = ar.fill(mask) | ||
|
||
pix = np.array( | ||
[[[255, 255, 255], [0, 0, 0]], [[0, 0, 0], [255, 255, 255]]], dtype=np.uint8 | ||
) | ||
|
||
assert (img.pixels == pix).all() | ||
|
||
|
||
def test_fill(): | ||
"""Ensure that the fill method parses colors that it is given.""" | ||
|
||
mask = np.array([[False, True], [True, False]]) | ||
img = ar.fill(mask, color="f00", background="0f0") | ||
|
||
pix = np.array( | ||
[[[0, 255, 0], [255, 0, 0]], [[255, 0, 0], [0, 255, 0]]], dtype=np.uint8 | ||
) | ||
|
||
assert (img.pixels == pix).all() |