Пример #1
0
    def draw(self):
        surface = gizeh.Surface(width=self.width,
                                height=self.height,
                                bg_color=(1, 1, 1))

        if self.bg:
            fill = gizeh.ImagePattern(self.bg.data, self.bg.pos, filter='best')
            bg_circle = gizeh.circle(r=self.width * 5, fill=fill)
            bg_circle.draw(surface)

        if self.dragon:
            xy_pos = self.dragon.pos
            dragon_circle = gizeh.circle(r=10, xy=xy_pos, fill=(1, 0, 0))
            dragon_circle.draw(surface)

        for target in self.target_list:
            circle = gizeh.circle(r=target.size,
                                  xy=target.pos,
                                  fill=target.color)
            circle.draw(surface)

        surface.get_npimage()

        img_name = "temp/scr" + str(self.time) + ".png"
        surface.write_to_png(img_name)

        self.time += 1
Пример #2
0
def make_frame(t):
    progress = t / duration
    p = interval_progresses(progress, 2, 'hermite')
    p = interval_progresses(p[0], 2, 'none') + interval_progresses(
        p[1], 2, 'none')

    # circle
    surface = gz.Surface(2 * width, 2 * height)
    gz.circle(xy=(width, height),
              r=40 + 3 * (p[0] - p[1] - p[2] + p[3]),
              stroke_width=8 + 4 * (p[0] + p[1] - p[2] - p[3]),
              stroke=(1, 1, 1)).draw(surface)

    # FFT
    I = np.fft.fft2(surface.get_npimage()[:, :, 0] / 255)
    I = np.log(np.abs(I) + 0.00001).astype(np.float32)
    I = 1 - np.minimum(1, np.maximum(0, I))
    I = resize(I, (width, height))

    # border
    radius = (300 + 15 * (p[0] + p[1] - p[2] - p[3]))
    I *= get_circle_mask(width, height, radius)
    I = np.tile(I[:, :, np.newaxis], (1, 1, 4)) * 255
    surface = gz.Surface.from_image(I.astype(np.uint8))
    gz.circle(xy=(width / 2, height / 2),
              r=radius,
              stroke=(1, 1, 1),
              stroke_width=2).draw(surface)

    return surface.get_npimage()
Пример #3
0
    def draw(self, *data):
        chart_color = self.get_visual_token_oig_background(*data)
        soft_black_color = (0.137, 0.121, 0.125)

        gizeh.rectangle(xy=(self.width / 2, self.height / 2),
                        lx=self.width,
                        ly=self.height,
                        fill=chart_color).draw(self.surface)
        self.draw_triangle([self.spine_length] * 3, (1, 1, 1, 0.6), None, 0)

        spines = [value * self.spine_length / 100 for value in data]
        self.draw_triangle(spines, soft_black_color, soft_black_color)

        self.draw_chart_grid(4, chart_color)

        vertices = self.triangle_vertices(spines)
        for vertex in vertices:
            gizeh.polyline(
                points=[vertex, (self.center['x'], self.center['y'])],
                stroke_width=1,
                stroke=(1, 1, 1)).draw(self.surface)
        for vertex in vertices:
            gizeh.circle(r=4, xy=vertex, fill=(1, 1, 1)).draw(self.surface)
            gizeh.circle(r=3, xy=vertex,
                         fill=soft_black_color).draw(self.surface)

        return self.surface
Пример #4
0
def make_frame(t):
    progress = t / duration
    p = interval_progresses(progress, 2, 'hermite')
    center = (width / 2, height / 2)

    # star
    surface = gz.Surface(2 * width, 2 * height)
    n_lines = 24

    length = 30 + 5 * (p[0] - p[1])
    C = get_circle_coordinates(n_lines, length, center)
    rotate_around(C, -2 * np.pi * progress / n_lines, center)

    for i in range(n_lines):
        gz.polyline(points=[center, C[i, :]], stroke=(1, 1, 1),
                    stroke_width=2).draw(surface)

    # FFT
    I = np.fft.fft2(surface.get_npimage()[:, :, 0] / 255)
    I = np.abs(I).astype(np.float32)
    I -= 1
    I = 1 - np.minimum(1, np.maximum(0, I))
    I = resize(I, (width, height))

    # border
    radius = 300
    I *= get_circle_mask(width, height, radius)
    I = np.tile(I[:, :, np.newaxis], (1, 1, 4)) * 255
    surface = gz.Surface.from_image(I.astype(np.uint8))
    gz.circle(xy=(width / 2, height / 2),
              r=radius,
              stroke=(1, 1, 1),
              stroke_width=3).draw(surface)

    return surface.get_npimage()
Пример #5
0
def make_frame(t):
    progress = t / duration
    p = interval_progresses(progress, 4, 'none')
    ph = interval_progresses(progress, 4, 'hermite')

    I = (p[2] - p[0]) / 2 + (1 + (p[1] - p[3]) / 2) * cosine_sum

    corners = np.array(
        [[np.sin(2 * np.pi * progress),
          np.sin(2 * np.pi * (progress + 0.25))],
         [
             np.sin(2 * np.pi * (progress + 0.75)),
             np.sin(2 * np.pi * (progress + 0.5))
         ]]) * 0.4 + 0.6
    modulus = (corners[0, 0] * c0 + corners[0, 1] * c1 + corners[1, 0] * c2 +
               corners[1, 1] * c3)
    I = np.mod(I, modulus)

    I = resize(I, (width, height))
    I *= mask

    I -= np.min(I)
    I /= np.max(I)
    I = np.tile(I[:, :, np.newaxis], (1, 1, 4)) * 255

    surface = gz.Surface.from_image(I.astype(np.uint8))
    gz.circle(xy=(width / 2, height / 2),
              r=outer_radius,
              stroke=(1, 1, 1),
              stroke_width=2).draw(surface)

    return surface.get_npimage()
Пример #6
0
    def draw(self):
        surface = gizeh.Surface(width=self.width, height=self.height,
                                bg_color=(1,1,1))

        if self.bg:
            fill = gizeh.ImagePattern(self.bg.data, self.bg.pos, filter='best')
            bg_circle = gizeh.circle(r=self.width*5, fill=fill)
            bg_circle.draw(surface)

        if self.dragon:
            xy_pos = self.dragon.pos
            dragon_circle = gizeh.circle(r=10, xy=xy_pos, fill = (1,0,0))
            dragon_circle.draw(surface)

        for target in self.target_list:
            circle = gizeh.circle(r=target.size, xy=target.pos,
                                  fill=target.color)
            circle.draw(surface)

        surface.get_npimage()

        img_name = "temp/scr" + str(self.time) + ".png"
        surface.write_to_png(img_name)

        self.time += 1
Пример #7
0
    def draw(self, surface: gizeh.Surface) -> None:
        """Draw the tone clock according to its style settings."""
        if self._style.visible_circle:
            gizeh.circle(r=self._style.radius,
                         xy=self._style.center,
                         stroke=BLACK,
                         stroke_width=1).draw(surface)
        if self._style.hours:
            for hour in range(self._style.hours):
                pitch = self._style.octave**(hour / self._style.hours)
                self._style.line(pitch).draw(surface)
        for pitch in self._filled_dots:
            self._style.dot(pitch, filled=True).draw(surface)
        for pitch in self._empty_dots:
            self._style.dot(pitch, filled=False).draw(surface)
        for angle in self._angles:
            self._style.angle(angle).draw(surface)

        labels = {}
        for pitch, text in sorted(self._labels.items()):
            label = self._style.label(pitch, text)
            if label.quantized_pitch in labels:
                labels[label.quantized_pitch] += label
            else:
                labels[label.quantized_pitch] = label
        for label in labels.values():
            label.draw(surface)

        for mark in self._additional_marks:
            mark.draw(surface)
Пример #8
0
def make_frame(t):
    
    W,H = np.array([box,box]) # width, height, in pixels
    radius = (box/256.0)*10
    surface = gizeh.Surface(W,H)

    i = int((t/duration)*pt_N)
    dx = np.array([W/2.,H/2.])
    pts = R[i]

    cx = np.sin(t/duration*(np.pi))
    c = (cx, 0.5, 0, alpha)
    
    for x,y in pts:
        xy = dx + [x,y]*dx/1.5

        scale = box/128.

        if use_circles:
            circle = gizeh.circle(radius+(2*scale), xy=xy, fill=[1,1,1,alpha])
            circle.draw(surface)

            circle = gizeh.circle(radius+(1*scale), xy=xy, fill=[0,0,0,1])
            circle.draw(surface)
        
        circle = gizeh.circle(radius, xy=xy, fill=c)
        circle.draw(surface)

    img = surface.get_npimage()
    return img 
Пример #9
0
def prepare():
    surface = gz.Surface(width, height)
    gz.rectangle(lx=width,
                 ly=height,
                 xy=(width / 2, height / 2),
                 fill=(0, 0, 0)).draw(surface)
    gz.circle(xy=(width / 2, height / 2), r=width / 2 - 10,
              fill=(1, 1, 1)).draw(surface)
    gz.circle(xy=(width / 2, height / 2), r=width / 2 - 40,
              fill=(0, 0, 0)).draw(surface)
    surface.write_to_png('spiral_ring.png')

    points = stipple_image_points('spiral_ring.png',
                                  n_points=5000,
                                  scale_factor=2,
                                  max_iterations=50)
    np.save('spiral_ring.npy', points)
    write_tsp('spiral_ring.tsp', points)

    run_linkern('spiral_ring.tsp', 'spiral_ring.cyc',
                '../../tools/linkern.exe')
    postprocess_cyc('spiral_ring.npy',
                    'spiral_ring.cyc',
                    'spiral_ring_processed.npy', (256, 256),
                    segment_length=5,
                    degree=3,
                    normalize_points=False)
Пример #10
0
def prepare_data():
    surface = gz.Surface(1000, 1000)
    offset = np.array((500, 500))
    gz.square(l=1000, xy=offset, fill=(0, 0, 0)).draw(surface)

    radius, corners, stroke_width = get_extinction_symbol_params(400)
    gz.circle(r=radius, xy=offset, stroke=(1, 1, 1),
              stroke_width=stroke_width).draw(surface)
    gz.polyline(points=corners + offset,
                close_path=True,
                fill=None,
                stroke=(1, 1, 1),
                stroke_width=stroke_width).draw(surface)
    surface.write_to_png('extinction_symbol.png')

    print('STIPPLING EXTINCTION SYMBOL')
    points = stipple_image_points('extinction_symbol.png',
                                  n_points=2500,
                                  scale_factor=1,
                                  max_iterations=50)
    np.save('extinction_symbol', points)

    points = np.load('extinction_symbol.npy')
    write_tsp('extinction_symbol.tsp', points)
    run_linkern('extinction_symbol.tsp', 'extinction_symbol.cyc',
                '../../tools/linkern.exe')
    postprocess_cyc('extinction_symbol.npy',
                    'extinction_symbol.cyc',
                    'extinction_symbol_processed.npy', (width, height),
                    radius=110 / 128,
                    segment_length=5)
Пример #11
0
def make_frame(t):

    dt = 1.0 * DURATION / 2 / NDISKS_PER_CYCLE  # delay between disks
    N = int(NDISKS_PER_CYCLE / SPEED)  # total number of disks
    t0 = 1.0 / SPEED  # indicates at which avancement to start

    surface = gz.Surface(W, H)
    for i in range(1, N):
        a = (np.pi / NDISKS_PER_CYCLE) * (N - i - 1)
        r = np.maximum(0, .05 * (t + t0 - dt * (N - i - 1)))
        center = W * (0.5 + gz.polar2cart(r, a))
        color = 3 * ((1.0 * i / NDISKS_PER_CYCLE) % 1.0, )
        circle = gz.circle(r=0.3 * W,
                           xy=center,
                           fill=color,
                           stroke_width=0.01 * W)
        circle.draw(surface)
    contour1 = gz.circle(r=.65 * W, xy=[W / 2, W / 2], stroke_width=.5 * W)
    contour2 = gz.circle(r=.42 * W,
                         xy=[W / 2, W / 2],
                         stroke_width=.02 * W,
                         stroke=(1, 1, 1))
    contour1.draw(surface)
    contour2.draw(surface)
    return surface.get_npimage()
def make_frame(t):
    dt = 1.0 * DURATION / 2 / NDISKS_PER_CYCLE
    N = int(NDISKS_PER_CYCLE / SPEED)
    t0 = 1.0 / SPEED

    surface = gz.Surface(W, H)
    for i in range(1, N):
        a = (np.pi / NDISKS_PER_CYCLE) * (N - i - 1)
        r = np.maximum(0, 0.05 * (t + t0 - dt * (N - i - 1)))
        center = W * (0.5 + gz.polar2cart(r, a))
        color = 1 * ((1.0 * i / NDISKS_PER_CYCLE) % 1.0, 1, 0)
        circle = gz.circle(r=0.3 * W,
                           xy=center,
                           fill=color,
                           stroke_width=0.01 * W)
        circle.draw(surface)

    contour1 = gz.circle(r=0.65 * W, xy=[W / 2, W / 2], stroke_width=0.5 * W)
    contour2 = gz.circle(r=0.42 * W,
                         xy=[W / 2, W / 2],
                         stroke_width=0.02 * W,
                         stroke=(1, 1, 1))
    contour1.draw(surface)
    contour2.draw(surface)
    return surface.get_npimage()
Пример #13
0
def draw_pointer_circles(radius, center, angle):
	x1 = center[0]
	y1 = center[1]
	x2 = center[0] + radius*np.cos(angle)
	y2 = center[1] + radius*np.sin(angle)
	c1 = gz.circle(radius/10, fill=(0,0,0), xy=[x1, y1])
	c2 = gz.circle(radius/10, fill=(0,0,0), xy=[x2, y2])
	# c1.draw(surface)
	c2.draw(surface)
Пример #14
0
 def draw(self, surface: gizeh.Surface) -> None:
     """Draw the pitch's representative dot."""
     scale = self._style.marking_scale
     if self._filled:
         gizeh.circle(r=5 * scale, xy=self.get_mark_point(),
                      fill=BLACK).draw(surface)
     else:
         gizeh.circle(r=7 * scale,
                      xy=self.get_mark_point(),
                      stroke=BLACK,
                      stroke_width=scale).draw(surface)
Пример #15
0
 def render(self, time):
     """
     create gizeh object
     :param time: current time
     :return: gizeh object
     """
     alph = get_alpha(self, time)
     center = gizeh.circle(9, xy=self.position, fill=(1, 1, 1, alph))
     spinn = gizeh.circle(self.approach_circle(time), xy=self.position,
                          stroke_width=17, stroke=(*self.color, alph))
     return [center, spinn]
Пример #16
0
def make_yinyang(size=200, r=80, filename="yin_yang.png"):
    surface = gz.Surface(size, size, bg_color=(0, .3, .6))
    yin_yang = gz.Group([
        gz.arc(r, pi / 2, 3 * pi / 2, fill=(1, 1, 1)),
        gz.arc(r, -pi / 2, pi / 2, fill=(0, 0, 0)),
        gz.arc(r / 2, -pi / 2, pi / 2, fill=(1, 1, 1), xy=[0, -r / 2]),
        gz.arc(r / 2, pi / 2, 3 * pi / 2, fill=(0, 0, 0), xy=[0, r / 2]),
        gz.circle(r / 8, xy=[0, +r / 2], fill=(1, 1, 1)),
        gz.circle(r / 8, xy=[0, -r / 2], fill=(0, 0, 0))
    ])
    yin_yang.translate([size / 2, size / 2]).draw(surface)
    surface.write_to_png(filename)
    return 0
def make_frame(t):
    
    frame = int(math.floor(t*60))
    print(frame)

    #Essentially pauses the action if there are no more frames and but more clip duration
    if frame >= len(events["A"]):
        frame = len(events["A"])-1

    #White background
    surface = gz.Surface(W,H, bg_color=(1,1,1))            

    #Pucks
    for label, center in zip(labels, centers):

        xy = [center[0], center[1]]

        if events[label][frame]==1:
            #Event
            ball = gz.circle(r=RAD, fill=(1,1,0), stroke=(0,0,0), stroke_width=1).translate(xy)
            ball.draw(surface)

            # text = gz.text(label, fontfamily="Helvetica", 
            # fontsize=25, fontweight='bold', fill=(0.2,0.2,0.2), xy=xy) #, angle=Pi/12
            # text.draw(surface)
        elif events[label][frame]==2:
            #Action/intervention
            ball = gz.circle(r=RAD, fill=(1,1,0), stroke=(0,0,0), stroke_width=6).translate(xy)
            ball.draw(surface)

            text = gz.text('+', fontfamily="Helvetica",  fontsize=35, fontweight='bold', fill=(0,0,0), xy=xy) #, angle=Pi/12
            text.draw(surface)

            # timeline = gz.rectangle(251,201, fill=gz.ImagePattern(image), xy=xy)
            # timeline.draw(surface)
        elif events[label][frame]==0:
            #Inactive
            ball = gz.circle(r=RAD, fill=(.7,.7,.7), stroke=(0,0,0), stroke_width=1).translate(xy)
            ball.draw(surface)
                    #Letters
            # text = gz.text(label, fontfamily="Helvetica", 
            # fontsize=25, fontweight='bold', fill=(0.2,0.2,0.2), xy=xy) #, angle=Pi/12
            # text.draw(surface)


    #Mouse cursor
    # cursor_xy = np.array([this_events['mouse']['x'][frame]*RATIO, this_events['mouse']['y'][frame]*RATIO])
    # cursor = gz.text('+', fontfamily="Helvetica",  fontsize=25, fill=(0,0,0), xy=cursor_xy) #, angle=Pi/12
    # cursor.draw(surface)
    
    return surface.get_npimage()  
def make_frame(t):
    surface = gz.Surface(W,H, bg_color=(1,1,1))
    x = (-W/3)+(5*W/3)*(t/D)
    y = ground - HJ*4*(x % DJ)*(DJ-(x % DJ))/DJ**2
    coef = (HJ-y)/HJ
    shadow_gradient = gz.ColorGradient(type="radial",
                stops_colors = [(0,(0,0,0,.2-coef/5)),(1,(0,0,0,0))],
                xy1=[0,0], xy2=[0,0], xy3 = [0,1.4])
    shadow = (gz.circle(r=(1-coef/4), fill=shadow_gradient)
               .scale(r,r/2).translate((x,ground+r/2)))
    shadow.draw(surface)
    ball = gz.circle(r=1, fill=gradient).scale(r).translate((x,y))
    ball.draw(surface)
    return surface.get_npimage()
    def draw(self, ctx, anchor_at, width, height, parent_shape):
        t = self.progress*10

        W,H = 256, 256
        DURATION = 2.0
        NDISKS_PER_CYCLE = 8
        SPEED = .05
        W,H = int(width), int(height)

        dt = 1.0*DURATION/2/NDISKS_PER_CYCLE # delay between disks
        N = int(NDISKS_PER_CYCLE/SPEED) # total number of disks
        t0 = 1.0/SPEED # indicates at which avancement to start

        surface = gz.Surface(W,H)
        for i in range(1,N):
            a = (math.pi/NDISKS_PER_CYCLE)*(N-i-1)
            r = max(0, .05*(t+t0-dt*(N-i-1)))
            center = W*(0.5+ gz.polar2cart(r,a))
            color = 3*((1.0*i/NDISKS_PER_CYCLE) % 1.0,)
            circle = gz.circle(r=0.3*W, xy = center,fill = color,
                                  stroke_width=0.01*W)
            circle.draw(surface)
        contour1 = gz.circle(r=.65*W,xy=[W/2,W/2], stroke_width=.5*W)
        contour2 = gz.circle(r=.42*W,xy=[W/2,W/2], stroke_width=.02*W,
                                stroke=(1,1,1))
        #contour1.draw(surface)
        #contour2.draw(surface)

        cs = surface._cairo_surface
        ctx.set_source_surface(
            cairo.ImageSurface.create_for_data(
                cs.get_data(), cs.get_format(), cs.get_width(), cs.get_height()))
        ctx.paint()

        step_angle = math.pi*2./self.circle_count
        circle_radius = self.circle_radius
        circle_radius = (.5+self.progress)*circle_radius
        spread_radius = min(width, height)*.5-circle_radius-self.stroke_size
        for i in range(self.circle_count):
            angle = i*step_angle
            x = spread_radius*math.cos(angle)
            y = spread_radius*math.sin(angle)
            ctx.save()
            ctx.translate(anchor_at.x, anchor_at.y)
            ctx.new_path()
            ctx.translate(x, y)
            ctx.arc(0, 0, circle_radius, 0, 2*math.pi)
            ctx.restore()
            draw_stroke(ctx, self.stroke_size, self.stroke_color)
Пример #20
0
    def fl(im):
        """ transforms the image by adding a zoom """

        surface = gz.Surface.from_image(im)
        fill = gz.ImagePattern(im, pixel_zero=target_center,
                               filter='best')
        line = gz.polyline([target_center, zoom_center],
                           stroke_width=3)
        circle_target= gz.circle(zoom_radius, xy=target_center,
                                 fill=fill, stroke_width=2)
        circle_zoom = gz.circle(zoom_radius, xy=zoom_center, fill=fill,
                       stroke_width=2).scale(zoomx, center=zoom_center)
        for e in line, circle_zoom, circle_target:
            e.draw(surface)
        return surface.get_npimage()
Пример #21
0
def draw_pointer_circles(radius, center, angle):
	x2 = center[0] + radius*np.cos(angle)
	y2 = center[1] + radius*np.sin(angle)
	c2 = gz.circle(radius/10, fill=fill, xy=[x2, y2])
	# c1.draw(surface)
	# c2.draw(surface)
	grp2.append(c2)
Пример #22
0
 def drawpoint(self, p, style = littlepoint):
     for s in style:
         center = [p[0] + s.offset[0], p[1] + s.offset[0]]
         point = gizeh.circle(r = s.radius,
                              xy = center,
                             fill = s.fill)
         point.draw(self.surface)
def half(t, side="left"):
    points = gz.geometry.polar_polygon(NFACES, R, NSQUARES)
    #ipoint = 0 if side=="left" else NSQUARES/2
    #points = (points[ipoint:]+points[:ipoint])[::-1]

    #for point in points:
    #  print point

    surface = gz.Surface(W,H)

    centerPoints = []
    for (r, th, d) in points:
        center = W * (0.5 + gz.polar2cart(r, th))
        angle = -(6 * np.pi * d + t * np.pi / DURATION)
        #color= colorsys.hls_to_rgb((2*d+t/DURATION)%1,.5,.5)
        centerPoints.append(center)
        color= (0.9, 0.9, 0.9)
        square = gz.circle(r=4.0, xy= center, fill=color)
        #square = gz.square(l=0.17*W, xy= center, angle=angle,
        #           fill=color, stroke_width= 0.005*W, stroke=(1,1,1))

        square.draw(surface)

    line = gz.polyline(points=centerPoints, stroke_width=1, stroke=(1, 0, 0))
    line.draw(surface)

    im = surface.get_npimage()
    return (im[:,:W/2] if (side=="left") else im[:,W/2:])
Пример #24
0
def make_frame(t):
    surface = gz.Surface(W, H, bg_color=(1, 1, 1))

    gradient = gz.ColorGradient(type="radial",
                                stops_colors=[(0, (1, 0, 0, alpha)),
                                              (1, (0.9, 0, 0, alpha))],
                                xy1=[0.3, -0.3],
                                xy2=[0, 0],
                                xy3=[0, 1.4])
    for i in range(numBalls):
        if (t < duration / 2):
            newRadius = pytweening.easeInOutBounce(2 * t / duration) * radius
            newCircleRadius = pytweening.easeInOutBounce(
                2 * t / duration) * circleRadius
        else:
            newRadius = pytweening.easeInOutBounce(1 - (t / duration)) * radius
            newCircleRadius = pytweening.easeInOutBounce(
                1 - (t / duration)) * circleRadius

        angle = (2 * np.pi / numBalls) * i
        #center = (W/2) + gz.polar2cart(newCircleRadius, angle)
        center = (W / 2) + gz.polar2cart(circleRadius, angle)

        #ball = gz.circle(r=newRadius, fill=gradient).translate((x, y))
        ball = gz.circle(r=newRadius, fill=gradient).translate(center)
        ball.draw(surface)

    return surface.get_npimage()
Пример #25
0
def make_frame(time):
	global w, h, max_w, max_h, UP
	# set the surface of size 640 * 480 
	surface = gz.Surface(max_w, max_h)

	# UP is checking if the circle is going up
	if UP == True:
		# circle is going up
		w = w + 6.4 	# increase the width  
		h = h - 4.8 	# decrease the height
		# check if the circle go over than the upper right boarder
		if w + RADIUS > max_w or h - RADIUS < 0:
			UP = False	# change UP value to False (going down)
	else: 
		# circle is going down		
		w = w - 6.4 	# decrease the width
		h = h + 4.8 	# increase the height
		# check if the circle go under the bottom left boundary
		if w - RADIUS < 0 or h + RADIUS > max_h:
			UP = True	# change UP value to True (going up)

	# 
	circle = gz.circle(r=RADIUS, xy=(w, h), fill=(1,0,0))
	# draw a circle in a surface
	circle.draw(surface)
	
	return surface.get_npimage()
def half(t, side="left"):
    points = gz.geometry.polar_polygon(NFACES, R, NSQUARES)
    #ipoint = 0 if side=="left" else NSQUARES/2
    #points = (points[ipoint:]+points[:ipoint])[::-1]

    #for point in points:
    #  print point

    surface = gz.Surface(W, H)

    centerPoints = []
    for (r, th, d) in points:
        center = W * (0.5 + gz.polar2cart(r, th))
        angle = -(6 * np.pi * d + t * np.pi / DURATION)
        #color= colorsys.hls_to_rgb((2*d+t/DURATION)%1,.5,.5)
        centerPoints.append(center)
        color = (0.9, 0.9, 0.9)
        square = gz.circle(r=4.0, xy=center, fill=color)
        #square = gz.square(l=0.17*W, xy= center, angle=angle,
        #           fill=color, stroke_width= 0.005*W, stroke=(1,1,1))

        square.draw(surface)

    line = gz.polyline(points=centerPoints, stroke_width=1, stroke=(1, 0, 0))
    line.draw(surface)

    im = surface.get_npimage()
    return (im[:, :W / 2] if (side == "left") else im[:, W / 2:])
Пример #27
0
def add_shape(shape, state, itr):
    """
    Draws the required shape
    """
    sides = 0
    A = 2*R/2.56 # Maximum line weight
    a = 3  # Shaping exponent
    L = LENGTH # Period
    weight = A*(abs(itr%L - L/2)**a)/(L/2)**a # Periodic
    # if itr%LENGTH < LENGTH/2:
        # weight = ((OLD_RADII[itr%LENGTH]**(2))/R ) # Based on radii
    # else: weight = ((OLD_RADII[(LENGTH-itr)%LENGTH]**(2))/R)
    # weight = (20*np.cos(2*np.pi/LENGTH*itr) + 20) # Really periodic
    # print itr, weight
    # weight = 3
    weight *= state.radius/R #Normalize vs zoom
    fill = colorsys.hls_to_rgb(float(itr)/(LENGTH/2)%1,.5,1)
    if (shape == CIRCLE):
        SHAPES.append(gz.circle(state.radius, stroke=(1,1,1), stroke_width=weight, fill=fill, xy=state.center))
        return
    elif (shape == TRIANGLE):
        sides = 3
    elif (shape == SQUARE):
        sides = 4
    SHAPES.append(gz.regular_polygon(state.radius, sides, stroke=(1,1,1), stroke_width=weight, fill=fill, xy=state.center, angle=state.angle))
Пример #28
0
 def make_frame(t):
     # See example: https://zulko.github.io/moviepy/getting_started/videoclips.html#videoclip
     surface = gizeh.Surface(128, 128)
     radius = 100 * (1 + (t * (2 - t))**2) / 6
     circle = gizeh.circle(radius, xy=(64, 64), fill=(1, 0, 0))
     circle.draw(surface)
     return surface.get_npimage()
Пример #29
0
        def make_frame(t):
            surface = gizeh.Surface(W,H, bg_color=(1,1,1))
            radius = 60

            circle = gizeh.circle(radius, xy = (W/2, H/2+(datanow[x_animation_range.index(t)])*40), fill=(.5,.5,.5))
            circle.draw(surface)
            return surface.get_npimage()
Пример #30
0
def test_yin_yang():
    L = 200  # <- dimensions of the final picture
    surface = gz.Surface(L, L, bg_color=(0, .3, .6))  # blue background
    r = 70  # radius of the whole yin yang

    yin_yang = gz.Group([
        gz.arc(r, np.pi / 2, 3 * np.pi / 2, fill=(1, 1, 1)),  # white half
        gz.arc(r, -np.pi / 2, np.pi / 2, fill=(0, 0, 0)),  # black half
        gz.arc(r / 2, -np.pi / 2, np.pi / 2, fill=(1, 1, 1), xy=[0, -r / 2]),
        gz.arc(r / 2, np.pi / 2, 3 * np.pi / 2, fill=(0, 0, 0), xy=[0, r / 2]),
        gz.circle(r / 8, xy=[0, +r / 2], fill=(1, 1, 1)),  # white dot
        gz.circle(r / 8, xy=[0, -r / 2], fill=(0, 0, 0))
    ])  # black dot

    yin_yang.translate([L / 2, L / 2]).draw(surface)

    assert is_like_sample(surface, 'yin_yang')
Пример #31
0
 def drawcircle(self, p, radius, style = blackline):
     for s in style:
         circle = gizeh.circle(r = radius,
                               xy = list(p),
                               fill = s.fill,
                               stroke_width = s.stroke_width,
                               stroke=s.stroke)
         circle.draw(self.surface)
Пример #32
0
def make_frame(t):
    surface = gizeh.Surface(W, H)
    radius = W * (10 + (t * (duration - t))**2) / 200
    circle = gizeh.circle(radius,
                          xy=(W / 2, H / 2),
                          fill=((np.cos(3 * t) + 1.0) / 2.0, 0.0, 1.0))
    circle.draw(surface)
    return surface.get_npimage()
Пример #33
0
def render_text(t):
    surface = gz.Surface(width=640, height=480)
    text = gz.circle(
        r=4,
        fill=BLUE,
        xy=(point1X[int(len(point1X) * t / original_clip.duration)],
            point1Y[int(len(point1Y) * t / original_clip.duration)]))
    text.draw(surface)

    text = gz.circle(
        r=4,
        fill=LOL,
        xy=(point2X[int(len(point2X) * t / original_clip.duration)],
            point2Y[int(len(point2Y) * t / original_clip.duration)]))
    text.draw(surface)

    return surface.get_npimage(transparent=True)
Пример #34
0
 def draw(self, ind):
     circle = gizeh.circle(
         r=self.radius[ind],
         xy=self.center,
         fill=self.color[ind],
         **self.kwargs
     )
     circle.draw(self.surface)
Пример #35
0
def prepare_data():
    surface = gz.Surface(width, height)
    offset = np.array((width / 2, height / 2))
    gz.square(l=width, xy=offset, fill=(0, 0, 0)).draw(surface)

    radius, corners, stroke_width = get_extinction_symbol_params(0.35 * width)
    gz.circle(r=radius, xy=offset, stroke=(1, 1, 1),
              stroke_width=stroke_width).draw(surface)
    gz.polyline(points=corners + offset,
                close_path=True,
                fill=None,
                stroke=(1, 1, 1),
                stroke_width=stroke_width).draw(surface)

    img = surface.get_npimage()[:, :, 0]
    img = gaussian_filter(img, sigma=width / 50, truncate=10)
    imsave(f'extinction_symbol_soft_{width}.png', img)
Пример #36
0
def make_frame(t):
    surface = gz.Surface(width, height)
    progress = t / duration

    points = np.mgrid[:width:16, :height:12].astype(float)
    points[0, :, ::2] = (points[0, :, ::2] + 8 + 160 * progress) % width
    points[0, :, 1::2] = (points[0, :, 1::2] - 160 * progress) % width
    points = points.reshape(2, -1).T
    rotate_around(points, 2 * np.pi * progress, (width / 2, height / 2))

    for x, y in points:
        d = np.sqrt((x - width / 2)**2 + (y - height / 2)**2)
        if d < width / 2 - 30:
            r = r_min + (r_max - r_min) * xr[int(x), int(y)] / 255
            gz.circle(xy=(x, y), r=r, fill=(1, 1, 1)).draw(surface)

    return surface.get_npimage()
def make_ball(t, alpha):
    gradient = gz.ColorGradient(type="radial",
                    stops_colors = [(0,(1,0,0, alpha)),(1,(0.1,0,0,alpha))],
                    xy1=[0.3,-0.3], xy2=[0,0], xy3 = [0,1.4])
    x = (-W/3)+(5*W/3)*(t/D)
    y = ground - HJ*4*(x % DJ)*(DJ-(x % DJ))/DJ**2
    coef = (HJ-y)/HJ
    ball = gz.circle(r=1, fill=gradient).scale(r).translate((x,y))
    return ball
Пример #38
0
def test_yin_yang():
    L = 200  # <- dimensions of the final picture
    surface = gz.Surface(L, L, bg_color=(0, .3, .6))  # blue background
    r = 70  # radius of the whole yin yang

    yin_yang = gz.Group([
        gz.arc(r, np.pi / 2, 3 * np.pi / 2, fill=(1, 1, 1)),  # white half
        gz.arc(r, -np.pi / 2, np.pi / 2, fill=(0, 0, 0)),  # black half

        gz.arc(r / 2, -np.pi / 2, np.pi / 2, fill=(1, 1, 1), xy=[0, -r / 2]),
        gz.arc(r / 2, np.pi / 2, 3 * np.pi / 2, fill=(0, 0, 0), xy=[0, r / 2]),

        gz.circle(r / 8, xy=[0,  +r / 2], fill=(1, 1, 1)),  # white dot
        gz.circle(r / 8, xy=[0,  -r / 2], fill=(0, 0, 0))])  # black dot

    yin_yang.translate([L / 2, L / 2]).draw(surface)

    assert is_like_sample(surface, 'yin_yang')
Пример #39
0
def make_frame(t):
    surface = gz.Surface(W,H)
    for angle in np.linspace(0,2*np.pi,ncircles+1)[:-1]:
        center = np.array([W/2,H/2]) + gz.polar2cart(.2*W,angle)
        for i in [0,1]: # two circles belongin to two groups
            circle = gz.circle(W*.45*(i+t/D),xy=center,
                                  fill=(1,1,1,1.0/255))
            circle.draw(surface)
    return 255*((surface.get_npimage()+1) % 2)
Пример #40
0
def circles(sw, opacity):
    b = ring_rad * 2
    while b < (radius):
        circ = g.circle(r=b,
                        xy=[w / 2, h / 2],
                        stroke=(1, 1, 1),
                        stroke_width=1.5)
        circ.draw(surface)
        b = b + ring_rad
Пример #41
0
def make_station_icon(surface, settings, n, constants, text=None):
    x_pos, y_pos = constants.icon_xy
    if constants.theme.lower() == 'tokyu':
        fill = constants.line_color
        stroke = [1, 1, 1]
        stroke_width = 5
        text_fill = [1, 1, 1]
        letter_mod = -10
    else:
        fill = [1, 1, 1]
        stroke = constants.line_color
        stroke_width = 15
        text_fill = [0, 0, 0]
        letter_mod = 0

    if constants.icon_shape.lower() == 'square':
        mod = 40
        gz.square(constants.icon_size,
                  xy=[x_pos, y_pos],
                  stroke=stroke,
                  stroke_width=stroke_width,
                  fill=fill).draw(surface)
    else:
        mod = 45
        gz.circle(constants.icon_size,
                  xy=[x_pos, y_pos],
                  stroke=constants.line_color,
                  stroke_width=30,
                  fill=[1, 1, 1]).draw(surface)

    if text:
        line, num = text.split('-')
    else:
        line, num = settings[n].station_number.split('-')
    gz.text(line,
            constants.icon_text_font,
            constants.icon_line_fontsize + letter_mod,
            xy=[x_pos, y_pos - mod],
            fill=text_fill).draw(surface)
    gz.text(num,
            constants.icon_text_font,
            constants.icon_station_fontsize - letter_mod,
            xy=[x_pos, y_pos + 30],
            fill=text_fill).draw(surface)
def make_shadow(t):
    x = (-W/3)+(5*W/3)*(t/D)
    y = ground - HJ*4*(x % DJ)*(DJ-(x % DJ))/DJ**2
    coef = (HJ-y)/HJ
    shadow_gradient = gz.ColorGradient(type="radial",
                stops_colors = [(0,(0,0,0,.2-coef/5)),(1,(0,0,0,0))],
                xy1=[0,0], xy2=[0,0], xy3 = [0,1.4])
    shadow = (gz.circle(r=(1-coef/4), fill=shadow_gradient)
               .scale(r,r/2).translate((x,ground+r/2)))
    return shadow
Пример #43
0
def make_frame(t):
    surface = gz.Surface(R, R)
    background = gz.square(l=R, xy= [R/2,R/2], fill=(1,1,1))
    background.draw(surface)
    cir = gz.circle(R/2, stroke=(1,1,1), fill=(0, 1, 0, 0.5), stroke_width=1, xy=[R/2, R/2])
    tri = gz.regular_polygon(R/2, 3, stroke=(1,1,1), fill=(1, 0, 0, 0.5), stroke_width=1, xy=[R/2, R/2], angle=2*t/DURATION*np.pi)
    sqr = gz.square(R/2, stroke=(1,1,1), fill=(0, 0, 1, 0.5), stroke_width=1, xy=[R/2, R/2], angle=-2*t/DURATION*np.pi)
    grp = gz.Group([cir, tri, sqr])
    grp.draw(surface)
    im = surface.get_npimage()
    return im
Пример #44
0
def make_frame(t):
	surface = gizeh.Surface(W,H)

	for i in range(ncircles):
		angle = 2*np.pi*(1.0*i/ncircles+t/duration)
		center = W*(0.5+gizeh.polar2cart(0.1,angle))
		circle = gizeh.circle(r=W*(1.0-1.0*i/ncircles),
					xy=center,fill=(i%2,i%2,i%2))
		circle.draw(surface)

	return surface.get_npimage()
def make_frame(t):
    surface = gz.Surface(W,H)
    for r,color, center in zip(radii, colors, centers):
        angle = 2*np.pi*(t/D*np.sign(color[0]-.5)+color[1])
        xy = center+gz.polar2cart(W/5,angle) # center of the ball
        gradient = gz.ColorGradient(type="radial",
                     stops_colors = [(0,color),(1,color/10)],
                     xy1=[0.3,-0.3], xy2=[0,0], xy3 = [0,1.4])
        ball = gz.circle(r=1, fill=gradient).scale(r).translate(xy)
        ball.draw(surface)
    return surface.get_npimage()
Пример #46
0
def generate_segments(strokes):
    points = [s for stroke in strokes for s in stroke]
    xs = map(lambda p: p['x'], points)
    ys = map(lambda p: p['y'], points)
    width = max(xs)
    height = max(ys)

    surface = gizeh.Surface(width=width, height=height)
    for i, stroke in enumerate(strokes):
        cuts = list(generate_cuts(stroke))
        #if len(cuts) > 12: cuts = cuts[::int(ceil(len(cuts) / 12.0))]
        image = surface.get_npimage()
        histogram = np.sum(np.sum(image/255, 0), 1)
        lines = np.where(histogram == np.min(histogram))

        print len(cuts), 2**len(cuts)
        #x = list(powerset(cuts))
        surface = draw_points(surface, stroke)
        for cut in cuts:
            gizeh.circle(r=9,xy=(cut['x'], cut['y']), fill=(1,0,1)).draw(surface)
    surface.write_to_png('a.png')
def make_frame(t):

    dt = 1.0*DURATION/2/NDISKS_PER_CYCLE # delay between disks
    N = int(NDISKS_PER_CYCLE/SPEED) # total number of disks
    t0 = 1.0/SPEED # indicates at which avancement to start

    surface = gz.Surface(W,H)
    for i in range(1,N):
        a = (np.pi/NDISKS_PER_CYCLE)*(N-i-1)
        r = np.maximum(0, .05*(t+t0-dt*(N-i-1)))
        center = W*(0.5+ gz.polar2cart(r,a))
        color = 3*((1.0*i/NDISKS_PER_CYCLE) % 1.0,)
        circle = gz.circle(r=0.3*W, xy = center,fill = color,
                              stroke_width=0.01*W)
        circle.draw(surface)
    contour1 = gz.circle(r=.65*W,xy=[W/2,W/2], stroke_width=.5*W)
    contour2 = gz.circle(r=.42*W,xy=[W/2,W/2], stroke_width=.02*W,
                            stroke=(1,1,1))
    contour1.draw(surface)
    contour2.draw(surface)
    return surface.get_npimage()
def make_frame(t):

  alpha = 0.8
  surface = gz.Surface(W,H, bg_color=(1,1,1))

  gradient = gz.ColorGradient(type="radial",
                  stops_colors = [(0,(1,0,0, alpha)),(1,(0.1,0,0,alpha))],
                  xy1=[0.3,-0.3], xy2=[0,0], xy3 = [0,1.4])
  for i in range(numStars):
    star = stars[i]
    star.x += star.vecX;
    star.y += star.vecY;
    ball = gz.circle(r=star.radius, fill=gradient).translate((star.x, star.y))
    ball.draw(surface)
  return surface.get_npimage()
Пример #49
0
def test_transparent_colors():
    L = 200  # <- dimensions of the final picture
    surface = gz.Surface(L, L, bg_color=(1, 1, 1))  # <- white background
    radius = 50
    centers = [gz.polar2cart(40, angle)
               for angle in [0, 2 * np.pi / 3, 4 * np.pi / 3]]
    colors = [(1, 0, 0, .4),  # <- Semi-tranparent red (R,G,B, transparency)
              (0, 1, 0, .4),  # <- Semi-tranparent green
              (0, 0, 1, .4)]  # <- Semi-tranparent blue
    circles = gz.Group([gz.circle(radius, xy=center, fill=color,
                                  stroke_width=3, stroke=(0, 0, 0))
                        for center, color in zip(centers, colors)])
    circles.translate([L / 2, L / 2]).draw(surface)

    assert is_like_sample(surface, 'transparent_colors')
Пример #50
0
def add_shape(shape, state, itr):
	"""
	Draws the required shape
	"""
	sides = 0
	weight = state.radius/R * 2.5 + 0.5
	# if itr % 2 == 0:
	# 	fill = (0,0,0)
	# else: fill = (1,1,1)
	if (shape == CIRCLE):
		SHAPES.append(gz.circle(state.radius, stroke=(0,0,0), stroke_width=0, xy=state.center, fill = fill))
		return
	elif (shape == TRIANGLE):
		sides = 3
	elif (shape == SQUARE):
		sides = 4
	SHAPES.append(gz.regular_polygon(state.radius, sides, stroke=(0,0,0), stroke_width=0, xy=state.center, fill = fill, angle=state.angle))
Пример #51
0
def make_frame(t):
    global b_coords, r_coords
    # Create template to work on
    surface = gizeh.Surface(W, H)

    # Generate new coordinates
    b_coords = rand_movement(b_coords)
    r_coords = rand_movement(r_coords)

    # Specify and draw circle and square
    b_circle = gizeh.circle(25, xy=b_coords, fill=(0, 0, 1))
    r_square = gizeh.square(l=50, xy=r_coords, fill=(1, 0, 0), angle=PI*t)

    b_circle.draw(surface)
    r_square.draw(surface)
    # Return a numpy array
    return surface.get_npimage()
def make_frame(t):
    surface = gz.Surface(W,H)

    centerPoints = []
    r = W / 2 * 0.8
    for i in range(NFACES*2):
        th = float(i) * ((2 * np.pi) / float(NFACES * 2))
        #center = gz.polar2cart(r, th)
        #center = gz.polar2cart(r, th)
        center = polar_ngon_to_cart(NFACES, r, th)
        print "center",center
        centerPoints.append(center)
        color= (0.9, 0.9, 0.9)
        dot = gz.circle(r=4.0, xy= center, fill=color).translate((W/2, H/2))
        dot.draw(surface)

    line = gz.polyline(points=centerPoints, stroke_width=1, stroke=(1, 0, 0)).translate((W/2, H/2))
    line.draw(surface)

    im = surface.get_npimage()
    return im
Пример #53
0
def make_frame(t):
    surface = gz.Surface(R, R)
    background = gz.square(l=R, xy= [R/2,R/2], fill = (1,1,1,1))
    background.draw(surface)
    r = R/4
    ith = -np.pi/2
    C = pytweening.easeInOutSine(t/DURATION)
    # C = t/DURATION
    for i in range(NCIRCLES):
		th = ith + (i+1)*(2*np.pi*NROTATIONS) * C
		center = gz.polar2cart(R/4,th)
		color = (1.0,1.0,1.0,1.0/255)
		if i % 3 == 0:
			color = (1.0,0,0,1.0/255)
		elif i % 3 == 1:
			color = (0,1.0,0,1.0/255)
		else:
			color = (0,0,1.0,1.0/255)
		cir = gz.circle(R/4 - (i/4), fill=color, xy=center)
		cir.translate([R/2,R/2]).draw(surface)
    im = 255*((surface.get_npimage()) % 2)
    return im
    def epoch_finished(self, epoch):
        num_words = len(self.words)
        surface = gizeh.Surface(width=1200, height=self.height)
        background = gizeh.rectangle(lx=1200, ly=self.height, xy=[600,750], fill=(0,0,0))
        background.draw(surface)

        gizeh.text('%s   epoch %s' % (self.title, epoch),
                   fontfamily='Arial',
                   fontsize=20,
                   fill=(.6,.6,.6),
                   xy=(70,40),
                   h_align='left').draw(surface)
        
        weights = self.rbm.weights.get_value()
        for block in range(self.tuplesize):
            for word in range(num_words):
                x = 40
                y = 70+22*(block*(num_words+2)+word)
                gizeh.text('%s %s' % (block, self.words[word]),
                           fontfamily='Arial',
                           fontsize=12,
                           fill=(.7,.7,.7),
                           xy=(x,y),
                           h_align='left').draw(surface)
        for block in range(self.tuplesize):
            for word in range(num_words):
                for h in range(self.num_hidden):
                    vis = block*num_words+word
                    w = weights[vis, h]
                    r = math.log(1+abs(w))*4
                    x = 100+22*h
                    y = 70+22*(block*(num_words+2)+word)
                    col = (1,1,0)
                    if w < 0:
                        col = (.4,.4,.4)
                    circle = gizeh.circle(r=r, xy=[x,y], fill=col)
                    circle.draw(surface)
        surface.write_to_png("epoch-%03d.png" % epoch)
def make_frame(t):
  surface = gz.Surface(W,H, bg_color=(1,1,1))

  gradient = gz.ColorGradient(type="radial",
                  stops_colors = [(0,(1,0,0, alpha)),(1,(0.9,0,0,alpha))],
                  xy1=[0.3,-0.3], xy2=[0,0], xy3 = [0,1.4])
  for i in range(numBalls):
    if (t < duration/2):
      newRadius = pytweening.easeInOutBounce(2 * t / duration) * radius
      newCircleRadius = pytweening.easeInOutBounce(2 * t / duration) * circleRadius
    else:
      newRadius = pytweening.easeInOutBounce(1 - (t / duration)) * radius
      newCircleRadius = pytweening.easeInOutBounce(1 - (t / duration)) * circleRadius

    angle = (2 * np.pi / numBalls) * i
    #center = (W/2) + gz.polar2cart(newCircleRadius, angle)
    center = (W/2) + gz.polar2cart(circleRadius, angle)

    #ball = gz.circle(r=newRadius, fill=gradient).translate((x, y))
    ball = gz.circle(r=newRadius, fill=gradient).translate(center)
    ball.draw(surface)

  return surface.get_npimage()
Пример #56
0
def make_frame(t):
    surface = gizeh.Surface(W,H)
    radius = W*(1+ (t*(duration-t))**2 )/6
    circle = gizeh.circle(radius, xy = (W/2,H/2), fill=(1,0,0))
    circle.draw(surface)
    return surface.get_npimage()
Пример #57
0
#                         angle=np.pi/6,
#                         n = 3,
#                        xy= [W/2, H/2], # coordinates of the center
#                        stroke= (0,0,0), stroke_width=1) # 'red' in RGB coordinates

# triangle.draw( surface ) # draw the triangle on the surface

# square = gz.square(W/4, stroke=(0,0,0), stroke_width = 1, xy= [W/2, H/2])

# square.draw( surface )

# circle = gz.circle(W/8, stroke=(0,0,0), stroke_width = 1, xy= [W/2, H/2])
# circle.draw(surface)

tri = gz.regular_polygon(W/2, 3, stroke=(0,0,0), stroke_width=1, xy=[W/2, H/2])
cir = gz.circle(W/2, stroke=(0,0,0), stroke_width=1, xy=[W/2, H/2])
sqr = gz.square(W/2, stroke=(0,0,0), stroke_width=1, xy=[W/2, H/2])
grp = gz.Group([tri, cir, sqr])
grp.draw(surface)

# surface.get_npimage() # export as a numpy array (we will use that)
surface.write_to_png("shapes.png")

# NFACES, R, NSQUARES, DURATION = 3, 0.3,  70, 10

# def half(t, side="left"):
#     # pdb.set_trace()
#     points = gz.geometry.polar_polygon(NFACES, R, NSQUARES)
#     ipoint = 0 if side=="left" else NSQUARES/2
#     points = (points[ipoint:]+points[:ipoint])[::-1]
Пример #58
0
"""
This generates a Yin Yang.
"""

import gizeh as gz
from math import pi

L = 200 # <- dimensions of the final picture
surface = gz.Surface(L, L, bg_color=(0 ,.3, .6)) # blue background
r = 70 # radius of the whole yin yang

yin_yang = gz.Group([
     gz.arc(r, pi/2, 3*pi/2, fill = (1,1,1)), # white half
     gz.arc(r, -pi/2, pi/2, fill = (0,0,0)), # black half

     gz.arc(r/2, -pi/2, pi/2, fill = (1,1,1), xy = [0,-r/2]), # white semihalf
     gz.arc(r/2, pi/2, 3*pi/2, fill = (0,0,0), xy = [0, r/2]),  # black semihalf

     gz.circle(r/8, xy = [0,  +r/2], fill = (1,1,1)), # white dot
     gz.circle(r/8, xy = [0,  -r/2], fill = (0,0,0)) ]) # black dot

yin_yang.translate([L/2,L/2]).draw(surface)

surface.write_to_png("yin_yang.png")
Пример #59
0
"""
This generates a picture of 3 semi-transparent circles of different colors
which overlap to some extent.
"""

import gizeh as gz
from numpy import pi # <- 3.14... :)

L = 200 # <- dimensions of the final picture

surface = gz.Surface(L,L, bg_color=(1,1,1)) # <- white background

radius = 50
centers = [ gz.polar2cart(40, angle) for angle in [0, 2*pi/3, 4*pi/3]]
colors = [ (1,0,0,.4), # <- Semi-tranparent red (R,G,B, transparency)
           (0,1,0,.4), # <- Semi-tranparent green
           (0,0,1,.4)] # <- Semi-tranparent blue

circles = gz.Group( [ gz.circle(radius, xy=center, fill=color,
                                stroke_width=3, stroke=(0,0,0)) # black stroke
                      for center, color in zip(centers, colors)] )

circles.translate([L/2,L/2]).draw(surface)

surface.write_to_png("transparent_colors.png")