コード例 #1
0
ファイル: small_demos.py プロジェクト: silky/pixelhouse
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
コード例 #2
0
ファイル: small_demos.py プロジェクト: Inkognita/pixelhouse
def simple_lines():
    C = Canvas(**canvas_args)

    tc = 0.08

    # 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.10)(C)
    line(0, 4, 0, -4, thickness=0.10)(C)

    return C
コード例 #3
0
 def text_test(self):
     C = Canvas()
     C += text()
     assert_true(C._img.sum() > 0)
コード例 #4
0
 def rectange_test(self):
     C = Canvas()
     C += rectangle()
     assert_true(C._img.sum() > 0)
コード例 #5
0
 def line_test(self):
     C = Canvas()
     C += line()
     assert_true(C._img.sum() > 0)
コード例 #6
0
 def ellipse_test(self):
     C = Canvas()
     C += ellipse()
     assert_true(C._img.sum() > 0)
コード例 #7
0
 def circle_test(self):
     C = Canvas()
     C += circle()
     assert_true(C._img.sum() > 0)
コード例 #8
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()
コード例 #9
0
ファイル: playground1.py プロジェクト: jdc08161063/pixelhouse
# 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()
コード例 #10
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()
コード例 #11
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)