コード例 #1
0
ファイル: boxes.py プロジェクト: tanglemore/grx
def activate(app):
    white = Grx.color_get_white()
    x = Grx.get_width() // 10
    y = Grx.get_height() // 10

    line_opts = Grx.LineOptions()
    line_opts.color = white
    line_opts.width = 3
    line_opts.n_dash_patterns = 2
    line_opts.dash_pattern0 = 6
    line_opts.dash_pattern1 = 4
    line_opts0 = Grx.LineOptions()
    pat = demo.get_checkerboard_pixmap()
    Grx.draw_box(x * 1, y * 1, x * 3, y * 3, white)
    Grx.draw_box_with_options(x * 4, y * 1, x * 6, y * 3, line_opts)
    Grx.draw_box_with_pixmap(x * 7, y * 1, x * 9, y * 3, line_opts0, pat)

    img = demo.get_smiley_pixmap(x * 2, y * 2)
    Grx.draw_filled_box(x * 1, y * 4, x * 3, y * 6, white)
    Grx.draw_filled_box_with_pixmap(x * 4, y * 4, x * 6, y * 6, img)
    Grx.draw_filled_box_with_offset_pixmap(x * 2, y, x * 7, y * 4, x * 9,
                                           y * 6, img)

    frame_colors = Grx.FramedBoxColors()
    frame_colors.background = Grx.color_get(224, 223, 228)
    frame_colors.border_top = Grx.color_get(255, 255, 255)
    frame_colors.border_right = Grx.color_get(155, 157, 154)
    frame_colors.border_bottom = Grx.color_get(110, 110, 100)
    frame_colors.border_left = Grx.color_get(241, 239, 226)
    Grx.draw_framed_box(x * 1, y * 7, x * 3, y * 9, y / 4, frame_colors)
    Grx.draw_rounded_box(x * 4, y * 7, x * 6, y * 9, y / 4, white)
    Grx.draw_filled_rounded_box(x * 7, y * 7, x * 9, y * 9, y / 4, white)
コード例 #2
0
ファイル: circles.py プロジェクト: tanglemore/grx
def activate(app):
    x = Grx.get_width() // 8
    y = Grx.get_height() // 8
    r = min(x, y) // 2
    colors = Grx.color_get_ega_colors()
    white = colors[Grx.EgaColorIndex.WHITE]
    checker = demo.get_checkerboard_pixmap()
    line_opt0 = Grx.LineOptions()

    # just a plain old circle
    Grx.draw_circle(x, y, r, white)
    Grx.draw_filled_circle(x, y * 3, r, white)
    Grx.draw_circle_with_pixmap(x, y * 5, r, line_opt0, checker)
    Grx.draw_filled_circle_with_pixmap(x, y * 7, r, checker)

    # quarter a circles
    Grx.draw_circle_arc(x * 3, y, r, 0, 900, Grx.ArcStyle.OPEN, white)
    Grx.draw_filled_circle_arc(x * 3, y * 3, r, 0, 900, Grx.ArcStyle.OPEN,
                               white)
    Grx.draw_circle_arc_with_pixmap(x * 3, y * 5, r, 0, 900, Grx.ArcStyle.OPEN,
                                    line_opt0, checker)
    Grx.draw_filled_circle_arc_with_pixmap(x * 3, y * 7, r, 0, 900,
                                           Grx.ArcStyle.OPEN, checker)
    Grx.draw_circle_arc(x * 3, y, r, 1800, 2700, Grx.ArcStyle.CLOSED_CHORD,
                        white)
    Grx.draw_filled_circle_arc(x * 3, y * 3, r, 1800, 2700,
                               Grx.ArcStyle.CLOSED_CHORD, white)
    Grx.draw_circle_arc_with_pixmap(x * 3, y * 5, r, 1800, 2700,
                                    Grx.ArcStyle.CLOSED_CHORD, line_opt0,
                                    checker)
    Grx.draw_filled_circle_arc_with_pixmap(x * 3, y * 7, r, 1800, 2700,
                                           Grx.ArcStyle.CLOSED_CHORD, checker)

    # Pac-Man
    Grx.draw_circle_arc(x * 5, y, r, 450, 3150, Grx.ArcStyle.CLOSED_RADIUS,
                        white)
    Grx.draw_filled_circle_arc(x * 5, y * 3, r, 450, 3150,
                               Grx.ArcStyle.CLOSED_RADIUS, white)
    Grx.draw_circle_arc_with_pixmap(x * 5, y * 5, r, 450, 3150,
                                    Grx.ArcStyle.CLOSED_RADIUS, line_opt0,
                                    checker)
    Grx.draw_filled_circle_arc_with_pixmap(x * 5, y * 7, r, 450, 3150,
                                           Grx.ArcStyle.CLOSED_RADIUS, checker)

    # line options
    line_opt = Grx.LineOptions()
    line_opt.color = colors[Grx.EgaColorIndex.GREEN]
    line_opt.width = 1
    line_opt.n_dash_patterns = 2
    line_opt.dash_pattern0 = 2
    line_opt.dash_pattern1 = 2
    Grx.draw_circle_with_options(x * 7, y, r, line_opt)
    Grx.draw_circle_arc_with_options(x * 7, y * 3, r, 2250, 1350,
                                     Grx.ArcStyle.CLOSED_RADIUS, line_opt)
    Grx.draw_circle_arc_with_pixmap(x * 7, y * 5, r, 2250, 1350,
                                    Grx.ArcStyle.CLOSED_RADIUS, line_opt,
                                    checker)
コード例 #3
0
ファイル: lines.py プロジェクト: tanglemore/grx
def activate(app):
    max_x = Grx.get_max_x()
    max_y = Grx.get_max_y()
    colors = Grx.color_get_ega_colors()

    # draw some horizontal lines
    for y in range(10, 20):
        Grx.draw_hline(0, max_x, y, colors[y % 16])

    # and some vertical lines
    for x in range(10, 20):
        Grx.draw_vline(x, 0, max_y, colors[x % 16])

    # and angled lines
    for x in range(30, 40):
        Grx.draw_line(20, x, x, 20, colors[x % 16])

    # then two connected lines at right angles
    for x in range(50, 60):
        points = Grx.generate_points((20, x, x, x, x, 20))
        Grx.draw_polyline(points, colors[x % 16])

    # try out line options
    line_opt = Grx.LineOptions()
    line_opt.color = Grx.color_get_white()
    line_opt.width = 3
    line_opt.n_dash_patterns = 3
    line_opt.dash_pattern0 = 3
    line_opt.dash_pattern1 = 6
    Grx.draw_line_with_options(70, 30, 110, 30, line_opt)
    points = Grx.generate_points((70, 40, 90, 40, 90, 50, 110, 50))
    Grx.draw_polyline_with_options(points, line_opt)

    # and pixmaps
    checker = demo.get_checkerboard_pixmap()
    line_opt0 = Grx.LineOptions()
    Grx.draw_line_with_pixmap(70, 60, 110, 60, line_opt0, checker)
    for y in range(65, 70):
        Grx.draw_hline_with_offset_pixmap(y, 0, 70, y, 40, checker)
コード例 #4
0
ファイル: ellipses.py プロジェクト: tanglemore/grx
def activate(app):
    x = Grx.get_width() // 8
    y = Grx.get_height() // 8
    r1 = int(x * 0.8)
    r2 = int(y * 0.8)
    colors = Grx.color_get_ega_colors()
    white = colors[Grx.EgaColorIndex.WHITE]
    checker = demo.get_checkerboard_pixmap()
    line_opt0 = Grx.LineOptions()

    # just a plain old ellipse
    Grx.draw_ellipse(x, y, r1, r2, white)
    Grx.draw_filled_ellipse(x, y * 3, r1, r2, white)
    Grx.draw_ellipse_with_pixmap(x, y * 5, r1, r2, line_opt0, checker)
    Grx.draw_filled_ellipse_with_pixmap(x, y * 7, r1, r2, checker)

    # quarter a ellipses
    Grx.draw_ellipse_arc(x * 3, y, r1, r2, 0, 900, Grx.ArcStyle.OPEN, white)
    Grx.draw_filled_ellipse_arc(x * 3, y * 3, r1, r2, 0, 900,
                                Grx.ArcStyle.OPEN, white)
    Grx.draw_ellipse_arc_with_pixmap(x * 3, y * 5, r1, r2, 0, 900,
                                     Grx.ArcStyle.OPEN, line_opt0, checker)
    Grx.draw_filled_ellipse_arc_with_pixmap(x * 3, y * 7, r1, r2, 0, 900,
                                            Grx.ArcStyle.OPEN, checker)
    Grx.draw_ellipse_arc(x * 3, y, r1, r2, 1800, 2700,
                         Grx.ArcStyle.CLOSED_CHORD, white)
    Grx.draw_filled_ellipse_arc(x * 3, y * 3, r1, r2, 1800, 2700,
                                Grx.ArcStyle.CLOSED_CHORD, white)
    Grx.draw_ellipse_arc_with_pixmap(x * 3, y * 5, r1, r2, 1800, 2700,
                                     Grx.ArcStyle.CLOSED_CHORD, line_opt0,
                                     checker)
    Grx.draw_filled_ellipse_arc_with_pixmap(x * 3, y * 7, r1, r2, 1800, 2700,
                                            Grx.ArcStyle.CLOSED_CHORD, checker)

    # stretchy Pac-Man
    Grx.draw_ellipse_arc(x * 5, y, r1, r2, 450, 3150,
                         Grx.ArcStyle.CLOSED_RADIUS, white)
    Grx.draw_filled_ellipse_arc(x * 5, y * 3, r1, r2, 450, 3150,
                                Grx.ArcStyle.CLOSED_RADIUS, white)
    Grx.draw_ellipse_arc_with_pixmap(x * 5, y * 5, r1, r2, 450, 3150,
                                     Grx.ArcStyle.CLOSED_RADIUS, line_opt0,
                                     checker)
    Grx.draw_filled_ellipse_arc_with_pixmap(x * 5, y * 7, r1, r2, 450, 3150,
                                            Grx.ArcStyle.CLOSED_RADIUS,
                                            checker)

    # line options
    line_opt = Grx.LineOptions()
    line_opt.color = colors[Grx.EgaColorIndex.GREEN]
    line_opt.width = 1
    line_opt.n_dash_patterns = 2
    line_opt.dash_pattern0 = 2
    line_opt.dash_pattern1 = 2
    Grx.draw_ellipse_with_options(x * 7, y, r1, r2, line_opt)
    Grx.draw_ellipse_arc_with_options(x * 7, y * 3, r1, r2, 2250, 1350,
                                      Grx.ArcStyle.CLOSED_RADIUS, line_opt)
    Grx.draw_ellipse_arc_with_pixmap(x * 7, y * 5, r1, r2, 2250, 1350,
                                     Grx.ArcStyle.CLOSED_RADIUS, line_opt,
                                     checker)

    # reusable points
    points = Grx.generate_ellipse(x * 7, y * 7, r1, r2)
    Grx.draw_polygon(points, white)