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


Python graphics.CanvasContext类代码示例

本文整理汇总了Python中nodebox.graphics.CanvasContext的典型用法代码示例。如果您正苦于以下问题:Python CanvasContext类的具体用法?Python CanvasContext怎么用?Python CanvasContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: size

 def size(self, width, height):
     CanvasContext.size(self, width, height)
     # To keep the WIDTH and HEIGHT properties up to date in the executing script,
     # the Context object must have access to its namespace. Normally, we passed this
     # during construction time.
     self._ns["WIDTH"] = width
     self._ns["HEIGHT"] = height
开发者ID:Banbury,项目名称:nodebox,代码行数:7,代码来源:__init__.py

示例2: font

 def font(self, fontname=None, fontsize=None):
     if fontname is not None and fontsize is not None:
         return CanvasContext.font(self, fontname, fontsize)
     elif fontname is not None:
         return CanvasContext.font(self, fontname)
     elif fontsize is not None:
         CanvasContext.fontsize(self, fontsize)
     return CanvasContext.font(self)
开发者ID:Banbury,项目名称:nodebox,代码行数:8,代码来源:__init__.py

示例3: rect

 def rect(self, x, y, width, height, roundness=0.0, draw=True, **kwargs):
     if roundness == 0:
         p = CanvasContext.rect(self, x, y, width, height, Boolean(draw))
     else:
         rw = roundness * width * 0.5
         rh = roundness * height * 0.5
         p = CanvasContext.rect(self, x, y, width, height, rw, rh, Boolean(draw))
     self._setAttributesFromKwargs(p, **kwargs)
     return p
开发者ID:Banbury,项目名称:nodebox,代码行数:9,代码来源:__init__.py

示例4: __init__

 def __init__(self, canvas=None, ns=None):
     args = canvas is not None and [canvas] or []
     CanvasContext.__init__(self, *args)
     if ns is None:
         ns = {}
     self._ns = ns
     
     # todo: better way to handle mouse events
     self._ns["MOUSEX"] = 0
     self._ns["MOUSEY"] = 0
     self._ns["mousedown"] = False
开发者ID:Banbury,项目名称:nodebox,代码行数:11,代码来源:__init__.py

示例5: text

 def text(self, txt, x, y, width=0, height=0, outline=False, draw=True, **kwargs):
     if outline:
         t = CanvasContext.text(self, unicode(txt), x, y, width, height, Boolean(False))
         p = t.path
         self._setAttributesFromKwargs(p, **kwargs)
         if draw:
             self.addPath(p)
         return p
     else:
         t = CanvasContext.text(self, unicode(txt), x, y, width, height, Boolean(draw))
         self._setAttributesFromKwargs(t, **kwargs)
         return t
开发者ID:Banbury,项目名称:nodebox,代码行数:12,代码来源:__init__.py

示例6: imagesize

 def imagesize(self, path, data=None):
     if data is not None:
         from nodebox.graphics import Image
         arg = Image.fromData(data).awtImage
     else:
         arg = path
     return CanvasContext.imagesize(self, arg)
开发者ID:Banbury,项目名称:nodebox,代码行数:7,代码来源:__init__.py

示例7: image

 def image(self, path, x, y, width=None, height=None, alpha=1.0, data=None, draw=True, **kwargs):
     if data is not None:
         from nodebox.graphics import Image
         arg = Image.fromData(data).awtImage
     else:
         arg = path
     img = CanvasContext.image(self, arg, x, y, width, height, alpha, Boolean(draw))
     # todo: handle data and kwargs
     return img
开发者ID:Banbury,项目名称:nodebox,代码行数:9,代码来源:__init__.py

示例8: arrow

 def arrow(self,
           x,
           y,
           width=100,
           type=CanvasContext.NORMAL,
           draw=True,
           **kwargs):
     p = CanvasContext.arrow(self, x, y, width, type, Boolean(draw))
     self._setAttributesFromKwargs(p, **kwargs)
     return p
开发者ID:alessandrostone,项目名称:nodebox,代码行数:10,代码来源:__init__.py

示例9: findpath

    def findpath(self, points, curvature=1.0):
        # The list of points consists of Point objects,
        # but it shouldn't crash on something straightforward
        # as someone supplying a list of (x,y)-tuples.

        from types import TupleType
        for i, pt in enumerate(points):
            if type(pt) == TupleType:
                points[i] = Point(pt[0], pt[1])
        return CanvasContext.findpath(self, points, curvature)
开发者ID:Banbury,项目名称:nodebox,代码行数:10,代码来源:__init__.py

示例10: star

 def star(self,
          startx,
          starty,
          points=20,
          outer=100,
          inner=50,
          draw=True,
          **kwargs):
     p = CanvasContext.star(self, startx, starty, points, outer, inner,
                            Boolean(draw))
     self._setAttributesFromKwargs(p, **kwargs)
     return p
开发者ID:alessandrostone,项目名称:nodebox,代码行数:12,代码来源:__init__.py

示例11: beginpath

 def beginpath(self, x=None, y=None):
     if x != None and y != None:
         CanvasContext.beginpath(self, x, y)
     else:
         CanvasContext.beginpath(self)
开发者ID:Banbury,项目名称:nodebox,代码行数:5,代码来源:__init__.py

示例12: color

 def color(self, *args):
     if len(args) == 1 and isinstance(args[0], tuple):
         args = args[0]
     return CanvasContext.color(self, *args)
开发者ID:Banbury,项目名称:nodebox,代码行数:4,代码来源:__init__.py

示例13: line

 def line(self, x1, y1, x2, y2, draw=True, **kwargs):
     p = CanvasContext.line(self, x1, y1, x2, y2, Boolean(draw))
     self._setAttributesFromKwargs(p, **kwargs)
     return p
开发者ID:Banbury,项目名称:nodebox,代码行数:4,代码来源:__init__.py

示例14: stroke

 def stroke(self, *args):
     if len(args) == 1 and isinstance(args[0], tuple):
         args = args[0]
     return CanvasContext.stroke(self, *args)
开发者ID:Banbury,项目名称:nodebox,代码行数:4,代码来源:__init__.py

示例15: ellipse

 def ellipse(self, x, y, width, height, draw=True, **kwargs):
     p = CanvasContext.ellipse(self, x, y, width, height, Boolean(draw))
     self._setAttributesFromKwargs(p, **kwargs)
     return p
开发者ID:Banbury,项目名称:nodebox,代码行数:4,代码来源:__init__.py


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