def shadowing(C, coords, color="r", n=5, dx=1.0, dy=1.0, n_refinements=2): """ Shadows around a set of "coords" onto a canvas. Used for eye liner or eye shadow. n: number of times to diffuse the glow outwards (succesive applications) dx, dy: Glow in the x and y directions color: shadow color n_refinements: Number of times to smooth the points """ # Smooth the coordinates a bit if requested coords = chaikins_corner_cutting(coords, refinements=n_refinements) ex, ey = zip(*coords) # Scale glow based of the extent in the x direction box_extent = coords.max(axis=0) - coords.min(axis=0) x_extent = box_extent[0] ratio = box_extent[0] / box_extent[1] dx *= x_extent dy *= x_extent / ratio # Make a copy of the image with a transparent mask C2 = C.copy() C2.alpha = 255 # 'Glow' around the mask mask = ph.polyline(ex, ey, is_filled=1, color=color) C2 += ph.filters.glow(mask, glow_x=dx, glow_y=dy, n=n) # Erase the mask C2 += ph.polyline(ex, ey, is_filled=1, color=[0, 0, 0, 0]) # Overlay the glow C += C2 return C
def polyline_test(self): C = Canvas() C += polyline() assert_true(C._img.sum() > 0)
# A working file to test various aspects of the module import numpy as np import pixelhouse as ph pal = ph.palette(4) C = ph.Canvas(width=400, height=400, bg=pal[0]) C = ph.Animation(width=400, height=400, bg=pal[0]) C += ph.circle(x=1, y=-0.5, r=2, color=pal[1]) theta = np.linspace(0, 2 * np.pi) with C.layer() as CX: CX += ph.polyline(color="k") CX += ph.transform.rotate(theta) CX += ph.filters.gaussian_blur(0.25, theta / 6) C += ph.circle(x=-1, r=1.0) C.show()
def polyline_gradient_test(self): g = ph.gradient.linear("r", "g") canvas = ph.Canvas() canvas += ph.polyline(gradient=g)
def polyFill_test(self): self.canvas += ph.polyline(is_filled=1)
def polyline_test(self): self.canvas += ph.polyline()