예제 #1
0
    def __init__(self,
                 width=640,
                 height=480,
                 title="Gasp",
                 background=(255, 255, 255),
                 back_end=None):
        global backend
        backend = back_end
        if isinstance(width, (int, float)) and width > 0:
            self.width = int(width)
        else:
            raise backend.GaspException(
                "invalid screen width, expected int got " + str(type(width)))
        if isinstance(height, (int, float)) and height > 0:
            self.height = int(height)
        else:
            raise backend.GaspException(
                "invalid screen height, expected int got " + str(type(height)))
        if isinstance(title, str):
            self.title = title
        else:
            raise backend.GaspException("Title must be a string")
        try:
            self.background = backend.color_convert(background)
        except:
            raise backend.GaspException("background argument is not a color")

        # backend.check_screen_atts(self)  # checks the variables
        backend.create_screen(self)
예제 #2
0
파일: api.py 프로젝트: tarzenda/gasp
 def __init__(self, pos, color=(0,0,0), size=1):
     try:
         self.center = make_it_a_point(center)
     except: raise backend.GaspException("center is not in (x,y) format")
     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 is not a number")
     self.key = time.time()*random.random()
     self.on_screen = False
     screen.action_objects.put([["plot",self],"new object"])
     screen.objects.append(self)
예제 #3
0
파일: api.py 프로젝트: tarzenda/gasp
 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)
예제 #4
0
파일: api.py 프로젝트: tarzenda/gasp
 def __init__(self, start, end, color=(0,0,0),thickness=1):
     try:
         self.start = make_it_a_point(start)
     except: raise backend.GaspException("start is not is (x,y) format")
     try:
         self.end = make_it_a_point(end)
     except: raise backend.GaspException("end is not is (x,y) format")
     self.center = make_it_a_point(((start[0]+end[0])/2,(start[1]+end[1])/2))
     try:
         self.color = backend.color_convert(color)
     except: raise backend.GaspException("color argument is not a color")
     self.thickness=thickness
     self.key = time.time()*random.random()
     self.on_screen = False
     screen.action_objects.put([["line",self],"new object"])
     screen.objects.append(self)
예제 #5
0
파일: api.py 프로젝트: tarzenda/gasp
 def __init__(self, center, filled=False, color=(0,0,0), thickness=1):
     try:
         self.center = make_it_a_point(center)
     except: raise backend.GaspException("center is not in (x,y) format")
     if isinstance(filled,bool):
         self.filled = filled
     else: raise backend.GaspException("filled argument must be a boolean")
     try:
         self.color = backend.color_convert(color)
     except: raise backend.GaspException("color argument is not a color")
     if isinstance(thickness,(int,float)):
         self.thickness = thickness
     else:
         raise backend.GaspException("thickness must be an int")
     self.rot = 0
     self.key = time.time()*random.random()
예제 #6
0
 def __init__(self, pos, color=(0, 0, 0), size=1):
     try:
         self.center = make_it_a_point(center)
     except:
         raise backend.GaspException("center is not in (x,y) format")
     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 is not a number")
     self.key = time.time() * random.random()
     self.on_screen = False
     screen.action_objects.put([["plot", self], "new object"])
     screen.objects.append(self)
예제 #7
0
 def __init__(self, center, filled=False, color=(0, 0, 0), thickness=1):
     try:
         self.center = make_it_a_point(center)
     except:
         raise backend.GaspException("center is not in (x,y) format")
     if isinstance(filled, bool):
         self.filled = filled
     else:
         raise backend.GaspException("filled argument must be a boolean")
     try:
         self.color = backend.color_convert(color)
     except:
         raise backend.GaspException("color argument is not a color")
     if isinstance(thickness, (int, float)):
         self.thickness = thickness
     else:
         raise backend.GaspException("thickness must be an int")
     self.rot = 0
     self.key = time.time() * random.random()
예제 #8
0
 def __init__(self, start, end, color=(0, 0, 0), thickness=1):
     try:
         self.start = make_it_a_point(start)
     except:
         raise backend.GaspException("start is not is (x,y) format")
     try:
         self.end = make_it_a_point(end)
     except:
         raise backend.GaspException("end is not is (x,y) format")
     self.center = make_it_a_point(
         ((start[0] + end[0]) / 2, (start[1] + end[1]) / 2))
     try:
         self.color = backend.color_convert(color)
     except:
         raise backend.GaspException("color argument is not a color")
     self.thickness = thickness
     self.key = time.time() * random.random()
     self.on_screen = False
     screen.action_objects.put([["line", self], "new object"])
     screen.objects.append(self)
예제 #9
0
파일: api.py 프로젝트: tarzenda/gasp
    def __init__(self, width=640, height=480,
                 title="Gasp", background=(255,255,255), back_end=None):
        global backend
        backend = back_end
        if isinstance(width,(int,float)) and width > 0:
            self.width = int(width)
        else:
            raise backend.GaspException("invalid screen width, expected int got " + str(type(width)))
        if isinstance(height,(int,float)) and height > 0:
            self.height = int(height)
        else:
            raise backend.GaspException("invalid screen height, expected int got " + str(type(height)))
        if isinstance(title,str):
            self.title = title
        else:
            raise backend.GaspException("Title must be a string")
        try:
            self.background = backend.color_convert(background)
        except:
            raise backend.GaspException("background argument is not a color")

        # backend.check_screen_atts(self)  # checks the variables
        backend.create_screen(self)
예제 #10
0
 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)