コード例 #1
0
ファイル: fiecanvas.py プロジェクト: cstein/fmo-ie-analyzer
 def __init__(self,parent,dpi=100.0):
     Canvas.__init__(self,parent,dpi)
     self.has_data = False
     self.sqplot = None
     self.cb = None
     self.colormap = customcolormap.make_colormap("mymap", 1.0, 0.001, 10)
     self.cmaplimits = 2.0
コード例 #2
0
ファイル: simpleCanvas.py プロジェクト: wangdyna/wxPython
    def __init__(self, renderer, max_update_delay=0.2, *args, **keys):
        ''' Inits this canvas.
            Things setupped: background color, default camera, node factory,
            model/view/primitve renderer registries, adapter registry and
            render/update policies.
        '''

        if 'name' not in keys:
            keys['name'] = 'unnamed canvas'

        self.renderer = renderer

        if 'backgroundColor' in keys:
            self.backgroundColor = keys['backgroundColor']
            del keys['backgroundColor']
        else:
            self.backgroundColor = None

        if 'renderPolicy' in keys:
            self.renderPolicy = keys['renderPolicy']
            del keys['renderPolicy']
        else:
            #self.renderPolicy = DefaultRenderPolicy()
            self.renderPolicy = CullingRenderPolicy()

        Canvas.__init__(self, self.renderer, False, None, None, None, None,
                        observables.ObservableLinearTransform2D(), *args,
                        **keys)

        self.camera = observables.ObservableCamera(
            observables.ObservableLinearTransform2D(), name='default camera')
        self.addChild(self.camera)

        self.model_kinds = [
            'Rectangle', 'RoundedRectangle', 'Circle', 'Ellipse', 'Arc',
            'Text', 'Line', 'LineLength', 'Lines', 'LinesList', 'LineSegments',
            'LineSegmentsSeparate', 'Bitmap', 'CubicSpline', 'QuadraticSpline',
            'Polygon', 'PolygonList', 'Arrow', 'AngleArrow'
        ]
        self.primitive_kinds = [
            'Rectangle', 'RoundedRectangle', 'Ellipse', 'Arc', 'Text',
            'LinesList', 'LineSegmentsSeparate', 'Bitmap', 'CubicSpline',
            'QuadraticSpline', 'PolygonList', 'Arrow'
        ]

        self._setupRegistries()
        self._setupNodeFactory()
        self._setupAdapters()

        if 'updatePolicy' in keys:
            self.updatePolicy = keys['updatePolicy']
            del keys['updatePolicy']
        else:
            self.updatePolicy = DefaultUpdatePolicy(self, max_update_delay)

        self.controllers = []

        self.subscribe(self.onDirty, 'attribChanged')
コード例 #3
0
ファイル: games.py プロジェクト: hooperw/aima-python
 def __init__(self, varname, player_1='human', player_2='random', id=None, width=300, height=300):
     valid_players = ('human', 'random', 'alphabeta')
     if player_1 not in valid_players or player_2 not in valid_players:
         raise TypeError("Players must be one of {}".format(valid_players))
     Canvas.__init__(self, varname, id, width, height)
     self.ttt = TicTacToe()
     self.state = self.ttt.initial
     self.turn = 0
     self.strokeWidth(5)
     self.players = (player_1, player_2)
     self.draw_board()
     self.font("Ariel 30px")
コード例 #4
0
 def __init__(self, varname, player_1='human', player_2='random', id=None, width=300, height=300):
     valid_players = ('human', 'random', 'alphabeta')
     if player_1 not in valid_players or player_2 not in valid_players:
         raise TypeError("Players must be one of {}".format(valid_players))
     Canvas.__init__(self, varname, id, width, height)
     self.ttt = TicTacToe()
     self.state = self.ttt.initial
     self.turn = 0
     self.strokeWidth(5)
     self.players = (player_1, player_2)
     self.draw_board()
     self.font("Ariel 30px")
コード例 #5
0
ファイル: clock.py プロジェクト: typerlc/ankice-deps
 def __init__(self, parent):
     Canvas.__init__(self, parent)
     self.pen_cadre_1 = Pen((0,0,250), 2)
     self.pen_cadre_2 = Pen(width=3)
     self.pen_aiguille_1 = Pen(width=6)
     self.pen_aiguille_2 = Pen(width=5)
     self.pen_aiguille_3 = Pen(width=2, color=(255,0,0))
     
     self.bind(size=self.on_size)
     #self._draw_cadre()
     self.aiguille_draw_op = CombineDrawOperation(self, [])
     self.scheduler = Thread(target=self.schedule)
     self.scheduler.start()
コード例 #6
0
ファイル: simpleCanvas.py プロジェクト: acarl123/wxPython
    def __init__(self, renderer, max_update_delay = 0.2, *args, **keys):
        ''' Inits this canvas.
            Things setupped: background color, default camera, node factory,
            model/view/primitve renderer registries, adapter registry and
            render/update policies.
        '''
        
        if 'name' not in keys:
            keys['name'] = 'unnamed canvas'

        self.renderer = renderer

        if 'backgroundColor' in keys:
            self.backgroundColor = keys['backgroundColor']
            del keys['backgroundColor']
        else:
            self.backgroundColor = None
        
        if 'renderPolicy' in keys:
            self.renderPolicy = keys['renderPolicy']
            del keys['renderPolicy']
        else:
            #self.renderPolicy = DefaultRenderPolicy()
            self.renderPolicy = CullingRenderPolicy()

        Canvas.__init__(self, self.renderer, False, None, None, None, None, observables.ObservableLinearTransform2D(), *args, **keys)
               
        self.camera = observables.ObservableCamera( observables.ObservableLinearTransform2D(), name = 'default camera' )
        self.addChild( self.camera )
        
        self.model_kinds = [ 'Rectangle', 'RoundedRectangle', 'Circle', 'Ellipse', 'Arc', 'Text', 'Line', 'LineLength', 'Lines', 'LinesList', 'LineSegments', 'LineSegmentsSeparate', 'Bitmap', 'CubicSpline', 'QuadraticSpline', 'Polygon', 'PolygonList', 'Arrow', 'AngleArrow' ]
        self.primitive_kinds = [ 'Rectangle', 'RoundedRectangle', 'Ellipse', 'Arc', 'Text', 'LinesList', 'LineSegmentsSeparate', 'Bitmap', 'CubicSpline', 'QuadraticSpline', 'PolygonList', 'Arrow' ]

        self._setupRegistries()
        self._setupNodeFactory()
        self._setupAdapters()

        if 'updatePolicy' in keys:
            self.updatePolicy = keys['updatePolicy']
            del keys['updatePolicy']
        else:
            self.updatePolicy = DefaultUpdatePolicy( self, max_update_delay )

        self.controllers = []
        
        self.subscribe( self.onDirty, 'attribChanged' )
コード例 #7
0
 def __init__(self,parent,dpi=100.0):
   Canvas.__init__(self,parent,dpi)
   self.pos = None
   self.vel = None
コード例 #8
0
        The maze is represented by a matrix with `height` rows and `width` columns,
        each cell in the maze has 4 possible states:

        0: it's a wall
        1: it's in the tree
        2: it's in the path
        3: it's filled (this will not be used until the depth-first search animation)

        Initially all cells are walls. Adjacent cells in the maze are spaced out by one cell.

        mask: must be None or a white/black image instance of PIL's Image class.
              This mask image must preserve the connectivity of the graph,
              otherwise the program will not terminate.
        """
        Canvas.__init__(self, width, height, scale, min_bits, palette, loop)

        def get_mask_pixel(cell):
            if mask is None:
                return True
            else:
                return mask.getpixel(cell) == 255

        self.cells = []
        for y in range(margin, height - margin, 2):
            for x in range(margin, width - margin, 2):
                if get_mask_pixel((x, y)):
                    self.cells.append((x, y))

        def neighborhood(cell):
            x, y = cell
コード例 #9
0
ファイル: console.py プロジェクト: mwerezak/ascii
 def __init__(self, handle):
     Canvas.__init__(self,0,0,handle)
コード例 #10
0
ファイル: cairo_canvas.py プロジェクト: msarch/py
 def __init__(self, sink, enable_cairo_queue=True):
     Canvas.__init__(self, sink)
     self.size = None
     self.enable_cairo_queue = enable_cairo_queue
     self.reset_canvas()
コード例 #11
0
ファイル: cairo_canvas.py プロジェクト: felipesanches/shoebot
 def __init__(self, sink):
     Canvas.__init__(self, sink)
     self.size = None
コード例 #12
0
ファイル: cairo_canvas.py プロジェクト: msarch/py
 def __init__(self, sink, enable_cairo_queue = True):
     Canvas.__init__(self, sink)
     self.size = None
     self.enable_cairo_queue = enable_cairo_queue
     self.reset_canvas()
コード例 #13
0
ファイル: wilson.py プロジェクト: wutongfei/pywonderland
    def __init__(self,
                 width,
                 height,
                 margin,
                 scale,
                 min_bits,
                 palette,
                 loop=0,
                 mask=None):
        """
        width, height: size of the maze, should both be odd numbers.
        margin: size of the border of the maze.

        The maze is represented by a matrix with `height` rows and `width` columns,
        each cell in the maze has 4 possible states:

        0: it's a wall
        1: it's in the tree
        2: it's in the path
        3: it's filled (this will not be used until the depth-first search animation)

        Initially all cells are walls. Adjacent cells in the maze are spaced out by one cell.

        mask: must be None or a white/black image instance of PIL's Image class.
              This mask image must preserve the connectivity of the graph,
              otherwise the program will not terminate.
        """
        Canvas.__init__(self, width, height, scale, min_bits, palette, loop)

        def get_mask_pixel(cell):
            if mask is None:
                return True
            else:
                return mask.getpixel(cell) == 255

        self.cells = []
        for y in range(margin, height - margin, 2):
            for x in range(margin, width - margin, 2):
                if get_mask_pixel((x, y)):
                    self.cells.append((x, y))

        def neighborhood(cell):
            x, y = cell
            neighbors = []
            if x >= 2 + margin and get_mask_pixel((x - 2, y)):
                neighbors.append((x - 2, y))
            if y >= 2 + margin and get_mask_pixel((x, y - 2)):
                neighbors.append((x, y - 2))
            if x <= width - 3 - margin and get_mask_pixel((x + 2, y)):
                neighbors.append((x + 2, y))
            if y <= height - 3 - margin and get_mask_pixel((x, y + 2)):
                neighbors.append((x, y + 2))
            return neighbors

        self.graph = {v: neighborhood(v) for v in self.cells}
        # we will look for a path between this start and end.
        self.start = (margin, margin)
        self.end = (width - margin - 1, height - margin - 1)
        self.path = []  # a list holds the path in the loop erased random walk.
        # map distance to color indices.
        self.dist_to_color = lambda d: max(d % (1 << min_bits), 3)
コード例 #14
0
ファイル: cairo_canvas.py プロジェクト: arvindmeena01/shoebot
 def __init__(self, sink):
     Canvas.__init__(self, sink)
     self.size = None