コード例 #1
0
ファイル: Displays.py プロジェクト: bopopescu/BCPy2000-1
def init_screen(b, **kwargs):
    """
	Initialize the drawing window, via screen.setup(), to have the
	dimensions specified in box object <b>.
	"""###
    screen = CurrentRenderer.get_screen()
    if b == None:
        b = Boxes.box(rect=(0, 0, screen.size[0], screen.size[1]))
    else:
        b = Boxes.box(b)  # makes a copy
        for k in [
                'left', 'top', 'right', 'bottom', 'width', 'height', 'x', 'y'
        ]:
            v = kwargs.pop(k, None)
            if v != None: setattr(b, k, v)
        b.width = int(round(b.width))
        b.height = int(round(b.height))
        b.left = int(round(b.left))
        b.top = int(round(b.top))
        screen.setup(width=b.width,
                     height=b.height,
                     left=b.left,
                     top=monitor(0).top - b.top,
                     **kwargs)
    b.sticky = True
    b.anchor = 'bottom left'
    b.position = (0, 0)
    if b.internal == None:
        b.internal = b.__class__(rect=(-1, -1, +1, +1), sticky=False)
    else:
        b.internal = b.__class__(b.internal)  # makes a copy
    screen.__dict__['coords'] = b
    return b
コード例 #2
0
def init_screen(b, **kwargs):
    """
	Initialize the drawing window, via screen.setup(), to have the
	dimensions specified in box object <b>.
	"""  ###
    screen = CurrentRenderer.get_screen()
    if b == None:
        b = Boxes.box(rect=(0, 0, screen.size[0], screen.size[1]))
    else:
        b = Boxes.box(b)  # makes a copy
        for k in ["left", "top", "right", "bottom", "width", "height", "x", "y"]:
            v = kwargs.pop(k, None)
            if v != None:
                setattr(b, k, v)
        b.width = int(round(b.width))
        b.height = int(round(b.height))
        b.left = int(round(b.left))
        b.top = int(round(b.top))
        screen.setup(width=b.width, height=b.height, left=b.left, top=monitor(0).top - b.top, **kwargs)
    b.sticky = True
    b.anchor = "bottom left"
    b.position = (0, 0)
    if b.internal == None:
        b.internal = b.__class__(rect=(-1, -1, +1, +1), sticky=False)
    else:
        b.internal = b.__class__(b.internal)  # makes a copy
    screen.__dict__["coords"] = b
    return b
コード例 #3
0
def PolygonTexture(frame=None,
                   vertices=((0.0, 1.0), (1.0, 1.0), (0.5, 0.0)),
                   color=(0, 0, 0),
                   anchor=None,
                   position=None,
                   size=None,
                   **kwargs):
    if frame == None:
        if size == None: size = (100, 100)
        if position == None: position = (50, 50)
        if anchor == None: anchor = 'center'
        frame = Boxes.box(size=size, position=position, anchor=anchor)
    else:
        if isinstance(frame, (list, tuple)):
            if len(frame) == 2: frame = [0, 0] + list(frame)
            frame = Boxes.box(rect=frame, sticky=True)
            if anchor != None: frame.anchor = anchor
        if size == None: size = frame.size
        if anchor == None: anchor = frame.anchor
        if position == None: position = frame.position
        frame = frame.copy()

    if len(color) >= 4: alpha = color[3]
    else: alpha = 1.0
    mask = (255, 255, 255, int(round(255.0 * alpha)))
    csize = (int(round(size[0])), int(round(size[1])))

    if isinstance(vertices, (float, int)):
        vertices = [i / float(vertices) for i in range(int(vertices) + 1)[:-1]]
    if False not in [isinstance(i, (float, int)) for i in vertices]:
        from math import cos, sin, pi
        vertices = [(0.5 + 0.5 * cos(2 * pi * a), 0.5 + 0.5 * sin(2 * pi * a))
                    for a in vertices]

    # map from source coordinates (default to lowerleft-upward normalized)
    # to upperleft-downward pixel coordinates
    if frame.internal == None:
        frame.internal = Boxes.box(left=0.0, right=1.0, bottom=0.0, top=1.0)
    frame.internal.bottom, frame.internal.top = frame.internal.top, frame.internal.bottom
    frame.anchor, frame.position, frame.size = 'lowerleft', (0, 0), csize
    vertices = [tuple(frame.map(v)) for v in vertices]

    canvas = Image.new("RGBA", csize, (0, 0, 0, 0))
    draw = ImageDraw.Draw(canvas)
    draw.polygon(vertices, fill=mask, outline=None)
    from CurrentRenderer import VisualStimuli
    return VisualStimuli.ImageStimulus(texture=canvas,
                                       size=size,
                                       anchor=anchor,
                                       position=position,
                                       color=color[:3],
                                       **kwargs)
コード例 #4
0
 def monitors():
     try:
         import pygame
     except ImportError:
         pass
     else:
         try:
             pygame.init()
             a = pygame.display.Info()
             return [Boxes.box(rect=(0, 0, a.current_w, a.current_h))]
         except:
             print "failed to get screen size using pygame.display.Info()"
     return [Boxes.box(rect=(0, 0, 640, 480))]
コード例 #5
0
ファイル: Displays.py プロジェクト: bopopescu/BCPy2000-1
 def monitors():
     try:
         import pygame
     except ImportError:
         pass
     else:
         try:
             pygame.init()
             a = pygame.display.Info()
             return [Boxes.box(rect=(0, 0, a.current_w, a.current_h))]
         except:
             print "failed to get screen size using pygame.display.Info()"
     return [Boxes.box(rect=(0, 0, 640, 480))]
コード例 #6
0
    def __init__(self, handle):
        super(PeterActivity, self).__init__(handle)

        # Build the activity toolbar.
        toolbox = activity.ActivityToolbox(self)
        activity_toolbar = toolbox.get_activity_toolbar()
        activity_toolbar.keep.props.visible = False
        activity_toolbar.share.props.visible = False

        toolbox.show()
        self.set_toolbox(toolbox)

        # Create the game instance.
        self.game = Boxes.Boxes()

        # Build the Pygame canvas.
        self._pygamecanvas = \
            sugargame.canvas.PygameCanvas(self)
        # Note that set_canvas implicitly calls
        # read_file when resuming from the Journal.
        self.set_canvas(self._pygamecanvas)
        self.game.canvas=self._pygamecanvas

        # Start the game running.
        self._pygamecanvas.run_pygame(self.game.run)
コード例 #7
0
        def monitors():
            """
			Returns a list of AppTools.Boxes.box objects, one for each of the
			displays attached. 
			"""  ###
            m = [Boxes.box(rect=x[2]) for x in win32api.EnumDisplayMonitors()]
            rebase = m[0].height
            for i in range(1, len(m)):
                m[i].bottom, m[i].top = rebase - m[i].top, rebase - m[i].bottom
            return m
コード例 #8
0
ファイル: Displays.py プロジェクト: bopopescu/BCPy2000-1
        def monitors():
            """
			Returns a list of AppTools.Boxes.box objects, one for each of the
			displays attached. 
			"""###
            m = [Boxes.box(rect=x[2]) for x in win32api.EnumDisplayMonitors()]
            rebase = m[0].height
            for i in range(1, len(m)):
                m[i].bottom, m[i].top = rebase - m[i].top, rebase - m[i].bottom
            return m
コード例 #9
0
def PolygonTexture(frame=None, vertices=((0.0,1.0), (1.0,1.0), (0.5,0.0)), color=(0,0,0), anchor=None, position=None, size=None, **kwargs):
	if frame==None:
		if size == None: size = (100,100)
		if position == None: position = (50,50)
		if anchor == None: anchor = 'center'
		frame = Boxes.box(size=size, position=position, anchor=anchor)
	else:
		if isinstance(frame, (list,tuple)):
			if len(frame)==2: frame = [0,0] + list(frame)
			frame = Boxes.box(rect=frame, sticky=True)
			if anchor != None: frame.anchor = anchor
		if size==None: size = frame.size
		if anchor==None: anchor = frame.anchor
		if position==None: position = frame.position
		frame = frame.copy()
		
	if len(color) >= 4: alpha = color[3]
	else: alpha = 1.0
	mask = (255,255,255,int(round(255.0*alpha)))
	csize = (int(round(size[0])), int(round(size[1])))

	if isinstance(vertices, (float,int)): vertices = [i/float(vertices) for i in range(int(vertices)+1)[:-1]]
	if False not in [isinstance(i, (float,int)) for i in vertices]:
		from math import cos, sin, pi
		vertices = [(0.5+0.5*cos(2*pi*a), 0.5+0.5*sin(2*pi*a)) for a in vertices]
		
	# map from source coordinates (default to lowerleft-upward normalized)
	# to upperleft-downward pixel coordinates
	if frame.internal == None: frame.internal = Boxes.box(left=0.0,right=1.0,bottom=0.0,top=1.0)
	frame.internal.bottom,frame.internal.top = frame.internal.top,frame.internal.bottom
	frame.anchor, frame.position, frame.size = 'lowerleft', (0,0), csize
	vertices = [tuple(frame.map(v)) for v in vertices]
	
	canvas = Image.new("RGBA", csize, (0,0,0,0))
	draw = ImageDraw.Draw(canvas)
	draw.polygon(vertices, fill=mask, outline=None)
	from CurrentRenderer import VisualStimuli
	return VisualStimuli.ImageStimulus(texture=canvas, size=size, anchor=anchor, position=position, color=color[:3], **kwargs)
コード例 #10
0
 def monitors():
     return [Boxes.box(rect=(0, 0, GetSystemMetrics(0), GetSystemMetrics(1)))]
コード例 #11
0
ファイル: Displays.py プロジェクト: bopopescu/BCPy2000-1
 def monitors():
     return [
         Boxes.box(rect=(0, 0, GetSystemMetrics(0),
                         GetSystemMetrics(1)))
     ]