當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。