当前位置: 首页>>代码示例>>Python>>正文


Python Box.matrix方法代码示例

本文整理汇总了Python中gaphas.examples.Box.matrix方法的典型用法代码示例。如果您正苦于以下问题:Python Box.matrix方法的具体用法?Python Box.matrix怎么用?Python Box.matrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gaphas.examples.Box的用法示例。


在下文中一共展示了Box.matrix方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update_matrices

# 需要导入模块: from gaphas.examples import Box [as 别名]
# 或者: from gaphas.examples.Box import matrix [as 别名]
    def test_update_matrices(self):
        """Test updating of matrices"""
        c = Canvas()
        i = Box()
        ii = Box()
        c.add(i)
        c.add(ii, i)

        i.matrix = (1.0, 0.0, 0.0, 1.0, 5.0, 0.0)
        ii.matrix = (1.0, 0.0, 0.0, 1.0, 0.0, 8.0)

        updated = c.update_matrices([i])

        self.assertEquals(i._matrix_i2c, cairo.Matrix(1, 0, 0, 1, 5, 0))
        self.assertEquals(ii._matrix_i2c, cairo.Matrix(1, 0, 0, 1, 5, 8))
开发者ID:adrianboguszewski,项目名称:gaphas,代码行数:17,代码来源:test_canvas.py

示例2: test_update_matrices

# 需要导入模块: from gaphas.examples import Box [as 别名]
# 或者: from gaphas.examples.Box import matrix [as 别名]
def test_update_matrices():
    """Test updating of matrices"""
    c = Canvas()
    i = Box()
    ii = Box()
    c.add(i)
    c.add(ii, i)

    i.matrix = (1.0, 0.0, 0.0, 1.0, 5.0, 0.0)
    ii.matrix = (1.0, 0.0, 0.0, 1.0, 0.0, 8.0)

    updated = c.update_matrices([i])

    assert i._matrix_i2c == cairo.Matrix(1, 0, 0, 1, 5, 0)
    assert ii._matrix_i2c == cairo.Matrix(1, 0, 0, 1, 5, 8)
开发者ID:amolenaar,项目名称:gaphas,代码行数:17,代码来源:test_canvas.py

示例3: create_canvas

# 需要导入模块: from gaphas.examples import Box [as 别名]
# 或者: from gaphas.examples.Box import matrix [as 别名]
def create_canvas(canvas, title):
    # Setup drawing window
    view = GtkView()
    view.painter = DefaultPainter()
    view.canvas = canvas
    window = Gtk.Window()
    window.set_title(title)
    window.set_default_size(400, 400)
    win_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
    window.add(win_box)
    win_box.pack_start(view, True, True, 0)

    # Draw first gaphas box
    b1 = Box(60, 60)
    b1.matrix = (1.0, 0.0, 0.0, 1, 10, 10)
    canvas.add(b1)

    # Draw second gaphas box
    b2 = Box(60, 60)
    b2.min_width = 40
    b2.min_height = 50
    b2.matrix.translate(170, 170)
    canvas.add(b2)

    # Draw gaphas line
    line = Line()
    line.matrix.translate(100, 60)
    canvas.add(line)
    line.handles()[1].pos = (30, 30)

    window.show_all()
    window.connect("destroy", Gtk.main_quit)
开发者ID:amolenaar,项目名称:gaphas,代码行数:34,代码来源:simple-box.py

示例4: test_bounding_box_calculations

# 需要导入模块: from gaphas.examples import Box [as 别名]
# 或者: from gaphas.examples.Box import matrix [as 别名]
    def test_bounding_box_calculations(self):
        """
        A view created before and after the canvas is populated should contain
        the same data.
        """
        canvas = Canvas()

        window1 = gtk.Window(gtk.WINDOW_TOPLEVEL)
        view1 = GtkView(canvas=canvas)
        window1.add(view1)
        view1.realize()
        window1.show_all()

        box = Box()
        box.matrix = (1.0, 0.0, 0.0, 1, 10,10)
        canvas.add(box)

        line = Line()
        line.fyzzyness = 1
        line.handles()[1].pos = (30, 30)
        #line.split_segment(0, 3)
        line.matrix.translate(30, 60)
        canvas.add(line)

        window2 = gtk.Window(gtk.WINDOW_TOPLEVEL)
        view2 = GtkView(canvas=canvas)
        window2.add(view2)
        window2.show_all()

        # Process pending (expose) events, which cause the canvas to be drawn.
        while gtk.events_pending():
            gtk.main_iteration()

        try: 
            assert view2.get_item_bounding_box(box)
            assert view1.get_item_bounding_box(box)
            assert view1.get_item_bounding_box(box) == view2.get_item_bounding_box(box), '%s != %s' % (view1.get_item_bounding_box(box), view2.get_item_bounding_box(box))
            assert view1.get_item_bounding_box(line) == view2.get_item_bounding_box(line), '%s != %s' % (view1.get_item_bounding_box(line), view2.get_item_bounding_box(line))
        finally:
            window1.destroy()
            window2.destroy()
开发者ID:pcakapratibha,项目名称:gaphas,代码行数:43,代码来源:test_view.py

示例5: create_canvas

# 需要导入模块: from gaphas.examples import Box [as 别名]
# 或者: from gaphas.examples.Box import matrix [as 别名]
def create_canvas(c=None):
    if not c:
        c = Canvas()
    b=MyBox()
    b.min_width = 20
    b.min_height = 30
    print 'box', b
    b.matrix=(1.0, 0.0, 0.0, 1, 20,20)
    b.width = b.height = 40
    c.add(b)

    bb=Box()
    print 'box', bb
    bb.matrix=(1.0, 0.0, 0.0, 1, 10,10)
    c.add(bb, parent=b)

    fl = FatLine()
    fl.height = 50
    fl.matrix.translate(100, 100)
    c.add(fl)

    circle = Circle()
    h1, h2 = circle.handles()
    circle.radius = 20
    circle.matrix.translate(50, 100)
    c.add(circle)

    # AJM: extra boxes:
    bb = Box()
    print 'box', bb
    bb.matrix.rotate(math.pi/4.)
    c.add(bb, parent=b)
#    for i in xrange(10):
#        bb=Box()
#        print 'box', bb
#        bb.matrix.rotate(math.pi/4.0 * i / 10.0)
#        c.add(bb, parent=b)

    b = PortoBox(60, 60)
    b.min_width = 40
    b.min_height = 50
    b.matrix.translate(55, 55)
    c.add(b)

    t = UnderlineText()
    t.matrix.translate(70,30)
    c.add(t)

    t = MyText('Single line')
    t.matrix.translate(70,70)
    c.add(t)

    l = MyLine()
    c.add(l)
    l.handles()[1].pos = (30, 30)
    segment = Segment(l, view=None)
    segment.split_segment(0, 3)
    l.matrix.translate(30, 60)
    l.orthogonal = True

    off_y = 0
    for align_x in (-1, 0, 1):
        for align_y in (-1, 0, 1):
            t=MyText('Aligned text %d/%d' % (align_x, align_y),
                     align_x=align_x, align_y=align_y)
            t.matrix.translate(120, 200 + off_y)
            off_y += 30
            c.add(t)

    t=MyText('Multiple\nlines', multiline = True)
    t.matrix.translate(70,100)
    c.add(t)

    return c
开发者ID:kubaraczkowski,项目名称:gaphas,代码行数:76,代码来源:demo.py


注:本文中的gaphas.examples.Box.matrix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。