예제 #1
0
def simple_lines():
    C = Canvas(**canvas_args)

    tc = 0.04

    # An example of the functional interface Artist(Canvas)
    for i in np.arange(-4, 5, 0.5):
        line(x=-4, y=i, x1=4, y1=i, thickness=tc, color=[20] * 3)(C)
        line(x=i, y=4, x1=i, y1=-4, thickness=tc, color=[20] * 3)(C)

    for i in np.arange(-4, 5, 1):
        line(x=-4,
             y=i,
             x1=4,
             y1=i,
             thickness=tc,
             color=[100, int(100 + i * 10), 100])(C)
        line(x=i,
             y=4,
             x1=i,
             y1=-4,
             thickness=tc,
             color=[100, 100, int(100 + i * 10)])(C)

    line(-4, 0, 4, 0, thickness=0.05)(C)
    line(0, 4, 0, -4, thickness=0.05)(C)

    return C
예제 #2
0
def teyleen_982():
    C = Canvas(**canvas_args)
    pi = np.pi

    pal = [matplotlib_colors("lavender")] + ph.palette(96)
    tc = 0.025

    dx = pi / 8
    t0 = dx
    t1 = 2 * pi - dx
    r = 1.8

    for n in range(6):
        ellipse(
            a=r,
            b=r,
            rotation=pi / 2,
            angle_start=t0,
            angle_end=t1,
            color=pal[n],
            thickness=tc,
        )(C)

        dx *= 1.4
        t0 = dx
        t1 = 2 * pi - dx
        r -= 0.2

    return C
예제 #3
0
def simple_rectangles():
    C = Canvas(**canvas_args)

    C += rectangle(-1, -1, 1, 1, color="lightcoral")
    C += rectangle(0, 0, 2, -2, color="lime")
    C += rectangle(-3, -3, 0.5, 0.5, color="royalblue")

    return C
예제 #4
0
def instagram_filters():

    f_sample = "pixelhouse/filter/insta/samples/Normal.jpg"
    C = Canvas(bg="w", **canvas_args).load(f_sample)
    C += scale(fx=0.25)
    C += circle(r=0.50, color="r")
    C += instafilter("Ludwig", weight=0.80)

    return C
예제 #5
0
def teyleen_116():
    C = Canvas(**canvas_args)
    pal = ph.palette(152)

    x = 0.25
    C += circle(x, x, r=x / 2, color=pal[0])
    C += circle(-x, x, r=x / 2, color=pal[1])
    C += circle(x, -x, r=x / 2, color=pal[2])
    C += circle(-x, -x, r=x / 2, color=pal[3])

    C += circle(y=x / 2, r=2 - x, color=pal[4], thickness=x / 20)
    C += circle(y=-x / 2, r=2 - x, color=pal[4], thickness=x / 20)

    return C
예제 #6
0
def simple_circles():
    C = Canvas(**canvas_args)

    n = 3
    t = np.arange(0, 2 * np.pi, 2 * np.pi / n) + np.pi / 6
    x, y = np.cos(t), np.sin(t)

    C += circle(x[0], y[0], 1, color=[0, 255, 0], mode="add")
    C += circle(x[1], y[1], 1, color=[255, 0, 0], mode="add")
    C += circle(x[2], y[2], 1, color=[0, 0, 255], mode="add")

    # An example of not saturating the images together
    C += circle(0, 0, 0.25, color=[155, 155, 155])

    return C
예제 #7
0
 def text_test(self):
     C = Canvas()
     C += text()
     assert_true(C._img.sum() > 0)
예제 #8
0
 def rectange_test(self):
     C = Canvas()
     C += rectangle()
     assert_true(C._img.sum() > 0)
예제 #9
0
 def line_test(self):
     C = Canvas()
     C += line()
     assert_true(C._img.sum() > 0)
예제 #10
0
 def ellipse_test(self):
     C = Canvas()
     C += ellipse()
     assert_true(C._img.sum() > 0)
예제 #11
0
 def circle_test(self):
     C = Canvas()
     C += circle()
     assert_true(C._img.sum() > 0)
예제 #12
0
# A working file to test various aspects of the module
import numpy as np
from pixelhouse import Artist
from pixelhouse import Canvas, Animation, circle, motion
from pixelhouse.transform.simple import translate, rotate
from pixelhouse.transform.elastic import distort

A = Canvas()
A = Animation(duration=2, fps=15)

A += circle(color="w")
A += circle(-1, 0, 0.25, color="purple")

theta = motion.easeReturn("easeInOutQuad", 0, np.pi, len(A))
A += rotate(theta)

z = motion.easeReturn("easeInOutQuad", 0, 10, len(A))
A += distort(seed=42, sigma=0.05, alpha=z)

A.show()
예제 #13
0
# A working file to test various aspects of the module
import numpy as np
import pixelhouse as ph
from pixelhouse import Canvas, Animation, circle, rectangle

C = Canvas(width=400, height=400, bg="purple")

with C.layer() as CX:
    CX += circle(x=0, color="w")
    for i in range(10):
        CX += ph.filters.gaussian_blur(blur_x=0.25)

    CX += circle(x=0, color="w")

C += circle(x=0, y=2, r=0.7, color="r")
C += circle(x=0, y=-2, r=0.7, color="k")
C += circle(x=0, y=2, r=0.7, color="r")

C.show()
예제 #14
0
# A working file to test various aspects of the module
import numpy as np
import pixelhouse as ph
from pixelhouse import Canvas, Animation, polyline, circle, Artist
from pixelhouse.transform import rotate, translate
from pixelhouse.filter import gaussian_blur

pal = ph.ColorLoversPalette()(4)

C = Canvas(width=400, height=400, bg=pal[0])
C = Animation(width=400, height=400, bg=pal[0])

C += circle(x=1, y=-0.5, color=pal[1])

theta = np.linspace(0, 2 * np.pi)

with C.layer() as CX:
    CX += polyline(color="k")
    CX += rotate(theta)
    CX += gaussian_blur(0.25, theta / 6)


C += circle(x=-1, r=0.5)
C.show()
예제 #15
0
    lg = ph.gradient.linear([pal[0], pal[1]], [1, 0], theta=-np.pi / 2)
    C += circle(0, 0, radius + offset, thickness=tc, gradient=lg)

    lg = ph.gradient.linear([pal[0], pal[1]], [1, 0], theta=np.pi / 2)
    C += circle(0, 0, radius - 2 * offset, thickness=tc / 2, gradient=lg)

    lg = ph.gradient.linear([pal[2], pal[1]], [1, 0], theta=-np.pi / 2)
    C += circle(0, 0, radius - offset, thickness=tc / 2, gradient=lg)

    lg = ph.gradient.linear([pal[2], pal[1]], [1, 0], theta=np.pi / 2)
    C += circle(0, 0, radius + 1.5 * offset, thickness=tc / 2, gradient=lg)


# Start a new canvas and load in an image. It will resize automatically.
C = Canvas().load("asphalt-dark-dawn-531321.jpg")

# Apply the instagram-like filter named 1977.
# Use ph.filters.instafilter("") to get a list of all known.
C += ph.filters.instafilter("1977")

# Start a new layer. This uses the current image as a background, and then
# applies it after the context is over.
with C.layer() as layer:

    # Draw the circles, blend, then draw them again.
    # This makes them have a glowy effect.
    draw_circles(layer)
    layer += ph.filters.gaussian_blur()
    draw_circles(layer)