def draw(ctx, pixel_width, pixel_height, frame_no, frame_count):
            setup(ctx, pixel_width, pixel_height, width=5, background=Color(0.8))

            Text(ctx).of("Left", (0.5, 0.5)).font("Times").size(0.2).align_left().align_baseline().fill(Color('blue'))
            Text(ctx).of("Aligned", (0.5, 0.7)).font("Times").size(0.2).align_left().align_baseline().fill(Color('red'))
            Text(ctx).of("Text", (0.5, 0.9)).font("Times").size(0.2).align_left().align_baseline().fill(Color('blue'))

            Text(ctx).of("Centre", (2.5, 0.5)).font("Times", weight=FONT_WEIGHT_BOLD).size(0.2)\
                     .align_center().align_baseline().fill(Color('blue'))
            Text(ctx).of("Aligned", (2.5, 0.7)).font("Times", weight=FONT_WEIGHT_BOLD).size(0.2)\
                     .align_center().align_baseline().fill(Color('red'))
            Text(ctx).of("Text", (2.5, 0.9)).font("Times", weight=FONT_WEIGHT_BOLD).size(0.2)\
                     .align_center().align_baseline().fill(Color('blue'))

            Text(ctx).of("Right", (4.5, 0.5)).font("Times", slant=FONT_SLANT_ITALIC).size(0.2)\
                     .align_right().align_baseline().fill(Color('blue'))
            Text(ctx).of("Aligned", (4.5, 0.7)).font("Times", slant=FONT_SLANT_ITALIC).size(0.2)\
                     .align_right().align_baseline().fill(Color('red'))
            Text(ctx).of("Text", (4.5, 0.9)).font("Times", slant=FONT_SLANT_ITALIC).size(0.2)\
                     .align_right().align_baseline().fill(Color('blue'))

            Circle(ctx).of_center_radius((1.9, 2), 0.02).fill(Color(0, 0, 1))
            Text(ctx).of("gTop", (2, 2)).font("Times").size(0.2).align_left().align_top().fill(Color('black'))

            Circle(ctx).of_center_radius((1.9, 2.5), 0.02).fill(Color(0, 0, 1))
            Text(ctx).of("gMid", (2, 2.5)).font("Times").size(0.2).align_left().align_middle().fill(Color('black'))

            Circle(ctx).of_center_radius((1.9, 3), 0.02).fill(Color(0, 0, 1))
            Text(ctx).of("gBase", (2, 3)).font("Times").size(0.2).align_left().align_baseline().fill(Color('black'))

            Circle(ctx).of_center_radius((1.9, 3.5), 0.02).fill(Color(0, 0, 1))
            Text(ctx).of("gBottom", (2, 3.5)).font("Times").size(0.2).align_left().align_bottom().fill(Color('black'))
Esempio n. 2
0
def draw(ctx, pixel_width, pixel_height, frame_no, frame_count):

    setup(ctx, pixel_width, pixel_height, width=5, background=Color(0.4))

    color = Color(1, 0.5, 0)

    Rectangle(ctx).of_corner_size((1, 1.5), 2.5, 2).fill(color)
Esempio n. 3
0
def draw2(ctx, pixel_width, pixel_height, frame_no, frame_count):
    setup(ctx, pixel_width, pixel_height, background=Color(0.8))

    black = Color(0)

    Line(ctx).of_start_end((50, 50), (450, 50)).stroke(black, 20, cap=SQUARE)
    Line(ctx).of_start_end((50, 100), (450, 100)).stroke(black, 20, cap=BUTT)
    Line(ctx).of_start_end((50, 150), (450, 150)).stroke(black, 20, cap=ROUND)

    Line(ctx).of_start_end((50, 250), (450, 250)).stroke(black,
                                                         20,
                                                         cap=SQUARE,
                                                         dash=[30])
    Line(ctx).of_start_end((50, 300), (450, 300)).stroke(black,
                                                         20,
                                                         cap=BUTT,
                                                         dash=[30])
    Line(ctx).of_start_end((50, 350), (450, 350)).stroke(black,
                                                         20,
                                                         cap=ROUND,
                                                         dash=[30])

    Line(ctx).of_start_end((50, 450), (450, 450)).stroke(black,
                                                         20,
                                                         cap=BUTT,
                                                         dash=[30, 40])
    Line(ctx).of_start_end((50, 500), (450, 500)).stroke(black,
                                                         20,
                                                         cap=BUTT,
                                                         dash=[30, 10, 20, 10])
Esempio n. 4
0
        def draw(ctx, width, height, frame_no, frame_count):
            cs = DarkColorScheme()
            setup(ctx, width, height, background=cs.BACKGROUND)

            colors = [
                cs.RED,
                cs.GREEN,
                cs.BLUE,
                cs.WHITE,
                cs.GREY,
                cs.BLACK,
                cs.YELLOW,
                cs.CYAN,
                cs.MAGENTA,
                cs.ORANGE,
            ]

            Transform(ctx).translate(50, 50)

            for i, color in enumerate(colors):
                Square(ctx).of_corner_size((i * 50, 0), 50).fill(color.dark3)
                Square(ctx).of_corner_size((i * 50, 50), 50).fill(color.dark2)
                Square(ctx).of_corner_size((i * 50, 100), 50).fill(color.dark1)
                Square(ctx).of_corner_size((i * 50, 150), 50).fill(color)
                Square(ctx).of_corner_size((i * 50, 200),
                                           50).fill(color.light1)
                Square(ctx).of_corner_size((i * 50, 250),
                                           50).fill(color.light2)
                Square(ctx).of_corner_size((i * 50, 300),
                                           50).fill(color.light3)
 def draw(ctx, pixel_width, pixel_height, frame_no, frame_count):
     setup(ctx, pixel_width, pixel_height, background=Color(1))
     Image(ctx).of_file_position('cat.png', (50, 50)).paint()
     Image(ctx).of_file_position('cat.png', (300, 50)).scale(0.5).paint()
     Image(ctx).of_file_position('cat.png', (50, 300)).scale(1.5).paint()
     Image(ctx).of_file_position('formula.png', (50, 600)).paint()
     Image(ctx).of_file_position('formula.png', (350, 200)).scale(0.5).paint()
Esempio n. 6
0
def draw_delta(ctx, pixel_width, pixel_height, frame_no, frame_count):
    setup(ctx, pixel_width, pixel_height, background=Color(1))

    col = Color("cadetblue")

    pos = [10, 10]
    w = 100
    h = 100

    Rectangle(ctx).of_corner_size(pos, w, h).fill(col.with_g_factor(0.8))
    pos[0] += w
    Rectangle(ctx).of_corner_size(pos, w, h).fill(col)
    pos[0] += w
    Rectangle(ctx).of_corner_size(pos, w, h).fill(col.with_g_factor(1.2))

    pos = [10, 120]

    Rectangle(ctx).of_corner_size(pos, w, h).fill(col.with_l_factor(0.6))
    pos[0] += w
    Rectangle(ctx).of_corner_size(pos, w, h).fill(col)
    pos[0] += w
    Rectangle(ctx).of_corner_size(pos, w, h).fill(col.with_l_factor(1.4))

    pos = [10, 230]

    Rectangle(ctx).of_corner_size(pos, w, h).fill(col.with_s_factor(0.6))
    pos[0] += w
    Rectangle(ctx).of_corner_size(pos, w, h).fill(col)
    pos[0] += w
    Rectangle(ctx).of_corner_size(pos, w, h).fill(col.with_s_factor(1.4))
Esempio n. 7
0
        def draw(ctx, width, height, frame_no, frame_count):
            setup(ctx, width, height, background=Color(1))

            colors = [
                Color(0.5, 0, 0),  # red
                Color(0, 0.5, 0),  # green
                Color(0, 0, 0.5),  #blue
                Color(0, 0.5, 0.5),  # cyan
                Color(0.5, 0, 0.5),  # magenta
                Color(0.5, 0.5, 0),  # yellow
                Color(1, 1, 1),  # white
                Color(0.5, 0.5, 0.5),  # grey
            ]

            Transform(ctx).translate(50, 50)

            for i, color in enumerate(colors):
                Square(ctx).of_corner_size((i * 50, 0), 50).fill(color.dark3)
                Square(ctx).of_corner_size((i * 50, 50), 50).fill(color.dark2)
                Square(ctx).of_corner_size((i * 50, 100), 50).fill(color.dark1)
                Square(ctx).of_corner_size((i * 50, 150), 50).fill(color)
                Square(ctx).of_corner_size((i * 50, 200),
                                           50).fill(color.light1)
                Square(ctx).of_corner_size((i * 50, 250),
                                           50).fill(color.light2)
                Square(ctx).of_corner_size((i * 50, 300),
                                           50).fill(color.light3)
def draw2(ctx, pixel_width, pixel_height, frame_no, frame_count):

    width = 32
    setup(ctx, pixel_width, pixel_height, width=width, startx=-width/2, starty=-width/2, background=Color(1))

    a = 14
    b = 6
    d = 4
    angle = 1

    Origin = (0, 0)
    A = (-a, 0)
    B = ((a-b)*math.cos(angle), (a-b)*math.sin(angle))
    x = (a - b) * math.cos(angle) + d * math.cos((a - b) / b * angle)
    y = (a - b) * math.sin(angle) - d * math.sin((a - b) / b * angle)
    D = (x, y)

    Polygon(ctx).of_points(create_spiro(a, b, d)).stroke(Color('skyblue'), line_width=0.1)
    Polygon(ctx).of_points(create_spiro(a, b, d, 0.01, angle)).open().stroke(Color('red'), line_width=0.1)

    Circle(ctx).of_center_radius(Origin, a).stroke(Color('darkgreen'), line_width=0.1)
    Circle(ctx).of_center_radius(Origin, 0.3).fill(Color('darkgreen'))
    Line(ctx).of_start_end(Origin, A).stroke(Color('darkgreen'), line_width=0.1)
    Text(ctx).of('a', (A[0]/2, A[1])).size(1.5).offset(0, -0.5).fill(Color('darkgreen'))
    Circle(ctx).of_center_radius(B, b).stroke(Color('blue'), line_width=0.1)
    Circle(ctx).of_center_radius(B, 0.3).fill(Color('blue'))
    Text(ctx).of('b', (B[0], B[1]+b/2)).size(1.5).offset(0.5, 0).fill(Color('blue'))
    Line(ctx).of_start_end(B, (B[0], B[1]+b)).stroke(Color('blue'), line_width=0.1)
    Circle(ctx).of_center_radius(D, 0.3).fill(Color('black'))
    Line(ctx).of_start_end(B, D).stroke(Color('black'), line_width=0.1)
    Text(ctx).of('d', ((B[0]+D[0])/2, (B[1]+D[1])/2)).size(1.5).offset(0.5, 0.5).fill(Color('black'))
        def draw(ctx, width, height, frame_no, frame_count):
            setup(ctx, width, height, width=5, background=Color(0.8))

            Rectangle(ctx).of_corner_size((0.5, 1), 1,
                                          1.2).stroke(Color(0, .5, 0),
                                                      0.1,
                                                      dash=[0.25])
            Rectangle(ctx).of_corner_size((2, 1), 1,
                                          1.2).stroke(Color(0, .5, 0),
                                                      0.1,
                                                      dash=[0.25],
                                                      cap=BUTT)
            Rectangle(ctx).of_corner_size((3.5, 1), 1.2,
                                          1).stroke(Color(0, .5, 0),
                                                    0.1,
                                                    dash=[0.25],
                                                    cap=ROUND)
            Rectangle(ctx).of_corner_size((0.5, 3), 1,
                                          1.2).stroke(Color(0, .5, 0),
                                                      0.1,
                                                      join=ROUND)
            Rectangle(ctx).of_corner_size((2, 3), 1,
                                          1.2).stroke(Color(0, .5, 0),
                                                      0.1,
                                                      join=BEVEL)
            Rectangle(ctx).of_corner_size((3.5, 3), 1.2,
                                          1).stroke(Color(0, .5, 0),
                                                    0.1,
                                                    miter_limit=1)
def draw3(ctx, pixel_width, pixel_height, frame_no, frame_count):

    width = 32
    setup(ctx, pixel_width, pixel_height, width=width, startx=-width/2, starty=-width/2, background=Color(1))

    a = 14
    b = 6
    d = 4
    angle = (frame_no/frame_count)*2*math.pi*b/math.gcd(a, b)
    print(angle)

    Origin = (0, 0)
    A = (-a, 0)
    B = ((a-b)*math.cos(angle), (a-b)*math.sin(angle))
    x = (a - b) * math.cos(angle) + d * math.cos((a - b) / b * angle)
    y = (a - b) * math.sin(angle) - d * math.sin((a - b) / b * angle)
    D = (x, y)

    Polygon(ctx).of_points(create_spiro(a, b, d)).stroke(Color('skyblue'), line_width=0.2)
    Polygon(ctx).of_points(create_spiro(a, b, d, 0.01, angle)).open().stroke(Color('red'), line_width=0.2)

    Circle(ctx).of_center_radius(Origin, a).stroke(Color('darkgreen'), line_width=0.2)
    Circle(ctx).of_center_radius(B, b).stroke(Color('blue'), line_width=0.2)
    Circle(ctx).of_center_radius(B, 0.3).fill(Color('blue'))
    Circle(ctx).of_center_radius(D, 0.3).fill(Color('black'))
    Line(ctx).of_start_end(B, D).stroke(Color('black'), line_width=0.2)
Esempio n. 11
0
def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, width=5, background=Color(0.8))

    # Get a polygon path object
    path1 = Polygon(ctx).of_points([(0, 0), (1, 1), (0.5, 2), (0.5, 1)])\
	                    .path()

    # Get a text path object
    path2 = Text(ctx).of("Path text", (0, 0)).font("Times").size(0.2)\
	                 .align_left().align_top().path()

    # Apply the polygon in various places
    with Transform(ctx).translate(0.5, 1):
        Path(ctx).of(path1).stroke(Color('darkgreen'), 0.1)

    with Transform(ctx).translate(1, 2.5):
        Path(ctx).of(path1).fill(Color('blue'))

    with Transform(ctx).translate(2.5, 0.5).scale(2, 2):
        Path(ctx).of(path1).fill(Color('orange')).stroke(Color('black'), 0.05)

    # Apply the text in various places
    with Transform(ctx).translate(0, 0):
        Path(ctx).of(path2).fill(Color('black'))

    with Transform(ctx).translate(2, 3):
        Path(ctx).of(path2).stroke(Color('red'), 0.01)

    with Transform(ctx).translate(2, 4).scale(2, 2):
        Path(ctx).of(path2).fill(Color('yellow')).stroke(Color('black'), 0.01)
Esempio n. 12
0
def draw4(ctx, pixel_width, pixel_height, frame_no, frame_count):

    setup(ctx, pixel_width, pixel_height, background=Color(0.8))

    blue = Color('blue')
    grey = Color(0.2)
    thickness = 2

    a0 = (50, 200)
    b0 = (100, 200)
    c0 = (100, 50)
    d0 = (200, 50)
    a1 = (200, 50)
    b1 = (300, 50)
    c1 = (350, 220)
    d1 = (450, 200)
    points = [a0, (*b0, *c0, *d0), (*b1, *c1, *d1)]
    Polygon(ctx).of_points(points).open().stroke(blue, thickness)

    show_bezier_points(ctx, (50, 200), (100, 200), (100, 50), (200, 50))
    show_bezier_points(ctx, (200, 50), (300, 50), (350, 220), (450, 200))

    Text(ctx).of('a0', a0).size(20).align_center().align_middle().offset_towards(b0, -20).fill(grey)
    Text(ctx).of('b0', b0).size(20).align_center().align_middle().offset_towards(a0, -20).fill(grey)
    Text(ctx).of('c0', c0).size(20).align_center().align_middle().offset_towards(d0, -20).fill(grey)
    Text(ctx).of('d0/a1', d0).size(20).align_center().align_middle().offset(0, -20).fill(grey)
    Text(ctx).of('b1', b1).size(20).align_center().align_middle().offset_towards(a1, -20).fill(grey)
    Text(ctx).of('c1', c1).size(20).align_center().align_middle().offset_towards(d1, -20).fill(grey)
    Text(ctx).of('d1', d1).size(20).align_center().align_middle().offset_towards(c1, -20).fill(grey)
def draw3(ctx, pixel_width, pixel_height, frame_no, frame_count):

    width = 32
    setup(ctx,
          pixel_width,
          pixel_height,
          width=width,
          startx=-width / 2,
          starty=-width / 2,
          background=Color(1))

    # x = [i/100 for i in range(1000)]
    # y = [-sintri(i) for i in x]
    # Polygon(ctx).of_points(zip(x, y)).open().stroke(Color('black'), line_width=0.1)
    #
    # x = [i/100 for i in range(1000)]
    # y = [-costri(i) + 2 for i in x]
    # Polygon(ctx).of_points(zip(x, y)).open().stroke(Color('black'), line_width=0.1)
    #
    # x = [i/100 for i in range(1000)]
    # y = [-int(3*i/(2*math.pi)) - 2 for i in x]
    # Polygon(ctx).of_points(zip(x, y)).open().stroke(Color('black'), line_width=0.1)

    a = 16
    b = 10
    d = 7
    Polygon(ctx).of_points(create_spiro_triangle(a, b, d)).fill(
        Color('gold'), fill_rule=EVEN_ODD).stroke(Color('darkblue'),
                                                  line_width=0.1)
        def draw(ctx, width, height, frame_no, frame_count):
            setup(ctx, width, height, width=5, background=Color(0.8))

            # The circle function is a convenience function that adds a circle as a new the path.
            # You can fill or stroke it as you wish.
            circle(ctx, (1, 1), 0.7)
            ctx.set_source_rgba(*Color(1, 0, 0))
            ctx.fill()

            # Circle objects can be filled, stroked, filled and stroked.
            Circle(ctx).of_center_radius(
                (2.5, 1), 0.7).fill(Color(0, 0, 1)).stroke(Color(0), 0.05)
            Circle(ctx).of_center_radius(
                (4, 1), 0.7).as_arc(0, 1).stroke(Color(0, 0.5, 0), 0.05)

            Circle(ctx).of_center_radius(
                (1, 2.5), 0.7).as_sector(1, 3).stroke(Color('orange'), 0.05)
            Circle(ctx).of_center_radius(
                (2.5, 2.5), 0.7).as_sector(2, 4.5).fill(Color('cadetblue'))
            Circle(ctx).of_center_radius((4, 2.5), 0.7).as_sector(2.5, 6).fill(
                Color('yellow')).stroke(Color('magenta'), 0.05)

            Circle(ctx).of_center_radius(
                (1, 4), 0.7).as_segment(1, 3).stroke(Color('orange'), 0.05)
            Circle(ctx).of_center_radius(
                (2.5, 4), 0.7).as_segment(2, 4.5).fill(Color('cadetblue'))
            Circle(ctx).of_center_radius((4, 4), 0.7).as_segment(2.5, 6).fill(
                Color('yellow')).stroke(Color('magenta'), 0.05)
Esempio n. 15
0
def draw(ctx, pixel_width, pixel_height, frame_no, frame_count):

    setup(ctx, pixel_width, pixel_height, background=Color(0.8))

    red = Color('crimson')
    green = Color('darkgreen')
    blue = Color('dodgerblue')

    RegularPolygon(ctx).of_centre_sides_radius((150, 150), 5, 100)\
                       .fill(blue)\
                       .stroke(green, 5)

    RegularPolygon(ctx).of_centre_sides_radius((400, 150), 6, 100)\
                       .fill(blue)\
                       .stroke(green, 5)

    RegularPolygon(ctx).of_centre_sides_radius((650, 150), 6, 100, math.pi/12)\
                       .fill(blue)\
                       .stroke(green, 5)

    p = RegularPolygon(ctx).of_centre_sides_radius((150, 400), 5, 100)\
                       .fill(blue)\
                       .stroke(green, 5)
    Circle(ctx).of_center_radius((150, 400), p.inner_radius).stroke(red, 5)

    p = RegularPolygon(ctx).of_centre_sides_radius((400, 400), 5, 100)\
                       .fill(blue)\
                       .stroke(green, 5)
    Circle(ctx).of_center_radius((400, 400), p.outer_radius).stroke(red, 5)

    p = RegularPolygon(ctx).of_centre_sides_radius((650, 400), 5, 100)\
                       .fill(blue)\
                       .stroke(green, 5)
    for v in p.vertices:
        Circle(ctx).of_center_radius(v, 10).fill(red)
Esempio n. 16
0
def draw(ctx, pixel_width, pixel_height, frame_no, frame_count):

    setup(ctx, pixel_width, pixel_height, background=Color(0.4))

    color = Color(1, 0.5, 0)

    Rectangle(ctx).of_corner_size((100, 150), 250, 200).fill(color)
Esempio n. 17
0
def draw3(ctx, pixel_width, pixel_height, frame_no, frame_count):
    setup(ctx, pixel_width, pixel_height, width=10, background=Color(0.8))

    a = (1, 2)
    b = (7, 2)
    c = (3, 8)
    d = (9, 8)
    e = (5, 2)
    f = (5, 8)

    Polygon(ctx).of_points([a, b, d, c]).stroke(Color('blue'), line_width=.05)

    ParallelMarker(ctx).of_start_end(
        a,
        b).with_length(.5).with_count(2).with_gap(0.15).stroke(Color('blue'),
                                                               line_width=.05)
    ParallelMarker(ctx).of_start_end(
        c,
        d).with_length(.5).with_count(2).with_gap(0.15).stroke(Color('blue'),
                                                               line_width=.05)
    ParallelMarker(ctx).of_start_end(a,
                                     c).with_length(.5).stroke(Color('blue'),
                                                               line_width=.05)
    ParallelMarker(ctx).of_start_end(b,
                                     d).with_length(.5).stroke(Color('blue'),
                                                               line_width=.05)

    Text(ctx).of('a', a).size(1).offset_towards(d, -0.5).fill(Color('red'))
    Text(ctx).of('b', b).size(1).offset_towards(c, -0.5).fill(Color('red'))
    Text(ctx).of('c', c).size(1).offset_towards(b, -0.9).fill(Color('red'))
    Text(ctx).of('d', d).size(1).offset_towards(a, -0.5).fill(Color('red'))
Esempio n. 18
0
def draw(ctx, pixel_width, pixel_height, frame_no, frame_count):

    setup(ctx, pixel_width, pixel_height, background=Color(0.8))

    blue = Color('blue')
    grey = Color(0.4)
    thickness = 2

    Circle(ctx).of_center_radius((100, 100), 75).stroke(blue, thickness)

    Circle(ctx).of_center_radius((300, 100), 75).stroke(grey,
                                                        thickness,
                                                        dash=[5])
    Circle(ctx).of_center_radius((300, 100),
                                 75).as_arc(0, 1).stroke(blue, thickness)

    Circle(ctx).of_center_radius((100, 300), 75).stroke(grey,
                                                        thickness,
                                                        dash=[5])
    Circle(ctx).of_center_radius((100, 300),
                                 75).as_sector(1, 3).stroke(blue, thickness)

    Circle(ctx).of_center_radius((300, 300), 75).stroke(grey,
                                                        thickness,
                                                        dash=[5])
    Circle(ctx).of_center_radius((300, 300),
                                 75).as_segment(-1, 1).stroke(blue, thickness)
Esempio n. 19
0
def draw2(ctx, pixel_width, pixel_height, frame_no, frame_count):

    width = 32
    setup(ctx,
          pixel_width,
          pixel_height,
          width=width,
          startx=-width / 2,
          starty=-width / 2,
          background=Color(1))

    a = 16
    b = 13
    d = 5
    Polygon(ctx).of_points(create_spiro(a, b, d)).stroke(Color('firebrick'),
                                                         line_width=0.1)

    a = 16
    b = 9
    d = 8
    Polygon(ctx).of_points(create_spiro(a, b, d)).stroke(Color('goldenrod'),
                                                         line_width=0.1)

    a = 16
    b = 11
    d = 6
    Polygon(ctx).of_points(create_spiro(a, b, d)).stroke(Color('darkgreen'),
                                                         line_width=0.1)
Esempio n. 20
0
def draw(ctx, pixel_width, pixel_height, frame_no, frame_count):
    setup(ctx, pixel_width, pixel_height, width=10, background=Color(0.8))

    a = (1, 2)
    b = (7, 2)
    c = (3, 8)
    d = (9, 8)
    e = (5, 2)
    f = (5, 8)

    Polygon(ctx).of_points([a, b, d, c]).stroke(Color('blue'), line_width=.05)
    Line(ctx).of_start_end(e, f).stroke(Color('blue'), line_width=.05)

    AngleMarker(ctx).of_points(
        b, a,
        c).with_radius(.5).with_count(2).with_gap(0.15).stroke(Color('blue'),
                                                               line_width=.05)
    AngleMarker(ctx).of_points(a, b, d).with_radius(.5).stroke(Color('blue'),
                                                               line_width=.05)
    AngleMarker(ctx).of_points(
        c, d,
        b).with_radius(.5).with_count(2).with_gap(0.15).stroke(Color('blue'),
                                                               line_width=.05)
    AngleMarker(ctx).of_points(a, c, d).with_radius(.5).stroke(Color('blue'),
                                                               line_width=.05)
    AngleMarker(ctx).of_points(
        e, f, d).with_radius(.5).as_right_angle().stroke(Color('blue'),
                                                         line_width=.05)

    Text(ctx).of('a', a).size(1).offset_towards(d, -0.5).fill(Color('red'))
    Text(ctx).of('b', b).size(1).offset_towards(c, -0.9).fill(Color('red'))
    Text(ctx).of('c', c).size(1).offset_towards(b, -0.9).fill(Color('red'))
    Text(ctx).of('d', d).size(1).offset_towards(a, -0.5).fill(Color('red'))
    Text(ctx).of('e', e).size(1).offset_towards(f, -0.3).fill(Color('red'))
    Text(ctx).of('f', f).size(1).offset_towards(e, -0.9).fill(Color('red'))
        def draw(ctx, width, height, frame_no, frame_count):
            setup(ctx, width, height, width=500, background=Color(0.8))

            with Transform(ctx) as transform:
                Text(ctx).of('A', (10, 100)).size(80).fill(Color('blue'))

            Text(ctx).of('B', (110, 100)).size(80).fill(Color('black'))
            with Transform(ctx) as transform:
                transform.scale(0.75, 1.5)
                Text(ctx).of('B', (110, 100)).size(80).fill(Color('blue', 0.5))

            Text(ctx).of('C', (210, 100)).size(80).fill(Color('black'))
            Circle(ctx).of_center_radius((250, 80), 5).fill(Color('red'))
            with Transform(ctx).scale(0.75, 1.5, (250, 80)):
                Text(ctx).of('C', (210, 100)).size(80).fill(Color('blue', 0.5))

            Text(ctx).of('D', (110, 200)).size(80).fill(Color('black'))
            with Transform(ctx) as transform:
                transform.translate(20, 30)
                Text(ctx).of('D', (110, 200)).size(80).fill(Color('blue', 0.5))

            Text(ctx).of('E', (110, 300)).size(80).fill(Color('black'))
            with Transform(ctx) as transform:
                transform.rotate(0.1)
                Text(ctx).of('E', (110, 300)).size(80).fill(Color('blue', 0.5))

            Text(ctx).of('F', (210, 300)).size(80).fill(Color('black'))
            Circle(ctx).of_center_radius((250, 80), 5).fill(Color('red'))
            with Transform(ctx).rotate(0.1, (210, 300)):
                Text(ctx).of('F', (210, 300)).size(80).fill(Color('blue', 0.5))

            Text(ctx).of('G', (210, 400)).size(80).fill(Color('black'))
            Circle(ctx).of_center_radius((250, 80), 5).fill(Color('red'))
            with Transform(ctx).matrix([1, 0.5, 0, 1, 0, 0]):
                Text(ctx).of('G', (210, 400)).size(80).fill(Color('blue', 0.5))
def draw4(ctx, pixel_width, pixel_height, frame_no, frame_count):

    width = 32
    setup(ctx,
          pixel_width,
          pixel_height,
          width=width,
          startx=-width / 2,
          starty=-width / 2,
          background=Color(1))

    colors = [
        Color('magenta', 0.7),
        Color('red', 0.7),
        Color('blue', 0.7),
        Color('gold', 0.7),
    ]

    for i, color in enumerate(colors):
        a = 16
        b = 10
        d = 7
        with Transform(ctx).rotate(i * math.pi / 6):
            Polygon(ctx).of_points(create_spiro_triangle(a, b, d)).fill(
                color, fill_rule=EVEN_ODD)
Esempio n. 23
0
        def draw(ctx, width, height, frame_no, frame_count):
            setup(ctx, width, height, background=Color(1))

            cs = ArtisticColorScheme()

            colors = [
                cs.RED,
                cs.BLUE,
                cs.GREEN,
                cs.YELLOW,
                cs.MAGENTA,
                cs.STEEL,
                cs.CREAM,
                cs.LIME,
                cs.BLACK,
                cs.GREY,
                cs.WHITE,
            ]

            Transform(ctx).translate(50, 50)

            for i, color in enumerate(colors):
                Square(ctx).of_corner_size((i * 50, 0), 50).fill(color.dark3)
                Square(ctx).of_corner_size((i * 50, 50), 50).fill(color.dark2)
                Square(ctx).of_corner_size((i * 50, 100), 50).fill(color.dark1)
                Square(ctx).of_corner_size((i * 50, 150), 50).fill(color)
                Square(ctx).of_corner_size((i * 50, 200),
                                           50).fill(color.light1)
                Square(ctx).of_corner_size((i * 50, 250),
                                           50).fill(color.light2)
                Square(ctx).of_corner_size((i * 50, 300),
                                           50).fill(color.light3)
Esempio n. 24
0
def draw2(ctx, pixel_width, pixel_height, frame_no, frame_count):

    setup(ctx, pixel_width, pixel_height, background=Color(0.8))

    show_bezier_labels(ctx, (50, 150), (100, 50), (150, 50), (200, 150))
    show_bezier_labels(ctx, (250, 150), (250, 50), (350, 50), (400, 150))
    show_bezier_labels(ctx, (50, 350), (100, 250), (150, 450), (200, 350))
    show_bezier_labels(ctx, (250, 350), (450, 250), (200, 250), (400, 350))
Esempio n. 25
0
 def draw(ctx, width, height, frame_no, frame_count):
     setup(ctx, width, height, background=Color(0.8))
     image, size = rasterise_formula(
         "formula-test-temp", r"\cosh{x} = \frac{e^{x}+e^{-x}}{2}",
         Color("dodgerblue"))
     Image(ctx).of_file_position(image, (50, 50)).paint()
     Text(ctx).of("Size = " + str(size),
                  (50, 300)).size(20).fill(Color(0))
Esempio n. 26
0
def draw(ctx, width, height, frame_no, frame_count):
    setup(ctx, width, height, width=5, background=Color(0.8))

    # Bezier objects can only be stroked as they do not contain an area.
    Bezier(ctx).of_abcd((1, 1.5), (3, 0.5), (2, 2.5), (4, 1.5)).stroke(Color('darkgreen'), 0.1)

    # Create a polygon with a bezier side
    Polygon(ctx).of_points([(1, 4.5), (1, 2.5), (2, 3, 3, 4, 4, 2.5), (4, 4.5)]).fill(Color('red')).stroke(Color('blue'), 0.05)
def draw(ctx, pixel_width, pixel_height, frame_no, frame_count):
    setup(ctx, pixel_width, pixel_width, background=Color(0.8))

    black = Color(0)

    Rectangle(ctx).of_corner_size((50, 50), 350, 250).add()
    Rectangle(ctx).of_corner_size((100, 100), 250, 150).as_sub_path()\
        .fill(Color('red'), fill_rule=EVEN_ODD)\
        .stroke(Color('blue'), 5)
    def draw(ctx, pixel_width, pixel_height, fn, frame_count):
        setup(ctx,
              pixel_width,
              pixel_height,
              width=OUTPUTWIDTH,
              height=OUTPUTHEIGHT,
              background=Color(0.5))

        Circle(ctx).of_center_radius(position[fn], 30).fill(Color("red"))
Esempio n. 29
0
def draw3(ctx, pixel_width, pixel_height, frame_no, frame_count):

    setup(ctx, pixel_width, pixel_height, background=Color(0.8))

    blue = Color('blue')
    red = Color('red')
    thickness = 4
    points = [(100, 250), (100, 50), (200, 100, 300, 200, 400, 50), (400, 250)]
    Polygon(ctx).of_points(points).fill(red).stroke(blue, thickness)
Esempio n. 30
0
def draw_color_scheme(ctx, pixel_width, pixel_height, frame_no, frame_count):
    setup(ctx, pixel_width, pixel_height, background=Color("white"))

    # Fill a square with red
    Square(ctx).of_corner_size((50, 50), 200).fill(cs.RED)

    # Fill a square with a lighter version of RED, stroke with a darker version
    Square(ctx).of_corner_size(
        (300, 50), 200).fill(cs.RED.light1).stroke(cs.RED.dark1, 10)