Unverified Commit 00ca6a6d authored by ThereforeGames's avatar ThereforeGames Committed by GitHub

Add files via upload

parent 685f9631
This diff is collapsed.
Copyright (c) 2015, 2016, 2017, 2018 Ethan Furman.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
Neither the name Ethan Furman nor the names of any
contributors may be used to endorse or promote products
derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
This source diff could not be displayed because it is too large. You can view the blob instead.
from operator import div as _div_
from inspect import getargspec
def raise_with_traceback(exc, tb):
raise exc, None, tb
__all__ = ['_div_', 'getargspec', 'raise_with_traceback']
from inspect import getfullargspec as _getfullargspec
def getargspec(method):
args, varargs, keywords, defaults, _, _, _ = _getfullargspec(method)
return args, varargs, keywords, defaults
def raise_with_traceback(exc, tb):
raise exc.with_traceback(tb)
def raise_from_none(exc):
raise exc from None
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
"""Use this module to apply a number of blending modes to a background and foreground image
"""
This diff is collapsed.
"""Specify supported blend types."""
from __future__ import annotations
from aenum import MultiValueEnum
class BlendType(str, MultiValueEnum):
"""Specify supported blend types.
NORMAL = "bm:normal", "normal"
MULTIPLY = "bm:multiply", "multiply"
ADDITIVE = "bm:additive", "additive"
COLOURBURN = "bm:colourburn", "colourburn"
COLOURDODGE = "bm:colourdodge", "colourdodge"
REFLECT = "bm:reflect", "reflect"
GLOW = "bm:glow", "glow"
OVERLAY = "bm:overlay", "overlay"
DIFFERENCE = "bm:difference", "difference"
NEGATION = "bm:negation", "negation"
LIGHTEN = "bm:lighten", "lighten"
DARKEN = "bm:darken", "darken"
SCREEN = "bm:screen", "screen"
XOR = "bm:xor", "xor"
SOFTLIGHT = "bm:softlight", "softlight"
HARDLIGHT = "bm:hardlight", "hardlight"
GRAINEXTRACT = "bm:grainextract", "grainextract"
GRAINMERGE = "bm:grainmerge", "grainmerge"
DIVIDE = "bm:divide", "divide"
HUE = "bm:hue", "hue"
SATURATION = "bm:saturation", "saturation"
COLOUR = "bm:colour", "colour"
LUMINOSITY = "bm:luminosity", "luminosity"
PINLIGHT = "bm:pinlight", "pinlight"
VIVIDLIGHT = "bm:vividlight", "vividlight"
EXCLUSION = "bm:exclusion", "exclusion"
DESTIN = "bm:destin", "destin"
DESTOUT = "bm:destout", "destout"
SRCATOP = "bm:srcatop", "srcatop"
DESTATOP = "bm:destatop", "destatop"
"""
NORMAL = "bm:normal", "normal"
MULTIPLY = "bm:multiply", "multiply"
ADDITIVE = "bm:additive", "additive"
COLOURBURN = "bm:colourburn", "colourburn"
COLOURDODGE = "bm:colourdodge", "colourdodge"
REFLECT = "bm:reflect", "reflect"
GLOW = "bm:glow", "glow"
OVERLAY = "bm:overlay", "overlay"
DIFFERENCE = "bm:difference", "difference"
NEGATION = "bm:negation", "negation"
LIGHTEN = "bm:lighten", "lighten"
DARKEN = "bm:darken", "darken"
SCREEN = "bm:screen", "screen"
XOR = "bm:xor", "xor"
SOFTLIGHT = "bm:softlight", "softlight"
HARDLIGHT = "bm:hardlight", "hardlight"
GRAINEXTRACT = "bm:grainextract", "grainextract"
GRAINMERGE = "bm:grainmerge", "grainmerge"
DIVIDE = "bm:divide", "divide"
HUE = "bm:hue", "hue"
SATURATION = "bm:saturation", "saturation"
COLOUR = "bm:colour", "colour"
LUMINOSITY = "bm:luminosity", "luminosity"
PINLIGHT = "bm:pinlight", "pinlight"
VIVIDLIGHT = "bm:vividlight", "vividlight"
EXCLUSION = "bm:exclusion", "exclusion"
DESTIN = "bm:destin", "destin"
DESTOUT = "bm:destout", "destout"
SRCATOP = "bm:srcatop", "srcatop"
DESTATOP = "bm:destatop", "destatop"
"""Do stuff to images to prepare them.
"""
from __future__ import annotations
import warnings
from deprecation import deprecated
from PIL import Image
@deprecated(deprecated_in="2021.1", removed_in="", details="use renderWAlphaOffset")
def rasterImageOA( # pylint:disable=missing-function-docstring
image: Image.Image, size: tuple[int, int], alpha: float = 1.0, offsets: tuple[int, int] = (0, 0)
) -> Image.Image:
warnings.warn(
"Call to deprecated function rasterImageOA.", category=DeprecationWarning, stacklevel=2
)
return renderWAlphaOffset(image, size, alpha, offsets)
@deprecated(deprecated_in="2021.1", removed_in="", details="use renderWAlphaOffset")
def rasterImageOffset( # pylint:disable=missing-function-docstring
image: Image.Image, size: tuple[int, int], offsets: tuple[int, int] = (0, 0)
) -> Image.Image:
warnings.warn(
"Call to deprecated function rasterImageOffset.", category=DeprecationWarning, stacklevel=2
)
return renderWAlphaOffset(image, size, 1, offsets)
def renderWAlphaOffset(
image: Image.Image, size: tuple[int, int], alpha: float = 1.0, offsets: tuple[int, int] = (0, 0)
) -> Image.Image:
"""Render an image with offset and alpha to a given size.
Args:
image (Image.Image): pil image to draw
size (tuple[int, int]): width, height as a tuple
alpha (float, optional): alpha transparency. Defaults to 1.0.
offsets (tuple[int, int], optional): x, y offsets as a tuple.
Defaults to (0, 0).
Returns:
Image.Image: new image
"""
imageOffset = Image.new("RGBA", size)
imageOffset.paste(image.convert("RGBA"), offsets, image.convert("RGBA"))
return Image.blend(Image.new("RGBA", size), imageOffset, alpha)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment