コード例 #1
0
        def draw(ctx, width, height, frame_no, frame_count):
            setup(ctx, width, height, background=Color(1))

            # Creates a set of axes.
            axes = Axes(ctx, position=(150, 150), width=1500, height=1200).of_start((-100, -1.1)).of_extent((500, 2.2))\
                .with_divisions((90, 0.5)).with_subdivisions((2, 5)).with_feature_scale(3)
            axes.draw()

            # Add curve. Deliberate low precision to test it works
            axes.clip()
            Plot(axes).of_function(lambda x: math.sin(x * math.pi / 180),
                                   precision=25).stroke(pattern=Color('red'))
            axes.unclip()
コード例 #2
0
        def draw(ctx, width, height, frame_no, frame_count):
            setup(ctx, width, height, background=Color(1))

            # Creates a set of axes.
            axes = Axes(ctx, position=(50, 50), width=500,
                        height=400).of_start((-4, -3)).of_extent((10, 8))
            axes.draw()

            # Add various curves
            gradient = LinearGradient().of_points(
                (0, 50), (0, 450)).with_start_end(Color('red'),
                                                  Color('darkblue')).build()
            axes.clip()
            Plot(axes).of_function(lambda x: x * x).stroke(pattern=gradient,
                                                           line_width=4)
            Plot(axes).of_xy_function(lambda x: 1.5**x).stroke(
                pattern=gradient)
            Plot(axes).of_polar_function(lambda x: 2 * x).stroke(
                pattern=gradient)
            axes.unclip()
コード例 #3
0
        def draw(ctx, width, height, frame_no, frame_count):
            setup(ctx, width, height, background=Color(1))

            # Creates a set of axes.
            axes = Axes(ctx, position=(50, 50), width=500, height=400)\
                .of_start((-100, -1.1))\
                .of_extent((500, 2.2))\
                .with_divisions((90, 0.5))\
                .with_subdivisions((2, 5))\
                .background(Color('wheat'))\
                .text_color(Color('darkgreen'))\
                .text_style(font="Times", size=20, slant=FONT_SLANT_ITALIC, weight=FONT_WEIGHT_NORMAL)\
                .axis_linestyle(Color('darkblue'), line_width=3)\
                .division_linestyle(Color('steelblue'), line_width=3)\
                .subdivision_linestyle(Color('lightblue'), line_width=2, dash=[4, 2])
            axes.draw()

            # Add curve
            axes.clip()
            Plot(axes).of_function(lambda x: math.sin(x * math.pi / 180),
                                   precision=100).stroke(pattern=Color('red'))
            axes.unclip()
コード例 #4
0
def draw(ctx, width, height, frame_no, frame_count):

    setup(ctx, width, height, background=Color(1))

    # Creates a set of axes.
    # Use the default size of 10 units, but offset the start toplace the origin inthe centre
    axes = Axes(ctx, (50, 50), 500, 500).of_start((-5, -5))
    axes.draw()

    axes.clip()
    Plot(axes).of_function(lambda x: x * x).stroke(pattern=Color('red'),
                                                   line_width=3,
                                                   dash=[5])
    Plot(axes).of_xy_function(lambda x: 1.5**x).stroke(pattern=Color('green'),
                                                       line_width=5,
                                                       dash=[10, 10, 20, 10],
                                                       cap=ROUND)
    Plot(axes).of_polar_function(lambda x: 2 * x).stroke(pattern=Color('blue'),
                                                         line_width=4,
                                                         dash=[5],
                                                         cap=BUTT)
    axes.unclip()