Skip to content

Commit

Permalink
Migrate code from "core" into the standard library (#228)
Browse files Browse the repository at this point in the history
- New `arlunio.lib.image` module that now contains all image related code
- Moved math related code to the `arlunio.lib.math` module
  • Loading branch information
alcarney authored May 18, 2020
1 parent 02598c6 commit 1bc1576
Show file tree
Hide file tree
Showing 21 changed files with 330 additions and 419 deletions.
8 changes: 4 additions & 4 deletions arlunio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._core import Defn, DefnInput, definition # noqa: F401
from ._expressions import all, any, clamp, invert, lerp, normalise # noqa: F401
from ._images import Image, Resolutions, colorramp, encode, fill, save # noqa: F401
from ._version import __version__ # noqa: F401
from ._version import __version__
from .definition import Defn, DefnInput, definition

__all__ = ["Defn", "DefnInput", "definition", "__version__"]
212 changes: 0 additions & 212 deletions arlunio/_expressions.py

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions arlunio/doc/directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from typing import List, Tuple

import arlunio as ar
import arlunio.lib.image as img

from docutils import nodes
from docutils.parsers import rst
Expand Down Expand Up @@ -125,7 +125,7 @@ def render_image(

if image is not None:
context = {
"data": ar.encode(image).decode("utf-8"),
"data": img.encode(image).decode("utf-8"),
"rendering": "auto" if smooth else "crisp-edges",
}
html = IMAGE_TEMPLATE.safe_substitute(context)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions arlunio/_images.py → arlunio/lib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import PIL.Image as PImage
import PIL.ImageColor as PColor

from ._expressions import lerp, normalise
from arlunio.lib.math import lerp, normalise

logger = logging.getLogger(__name__)

Expand All @@ -24,7 +24,7 @@ class Resolutions(enum.Enum):
Members of this enum are tuples containing the width and height which can be
accessed by name::
>>> from arlunio import Resolutions as R
>>> from arlunio.lib.image import Resolutions as R
>>> hd = R.HD
>>> hd.width
Expand Down
90 changes: 0 additions & 90 deletions arlunio/lib/mask/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,6 @@ def MaskAdd(
The first mask
b:
The second mask
Examples
--------
This definition is used implicitly when adding two masks together
.. arlunio-image::
:include-code: before
import arlunio as ar
from arlunio.lib import Circle, Square
c1 = Square(xc=-0.25, yc=-0.25, size=0.55)
c2 = Circle(xc=0.25, yc=0.25, r=0.7)
c = c1 + c2
image = ar.fill(c(width=1920, height=1080))
Or can be used directly
.. arlunio-image::
:include-code: before
import arlunio as ar
from arlunio.lib import Circle, MaskAdd, Square
a = Square(xc=-0.25, yc=-0.25, size=0.55)
b = Circle(xc=0.25, yc=0.25, r=0.7)
c = MaskAdd(a=a, b=b)
image = ar.fill(c(width=1920, height=1080))
"""

return ar.any(a(width=width, height=height), b(width=width, height=height))
Expand All @@ -76,36 +46,6 @@ def MaskSub(
The first "base" mask
b:
The second mask that defines the region to remove from :code:`a`
Examples
--------
This definition is used implicitly when subtracting one mask from another
.. arlunio-image::
:include-code: before
import arlunio as ar
from arlunio.lib import Circle, Square
c1 = Square(xc=-0.25, yc=-0.25, size=0.55)
c2 = Circle(xc=0.25, yc=0.25, r=0.7)
c = c1 - c2
image = ar.fill(c(width=1920, height=1080))
Or can be used directly
.. arlunio-image::
:include-code: before
import arlunio as ar
from arlunio.lib import Circle, MaskSub, Square
a = Square(xc=-0.25, yc=-0.25, size=0.55)
b = Circle(xc=0.25, yc=0.25, r=0.7)
c = MaskSub(a=b, b=a)
image = ar.fill(c(width=1920, height=1080))
"""
return ar.all(
a(width=width, height=height), ar.invert(b(width=width, height=height))
Expand All @@ -127,35 +67,5 @@ def MaskMul(
The first mask
b:
The second mask
Examples
--------
This definition is used implicitly when multiplying two masks together
.. arlunio-image::
:include-code: before
import arlunio as ar
from arlunio.lib import Circle, Square
c1 = Square(xc=-0.25, yc=-0.25, size=0.55)
c2 = Circle(xc=0.25, yc=0.25, r=0.7)
c = c1 * c2
image = ar.fill(c(width=1920, height=1080))
Or can be used directly
.. arlunio-image::
:include-code: before
import arlunio as ar
from arlunio.lib import Circle, MaskMul, Square
a = Square(xc=-0.25, yc=-0.25, size=0.55)
b = Circle(xc=0.25, yc=0.25, r=0.7)
c = MaskMul(a=a, b=b)
image = ar.fill(c(width=1920, height=1080))
"""
return ar.all(a(width=width, height=height), b(width=width, height=height))
Loading

0 comments on commit 1bc1576

Please sign in to comment.