Esempio n. 1
0
 def keep_drawing(self, x, y, dx, dy):
     self.x2, self.y2 = x, y
     self.rot = math.degrees(-math.atan2(y-self.start_y, x-self.start_x))
     self.scale = math.sqrt((x-self.start_x)*(x-self.start_x)+(y-self.start_y)*(y-self.start_y))
     self.scale /= self.this_stamp.width//2
     graphics.set_color(1,1,1,1)
     draw.image(self.canvas_pre,graphics.canvas_x,graphics.canvas_y)
     self.draw_stamp(x, y)
Esempio n. 2
0
 def draw(self):
     """Internal use only."""
     color = (1,1,1,1)
     if self.parent_group != None and self.selected: color = (0.8, 0.8, 0.8, 1)
     if self.pressed: color = (0.7, 0.7, 0.7, 1)
     draw.set_color(color=color)
     draw.image(self.image,self.x,self.y)
     draw.set_color(1,1,1,1)
     draw.label(self.label)
     if self.more_draw != None: self.more_draw()
Esempio n. 3
0
 def draw(self):
     """Render the image if it has not been rendered yet. Just draw the image if it has."""
     if self.rendered:
         graphics.set_color(1,1,1,1)
         draw.image(self.image,self.x,self.y)
     else:
         self.rendered = True
         self.draw_initial()
     graphics.set_color(0,0,0,1)
     graphics.set_line_width(1)
     draw.rect_outline(self.x,self.y,self.x+self.width,self.y+self.height)
Esempio n. 4
0
	def draw_image(self, image, pos, angle=0, color=None):

		x = (pos[0] - self.origin[0]) * self.scale
		y = (pos[1] - self.origin[1]) * self.scale

		draw.image(
				self.screen,
				image,
				(x,y),
				angle=angle,
				color=color )
Esempio n. 5
0
 def draw_stamp(self, x, y):
     pyglet.gl.glColor4f(1,1,1,1)
     pyglet.gl.glEnable(pyglet.gl.GL_BLEND)
     pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA, pyglet.gl.GL_ONE_MINUS_SRC_ALPHA)
     if self.mode == MOVE:
         self.this_stamp.blit(x, y)
         draw.image(self.this_stamp, x, y)
     else:
         pyglet.gl.glPushMatrix()
         pyglet.gl.glTranslatef(self.start_x, self.start_y, 0)
         pyglet.gl.glPushMatrix()
         if self.mode == ROTATESCALE: pyglet.gl.glRotatef(self.rot, 0, 0, -1)
         pyglet.gl.glScalef(self.scale, self.scale, 1)
         self.this_stamp.blit(0, 0)
         pyglet.gl.glPopMatrix()
         pyglet.gl.glPopMatrix()
     graphics.call_twice(pyglet.gl.glDisable, pyglet.gl.GL_BLEND)
Esempio n. 6
0
 def draw(self):
     """Internal use only."""
     if not self.visible: return
     if self.image != None:
         color = (1,1,1,1)
         if self.parent_group != None and self.selected: color = (0.8, 0.8, 0.8, 1)
         if self.pressed: color = (0.7, 0.7, 0.7, 1)
         graphics.set_color(*color)
         draw.image(self.image,self.x,self.y)
     else:
         color = (0,0,0,0)
         if self.parent_group != None and self.selected: color = (0,0,0, 0.3)
         if self.pressed: color = (0,0,0, 0.6)
         graphics.set_color(*color)
         draw.rect(self.x, self.y, self.x + self.width, self.y+self.height)
     if self.label != None:    
         graphics.set_color(1,1,1,1)
         draw.label(self.label)
     if self.more_draw != None: self.more_draw()
Esempio n. 7
0
 def draw(self):
     if not self.visible: return
     color = (1,1,1,1)
     if self.parent_group != None and self.selected: color = (0.8, 0.8, 0.8, 1)
     if self.pressed: color = (0.7, 0.7, 0.7, 1)
     graphics.set_color(color=color)
     draw.image(self.image,self.x,self.y)
     if self.image_2 != None:
         graphics.set_color(1,1,1,1)
         graphics.call_twice(pyglet.gl.glPushMatrix)
         if self.scale_factor != 1.0:
             pyglet.gl.glScalef(self.scale_factor, self.scale_factor, self.scale_factor)
         graphics.call_twice(
             pyglet.gl.glTranslatef, 
             self.x/self.scale_factor, self.y/self.scale_factor, 0
         )
         if self.centered:
             graphics.call_twice(
                 pyglet.gl.glTranslatef,
                 self.image.width/self.scale_factor/2, self.image.height/self.scale_factor/2, 0
             )
         draw.image(self.image_2, 0, 0)
         graphics.call_twice(pyglet.gl.glPopMatrix)
Esempio n. 8
0
 def draw(self):
     color = (1,1,1,1)
     if self.parent_group != None and self.selected:
         color = (0.8, 0.8, 0.8, 1)
     if self.pressed: color = (0.7, 0.7, 0.7, 1)
     draw.set_color(color=color)
     draw.image(self.image,self.x,self.y)
     if self.image_2 != None:
         if self.anchor == 'bottomleft':
             draw.image(self.image_2, self.x, self.y)
         elif self.anchor == 'center':
             draw.image(
                 self.image_2, 
                 self.x+self.image.width/2, self.y+self.image.height/2
             )
Esempio n. 9
0
    def draw_image(self, image, pos, angle=0, color=None):

        x = (pos[0] - self.origin[0]) * self.scale
        y = (pos[1] - self.origin[1]) * self.scale

        draw.image(self.screen, image, (x, y), angle=angle, color=color)