Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[![mybinder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/py5coding/py5examples/HEAD?urlpath=lab)

py5 is a new version of [Processing][processing] for Python 3.9+. The goal of py5 is to create a version of Processing that is [integrated into the Python ecosystem](https://py5coding.org/integrations/python_ecosystem_integrations.html). Built into the library are thoughtful choices about how to best get py5 to work with other popular Python libraries and tools such as [Jupyter](https://jupyter.org/), [numpy](https://numpy.org/), [shapely](https://shapely.readthedocs.io/en/stable/), [trimesh](https://trimesh.org/), [matplotlib](https://matplotlib.org/), and [Pillow](https://python-pillow.org/).
py5 is a new version of [Processing][processing] for Python. The goal of py5 is to create a version of Processing that is [integrated into the Python ecosystem](https://py5coding.org/integrations/python_ecosystem_integrations.html). Built into the library are thoughtful choices about how to best get py5 to work with other popular Python libraries and tools such as [Jupyter](https://jupyter.org/), [numpy](https://numpy.org/), [shapely](https://shapely.readthedocs.io/en/stable/), [trimesh](https://trimesh.org/), [matplotlib](https://matplotlib.org/), and [Pillow](https://python-pillow.org/).

py5 is an excellent choice for educators looking to teach Python in the context of creative coding and is currently used in classrooms all around the world. The documentation website includes [introductory tutorials](https://py5coding.org/tutorials/intro_to_py5_and_python.html) as well as extensive [reference documentation](https://py5coding.org/reference/summary.html), complete with example code.

Expand Down
21 changes: 20 additions & 1 deletion py5/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# *****************************************************************************
# -*- coding: utf-8 -*-
"""
py5 is a version of Processing for Python 3.9+. It makes the Processing Java libraries available to the CPython interpreter using JPype.
py5 is a version of Processing for Python. It makes the Processing Java libraries available to the CPython interpreter using JPype.
"""
from __future__ import annotations

Expand Down Expand Up @@ -208,6 +208,8 @@
BASELINE = 0
BEVEL = 32
BEZIER_VERTEX = 1
BICUBIC = 2
BILINEAR = 1
BLEND = 1
BLUR = 11
BOTTOM = 102
Expand Down Expand Up @@ -289,6 +291,7 @@
MODEL = 4
MOVE = 13
MULTIPLY = 128
NEAREST_NEIGHBOR = 0
NORMAL = 1
OPAQUE = 14
OPEN = 1
Expand Down Expand Up @@ -3792,6 +3795,10 @@ def copy() -> Py5Image:
the source image has an alpha channel set, it will be copied as well.

This function ignores `image_mode()`.

If you want to create a new image with the contents of a rectangular region of
the sketch, check out `get_pixels()` where x, y, w, h, are the position and
dimensions of the area to be copied. It will return a `Py5Image` object.
"""
pass

Expand Down Expand Up @@ -3856,6 +3863,10 @@ def copy(
the source image has an alpha channel set, it will be copied as well.

This function ignores `image_mode()`.

If you want to create a new image with the contents of a rectangular region of
the sketch, check out `get_pixels()` where x, y, w, h, are the position and
dimensions of the area to be copied. It will return a `Py5Image` object.
"""
pass

Expand Down Expand Up @@ -3929,6 +3940,10 @@ def copy(
the source image has an alpha channel set, it will be copied as well.

This function ignores `image_mode()`.

If you want to create a new image with the contents of a rectangular region of
the sketch, check out `get_pixels()` where x, y, w, h, are the position and
dimensions of the area to be copied. It will return a `Py5Image` object.
"""
pass

Expand Down Expand Up @@ -3990,6 +4005,10 @@ def copy(*args):
the source image has an alpha channel set, it will be copied as well.

This function ignores `image_mode()`.

If you want to create a new image with the contents of a rectangular region of
the sketch, check out `get_pixels()` where x, y, w, h, are the position and
dimensions of the area to be copied. It will return a `Py5Image` object.
"""
return _py5sketch.copy(*args)

Expand Down
23 changes: 23 additions & 0 deletions py5/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,8 @@ def color(self, *args) -> int:
BASELINE = 0
BEVEL = 32
BEZIER_VERTEX = 1
BICUBIC = 2
BILINEAR = 1
BLEND = 1
BLUE_MASK = 255
BLUR = 11
Expand Down Expand Up @@ -1731,6 +1733,7 @@ def color(self, *args) -> int:
MODEL = 4
MOVE = 13
MULTIPLY = 128
NEAREST_NEIGHBOR = 0
NORMAL = 1
OPAQUE = 14
OPEN = 1
Expand Down Expand Up @@ -5581,6 +5584,11 @@ def copy(self) -> Py5Image:

This method is the same as `copy()` but linked to a `Py5Graphics` object. To see
example code for how it can be used, see `copy()`.

If you want to create a new image with the contents of a rectangular region of a
`Py5Graphics` object, check out the `Py5Graphics.get_pixels()` method, where x,
y, w, h, are the position and dimensions of the area to be copied. It will
return a `Py5Image` object.
"""
pass

Expand Down Expand Up @@ -5647,6 +5655,11 @@ def copy(

This method is the same as `copy()` but linked to a `Py5Graphics` object. To see
example code for how it can be used, see `copy()`.

If you want to create a new image with the contents of a rectangular region of a
`Py5Graphics` object, check out the `Py5Graphics.get_pixels()` method, where x,
y, w, h, are the position and dimensions of the area to be copied. It will
return a `Py5Image` object.
"""
pass

Expand Down Expand Up @@ -5723,6 +5736,11 @@ def copy(

This method is the same as `copy()` but linked to a `Py5Graphics` object. To see
example code for how it can be used, see `copy()`.

If you want to create a new image with the contents of a rectangular region of a
`Py5Graphics` object, check out the `Py5Graphics.get_pixels()` method, where x,
y, w, h, are the position and dimensions of the area to be copied. It will
return a `Py5Image` object.
"""
pass

Expand Down Expand Up @@ -5787,6 +5805,11 @@ def copy(self, *args):

This method is the same as `copy()` but linked to a `Py5Graphics` object. To see
example code for how it can be used, see `copy()`.

If you want to create a new image with the contents of a rectangular region of a
`Py5Graphics` object, check out the `Py5Graphics.get_pixels()` method, where x,
y, w, h, are the position and dimensions of the area to be copied. It will
return a `Py5Image` object.
"""
return self._instance.copy(*args)

Expand Down
157 changes: 157 additions & 0 deletions py5/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def __getattr__(self, name):
ALPHA = 4
ALPHA_MASK = -16777216
ARGB = 2
BICUBIC = 2
BILINEAR = 1
BLEND = 1
BLUE_MASK = 255
BLUR = 11
Expand All @@ -120,6 +122,7 @@ def __getattr__(self, name):
INVERT = 13
LIGHTEST = 8
MULTIPLY = 128
NEAREST_NEIGHBOR = 0
OPAQUE = 14
OVERLAY = 512
POSTERIZE = 15
Expand Down Expand Up @@ -591,6 +594,11 @@ def copy(self) -> Py5Image:
as well.

This function ignores `image_mode()`.

If you want to create a new image with the contents of a rectangular region of a
`Py5Image` object, check out the `Py5Image.get_pixels()` method, where x, y, w,
h, are the position and dimensions of the area to be copied. It will return a
`Py5Image` object.
"""
pass

Expand Down Expand Up @@ -651,6 +659,11 @@ def copy(
as well.

This function ignores `image_mode()`.

If you want to create a new image with the contents of a rectangular region of a
`Py5Image` object, check out the `Py5Image.get_pixels()` method, where x, y, w,
h, are the position and dimensions of the area to be copied. It will return a
`Py5Image` object.
"""
pass

Expand Down Expand Up @@ -721,6 +734,11 @@ def copy(
as well.

This function ignores `image_mode()`.

If you want to create a new image with the contents of a rectangular region of a
`Py5Image` object, check out the `Py5Image.get_pixels()` method, where x, y, w,
h, are the position and dimensions of the area to be copied. It will return a
`Py5Image` object.
"""
pass

Expand Down Expand Up @@ -779,6 +797,11 @@ def copy(self, *args):
as well.

This function ignores `image_mode()`.

If you want to create a new image with the contents of a rectangular region of a
`Py5Image` object, check out the `Py5Image.get_pixels()` method, where x, y, w,
h, are the position and dimensions of the area to be copied. It will return a
`Py5Image` object.
"""
return self._instance.copy(*args)

Expand Down Expand Up @@ -1270,6 +1293,140 @@ def mask(self, *args):
"""
return self._instance.mask(*args)

@overload
def resize(self, w: int, h: int, /) -> None:
"""Resize the Py5Image object to a new height and width.

Underlying Processing method: PImage.resize

Methods
-------

You can use any of the following signatures:

* resize(w: int, h: int, /) -> None
* resize(w: int, h: int, interpolation_mode: int, /) -> None

Parameters
----------

h: int
height to size image to

interpolation_mode: int
interpolation method for resize operation

w: int
width to size image to

Notes
-----

Resize the Py5Image object to a new height and width. This will modify the
Py5Image object in place, meaning that rather than returning a resized copy, it
will modify your existing Py5Image object. If this isn't what you want, pair
this method with `Py5Image.copy()`, as shown in the example.

To make the image scale proportionally, use 0 as the value for either the `w` or
`h` parameter.

The default resize interpolation mode is `BILINEAR`. Alternatively you can use
the `interpolation_mode` parameter to interpolate using the `NEAREST_NEIGHBOR`
method, which is faster but yields lower quality results. You can also use
`BICUBIC` interpolation, which is the most computationally intensive but looks
the best, particularly for up-scaling operations.
"""
pass

@overload
def resize(self, w: int, h: int, interpolation_mode: int, /) -> None:
"""Resize the Py5Image object to a new height and width.

Underlying Processing method: PImage.resize

Methods
-------

You can use any of the following signatures:

* resize(w: int, h: int, /) -> None
* resize(w: int, h: int, interpolation_mode: int, /) -> None

Parameters
----------

h: int
height to size image to

interpolation_mode: int
interpolation method for resize operation

w: int
width to size image to

Notes
-----

Resize the Py5Image object to a new height and width. This will modify the
Py5Image object in place, meaning that rather than returning a resized copy, it
will modify your existing Py5Image object. If this isn't what you want, pair
this method with `Py5Image.copy()`, as shown in the example.

To make the image scale proportionally, use 0 as the value for either the `w` or
`h` parameter.

The default resize interpolation mode is `BILINEAR`. Alternatively you can use
the `interpolation_mode` parameter to interpolate using the `NEAREST_NEIGHBOR`
method, which is faster but yields lower quality results. You can also use
`BICUBIC` interpolation, which is the most computationally intensive but looks
the best, particularly for up-scaling operations.
"""
pass

def resize(self, *args):
"""Resize the Py5Image object to a new height and width.

Underlying Processing method: PImage.resize

Methods
-------

You can use any of the following signatures:

* resize(w: int, h: int, /) -> None
* resize(w: int, h: int, interpolation_mode: int, /) -> None

Parameters
----------

h: int
height to size image to

interpolation_mode: int
interpolation method for resize operation

w: int
width to size image to

Notes
-----

Resize the Py5Image object to a new height and width. This will modify the
Py5Image object in place, meaning that rather than returning a resized copy, it
will modify your existing Py5Image object. If this isn't what you want, pair
this method with `Py5Image.copy()`, as shown in the example.

To make the image scale proportionally, use 0 as the value for either the `w` or
`h` parameter.

The default resize interpolation mode is `BILINEAR`. Alternatively you can use
the `interpolation_mode` parameter to interpolate using the `NEAREST_NEIGHBOR`
method, which is faster but yields lower quality results. You can also use
`BICUBIC` interpolation, which is the most computationally intensive but looks
the best, particularly for up-scaling operations.
"""
return self._instance.resize(*args)

@overload
def set_pixels(self, x: int, y: int, c: int, /) -> None:
"""Changes the color of any pixel or writes an image directly into the Py5Image
Expand Down
Binary file modified py5/jars/core.jar
Binary file not shown.
Binary file modified py5/jars/dxf/dxf.jar
Binary file not shown.
Binary file modified py5/jars/pdf/pdf.jar
Binary file not shown.
Binary file modified py5/jars/py5.jar
Binary file not shown.
Binary file modified py5/jars/svg/svg.jar
Binary file not shown.
Loading