def move_to(self, pos): if self.on_screen: pos = backend.flip_coords(pos) x, y = pos[0] - self.center.x, self.center.y - pos[1] self.topleft = (self.topleft[0] + x, self.topleft[1] - y) self.center = Point(self.center.x + x, self.center.y - y) else: move_to(self, pos)
def move_to(self,pos): if self.on_screen: pos = backend.flip_coords(pos) x,y = pos[0]-self.center.x,self.center.y-pos[1] self.topleft = (self.topleft[0]+x,self.topleft[1]-y) self.center = Point(self.center.x+x,self.center.y-y) else: move_to(self,pos)
def draw(self,context): context.save() x,y = backend.flip_coords(self.topleft) context.translate(x,y-self.surface.get_height()) if self.rot != 0: context.translate(self.surface.get_width()/2,self.surface.get_height()/2) context.rotate(self.rot) context.translate(-1*self.surface.get_width()/2,-1*self.surface.get_height()/2) context.set_source_surface(self.surface) context.paint() context.restore()
def draw(self, context): context.save() x, y = backend.flip_coords(self.topleft) context.translate(x, y - self.surface.get_height()) if self.rot != 0: context.translate(self.surface.get_width() / 2, self.surface.get_height() / 2) context.rotate(self.rot) context.translate(-1 * self.surface.get_width() / 2, -1 * self.surface.get_height() / 2) context.set_source_surface(self.surface) context.paint() context.restore()
def __init__(self, file_path, center, width=0, height=0): self.path_name = file_path try: self.center = Point(backend.flip_coords(center)) except: raise backend.GaspException("center argument is not in (x,y) format") if isinstance(width,(int,float)): self.width = width else: raise backend.GaspException("width must be an int or a float") if isinstance(height,(int,float)): self.height = height else: raise backend.GaspException("height must be an int or a float") self.key = time.time()*random.random() self.on_screen = False screen.action_objects.put([["image",self],"new object"]) screen.objects.append(self)
def __init__(self, text, pos, color=(0,0,0), size=12): if isinstance(text, str): self.text = text else: raise backend.GaspException("Text must take a string argument") try: self.color = backend.color_convert(color) except: raise backend.GaspException("color argument is not a color") if isinstance(size, (int,float)): self.size = size else: raise backend.GaspException("size argument must be an int or float") try: self.pos = backend.flip_coords(pos) except: raise backend.GaspException("pos argument is not in the (x,y) format") self.key = time.time()*random.random() self.on_screen = False screen.action_objects.put([["text",self],"new object"]) screen.objects.append(self)
def __init__(self, file_path, center, width=0, height=0): self.path_name = file_path try: self.center = Point(backend.flip_coords(center)) except: raise backend.GaspException( "center argument is not in (x,y) format") if isinstance(width, (int, float)): self.width = width else: raise backend.GaspException("width must be an int or a float") if isinstance(height, (int, float)): self.height = height else: raise backend.GaspException("height must be an int or a float") self.key = time.time() * random.random() self.on_screen = False screen.action_objects.put([["image", self], "new object"]) screen.objects.append(self)
def __init__(self, text, pos, color=(0, 0, 0), size=12): if isinstance(text, str): self.text = text else: raise backend.GaspException("Text must take a string argument") try: self.color = backend.color_convert(color) except: raise backend.GaspException("color argument is not a color") if isinstance(size, (int, float)): self.size = size else: raise backend.GaspException( "size argument must be an int or float") try: self.pos = backend.flip_coords(pos) except: raise backend.GaspException( "pos argument is not in the (x,y) format") self.key = time.time() * random.random() self.on_screen = False screen.action_objects.put([["text", self], "new object"]) screen.objects.append(self)
def mouse_position(): """ Returns a Point() at the mouse's current position """ pos = backend.mouse_pos() return backend.flip_coords((int(pos[0]),int(pos[1])))
def move_to(self,pos): if self.on_screen: self.pos = backend.flip_coords(pos) else: move_to(self,pos)
def mouse_position(): """ Returns a Point() at the mouse's current position """ pos = backend.mouse_pos() return backend.flip_coords((int(pos[0]), int(pos[1])))
def move_to(self, pos): if self.on_screen: self.pos = backend.flip_coords(pos) else: move_to(self, pos)