Esempio n. 1
0
 def get_imgs():
     """Load an return the images used as file and folder icons."""
     print("*** MCEDIT DEBUG: file_dialog:", __file__)
     print("*** MCEDIT DEBUG: directory:", os.path.dirname(__file__))
     print("*** MCEDIT DEBUG: current directory:", os.getcwd())
     try:
         file_image = get_image('file.png', prefix='')
         folder_image = get_image('folder.png', prefix='')
     except Exception as e:
         print("MCEDIT DEBUG: Could not load file dialog images.")
         print(e)
         from pygame import draw, Surface
         from pygame.locals import SRCALPHA
         from math import pi
         file_image = Surface((16, 16), SRCALPHA)
         file_image.fill((0, 0, 0, 0))
         draw.lines(file_image, (255, 255, 255, 255), False,
                    [[3, 15], [3, 1], [13, 1]], 2)
         draw.line(file_image, (255, 255, 255, 255), [3, 7], [10, 7], 2)
         folder_image = Surface((16, 16), SRCALPHA)
         folder_image.fill((0, 0, 0, 0))
         draw.line(folder_image, (255, 255, 255, 255), [3, 15], [3, 1], 2)
         draw.arc(folder_image, (255, 255, 255, 255), [0, 1, 13, 15], 0,
                  pi / 1.9, 2)
         draw.arc(folder_image, (255, 255, 255, 255), [0, 1, 13, 15],
                  3 * pi / 2, 2 * pi, 2)
     return file_image, folder_image
Esempio n. 2
0
def draw_ball():
    # клубок
    draw.circle(screen, gray, (300, 608), 40)
    draw.arc(screen, (0, 0, 0), (290, 598, 10, 30), 2 * math.pi / 3,
             3 * math.pi / 1.8)
    draw.arc(screen, (0, 0, 0), (300, 595, 10, 35), 2 * math.pi / 3,
             3 * math.pi / 1.8)
Esempio n. 3
0
	def draw(self, screen):
		# Center point
		draw.line(screen, (0,0,0), (self.center - self.left*5).as_tuple(), (self.center + self.left*5).as_tuple())
		draw.line(screen, (0,0,0), self.center.as_tuple(), (self.center + self.forward*8).as_tuple())
		# Sensor edges
		draw.line(screen, (255,0,0), self.center.as_tuple(), (self.center + self.forward*self.CAMERA_DEPTH + self.left*self.CAMERA_SIDE).as_tuple())		
		draw.line(screen, (255,0,0), self.center.as_tuple(), (self.center + self.forward*self.CAMERA_DEPTH + self.left*(-self.CAMERA_SIDE)).as_tuple())	
		draw.line(screen, (255,0,0), (self.center + self.forward*self.CAMERA_DEPTH + self.left*(-self.CAMERA_SIDE)).as_tuple(), \
									(self.center + self.forward*self.CAMERA_DEPTH + self.left*self.CAMERA_SIDE).as_tuple())
		# Circle
		# Angle we're pointing to:
		fwdangle = atan2(-self.forward.y, self.forward.x)
		fromangle = fwdangle + 0.86
		toangle = fwdangle - 0.86
		if (toangle < 0): toangle += 2*3.1415
		if (fromangle > toangle):
			fromangle -= 2*3.1415
		draw.arc(screen, (0,0,0), Rect(self.center.x - self.radius, self.center.y - self.radius, 2*self.radius, 2*self.radius), fromangle, toangle, 1)
				
		# Wheels
		for side in [1, -1]:
			draw.line(screen, (0,0,0), (self.center + self.left*self.WHEEL_RADIUS*side - self.forward*(30/5)).as_tuple(), (self.center + self.left*self.WHEEL_RADIUS*side + self.forward*(30/5)).as_tuple(), 5)
		# Sides
		for (f,t) in self.edges():
			draw.line(screen, (0,0,0), f.as_tuple(), t.as_tuple())
Esempio n. 4
0
 def test_color_validation(self):
     surf = pygame.Surface((10, 10))
     colors = 123456, (1, 10, 100), RED # but not '#ab12df' or 'red' ...
     points = ((0, 0), (1, 1), (1, 0))
     # 1. valid colors
     for col in colors:
         draw.line(surf, col, (0, 0), (1, 1))
         draw.aaline(surf, col, (0, 0), (1, 1))
         draw.aalines(surf, col, True, points)
         draw.lines(surf, col, True, points)
         draw.arc(surf, col, pygame.Rect(0, 0, 3, 3), 15, 150)
         draw.ellipse(surf, col, pygame.Rect(0, 0, 3, 6), 1)
         draw.circle(surf, col, (7, 3), 2)
         draw.polygon(surf, col, points, 0)
     # 2. invalid colors
     for col in ('invalid', 1.256, object(), None, '#ab12df', 'red'):
         with self.assertRaises(TypeError):
             draw.line(surf, col, (0, 0), (1, 1))
         with self.assertRaises(TypeError):
             draw.aaline(surf, col, (0, 0), (1, 1))
         with self.assertRaises(TypeError):
             draw.aalines(surf, col, True, points)
         with self.assertRaises(TypeError):
             draw.lines(surf, col, True, points)
         with self.assertRaises(TypeError):
             draw.arc(surf, col, pygame.Rect(0, 0, 3, 3), 15, 150)
         with self.assertRaises(TypeError):
             draw.ellipse(surf, col, pygame.Rect(0, 0, 3, 6), 1)
         with self.assertRaises(TypeError):
             draw.circle(surf, col, (7, 3), 2)
         with self.assertRaises(TypeError):
             draw.polygon(surf, col, points, 0)
Esempio n. 5
0
def circle_mesh(obj, win):
    draw.arc(win,
             mesh_color,
             (transform_x(obj.Pos.x) - obj.radius, transform_y(obj.Pos.y) -
              obj.radius, obj.radius * 2, obj.radius * 2),
             0.0,
             2 * pi,
             width=1)
def draw_ball():
    """
    This function draws klubok
    :return:
    """
    draw.circle(screen, gray, (300, 608), 40)
    draw.arc(screen, (0, 0, 0), (290, 598, 10, 30), 2*math.pi/3, 3*math.pi/1.8)
    draw.arc(screen, (0, 0, 0), (300, 595, 10, 35), 2*math.pi/3, 3*math.pi/1.8)
def draw_partial_ellipse(top_left_x, top_left_y, width, height, 
                         start_degrees, end_degrees, thickness = 1):
    if thickness == 0:
        thickness = 1
    draw.arc(screen, color, pygame.Rect(int(top_left_x), 
                                        int(WINDOW_HEIGHT-top_left_y), 
                                        int(width), int(height)),
             start_degrees * math.pi / 180, end_degrees * math.pi / 180,
             int(thickness))
Esempio n. 8
0
def draw_ball():
    """
    This function draws the ball
    return:
    """
    draw.circle(screen, gray, (300, 548), 40)
    draw.arc(screen, (0, 0, 0), (290, 538, 10, 30), 2 * math.pi / 3,
             3 * math.pi / 1.8)
    draw.arc(screen, (0, 0, 0), (300, 535, 10, 35), 2 * math.pi / 3,
             3 * math.pi / 1.8)
Esempio n. 9
0
def draw_seabirds(surf, color, length, height):
    """
    Функция рисует птичку в небе
    :param surf: поверхность, на которой нужно нарисовать птичку
    :param color: цвет птички
    :param length: ширина поверхности
    :param height: высота поверхности
    :return: функция ничего не возвращает
    """
    for i in range(2):
        draw.arc(surf, color, (0.13 * length, 0.033 * height + i, 100, 128), np.pi / 3, 7 * np.pi / 9)
        draw.arc(surf, color, (0.235 * length, 0.02 * height + i, 100, 128), np.pi / 3, 7 * np.pi / 9)
Esempio n. 10
0
def draw_tree(screen, x, y, size_x, size_y, color):
    #the center(x,y) of the tree is the point in the middle of its trunk
    #bottom part of trunk
    pgd.line(screen, color, [x, y + int(size_y/60)], 
                            [x, y + int(size_y/4)], 
                            int(size_x/18))
    pgd.line(screen, color, [x, y + int(17*size_y/60)], 
                            [x, y + int(size_y/2)], 
                            int(size_x/18))
    #right and bottom branch
    pgd.arc(screen, tree_color, [[x, y - int(5*size_y/57)], 
                                 [int(14*size_x/35), int(size_y/2 + 5*size_y/57)]],
                                 6*m.pi/14, 4*m.pi/5, 4)
    #top part of trunk
    pgd.polygon(screen, tree_color, [[x, y], 
                                     [x - int(size_x/22), y - int(size_y/80)], 
                                     [x, y - int(17.5*size_y/116)], 
                                     [x + int(size_x/22), y - int(16*size_y/116)]])
    pgd.polygon(screen, tree_color, [[x + int(size_x/80), y - int(size_y/6 + 0.5*size_y/100)], 
                                     [x - int(size_x/80), y - int(17*size_y/96)], 
                                     [x + int(size_x/18), y - int(size_y/2 + 1*size_y/100 )], 
                                     [x + int(7*size_x/86), y - int(size_y/2 + 0.5*size_y/100)]])
    #leaves on right and bottom branch
    delta_1 = int(5*size_x/37)
    for i in range(3):
        pgd.ellipse(screen, tree_color, [[x + delta_1, y - int(5*size_y/70)], 
                                         [int(size_x/40), int(5*size_y/35)]])
        delta_1 += int(3*size_x/60)
    
    #right and top branch and leaves on it
    pgd.arc(screen, tree_color, [[x + int(5*size_x/80), y - int(size_y/2)], 
                                 [int(size_x - 5*size_x/40), int(30*size_y/35)]],
            m.pi/2, 9*m.pi/10, 4)
    delta_2x = int(8*size_x/24)
    delta_2y = int(32*size_y/70)
    for i in range(5):
        pgd.ellipse(screen, tree_color, [[x + delta_2x, y - delta_2y], 
                                         [int(size_x/40), int(5*size_y/35)]])
        delta_2x += int(3*size_x/80)
        delta_2y += int(size_y/70)
    #left top branch and leaves
    pgd.arc(screen, tree_color, [[x - size_x, y - int(size_y/2)], 
                                 [size_x, size_y]],
            m.pi/10, m.pi/2, 4)
    delta_3x = int(2.5*size_x/8)
    delta_3y = int(3.5*size_y/8)
    for i in range(5):
        pgd.ellipse(screen, tree_color, [[x - delta_3x, y - delta_3y], 
                                         [int(size_x/40), int(5*size_y/35)]])
        delta_3x += int(3*size_x/80)
        delta_3y += int(size_y/70)
        #left top branch and leaves
    pgd.arc(screen, tree_color, [[x - int(22*size_x/48), y], 
                                 [int(22*size_x/48), int(size_y/2)]],
            m.pi/6, 2.5*m.pi/4, 4)
    delta_4 = int(size_x/6)
    for i in range(3):
        pgd.ellipse(screen, tree_color, [[x - delta_4, y], 
                                         [int(size_x/40), int(5*size_y/35)]])
        delta_4 += int(3*size_x/60)
def eskimo(x1, y1, length, height, hand):
    """"
        функция рисует эскимоса
        :param x1: координата по х верхнего левого угла прямоугольника, в который вписан эллипс - голова эскимоса
        :param y1: координата по y верхнего левого угла прямоугольника, в который вписан эллипс - голова эскимоса
        :param length: ширина головы эскимоса
        :param height: высота головы эскимоса
        :param hand: если данный параметр = 0, то эскимос держит палку в правой руке, иначе - в левой
        :return: функция ничего не возвращает
    """
    if hand == 0:
        draw.ellipse(screen, (149, 124, 110), (x1 - 0.3 * length, y1 + height, 0.55 * length, 0.25 * height))
        draw.line(screen, (0, 0, 0), (x1 - 0.25 * length, y1), (x1 - 0.25 * length, y1 + 2 * height), 1)
        tale = pygame.Surface((0.55 * length, 0.25 * height))
        tale.set_colorkey('BLACK')
        draw.ellipse(tale, (149, 124, 110), (0, 0, 0.5 * length, 0.25 * height))
        tale2 = pygame.transform.rotate(tale, 330)
        screen.blit(tale2, (x1 + 0.78 * length, y1 + 0.91 * height))
    else:
        draw.ellipse(screen, (149, 124, 110),
                     (x1 + 0.78 * length, y1 + 0.91 * height, 0.55 * length, 0.25 * height))
        draw.line(screen, (0, 0, 0), (x1 + 1.2 * length, y1), (x1 + 1.2 * length, y1 + 2 * height), 1)
        tale = pygame.Surface((0.55 * length, 0.25 * height))
        tale.set_colorkey('BLACK')
        draw.ellipse(tale, (149, 124, 110), (0, 0, 0.5 * length, 0.25 * height))
        tale2 = pygame.transform.rotate(tale, 30)
        screen.blit(tale2, (x1 - 0.3 * length, y1 + 0.9 * height))
    draw.ellipse(screen, (228, 222, 219), (x1, y1, length, height))
    draw.ellipse(screen, (149, 124, 110), (x1 - 0.1 * length, y1 + height / 2, 1.2 * length, 3 * height))
    draw.rect(screen, (255, 255, 255), (x1 - 0.1 * length, y1 + height * 2, 1.2 * length, 2 * height))
    draw.rect(screen, (111, 92, 82), (x1 + 0.35 * length, y1 + height / 2, 0.3 * length, 1.5 * height))
    draw.ellipse(screen, (149, 124, 110),
                 (x1 + 0.12 * length, y1 + 1.85 * height, 0.25 * length, 0.5 * height))
    draw.ellipse(screen, (149, 124, 110),
                 (x1 + 0.62 * length, y1 + 1.85 * height, 0.25 * length, 0.5 * height))
    draw.ellipse(screen, (149, 124, 110), (x1, y1 + 1.8 * height + 0.4 * height, 0.35 * length, 0.2 * height))
    draw.ellipse(screen, (149, 124, 110),
                 (x1 + 0.62 * length, y1 + 2.2 * height, 0.35 * length, 0.2 * height))
    draw.ellipse(screen, (175, 157, 146), (x1 + 0.1 * length, y1 + 0.1 * height, 0.8 * length, 0.8 * height))
    draw.ellipse(screen, (229, 218, 219), (x1 + 0.2 * length, y1 + 0.2 * height, 0.6 * length, 0.6 * height))
    draw.line(screen, (0, 0, 0), (x1 + 0.32 * length, y1 + 0.35 * height),
              (x1 + 0.42 * length, y1 + 0.4 * height), 2)
    draw.line(screen, (0, 0, 0), (x1 + 0.64 * length, y1 + 0.35 * height),
              (x1 + 0.54 * length, y1 + 0.4 * height), 2)
    draw.arc(screen, (0, 0, 0), (x1 + 0.3 * length, y1 + 0.5 * height, 0.4 * length, 0.4 * height),
             math.pi * 0.3, math.pi * 0.7,
             2)
    draw.rect(screen, (111, 92, 82), (x1 - 0.1 * length, y1 + 1.8 * height, 1.2 * length, 0.2 * length))
Esempio n. 12
0
 def update(self):
     progress = (time.get_ticks() - self.start) / self.animation
     if progress < 1:
         import math
         rect = (*self.image.get_abs_offset(), *self.image.get_size())
         draw.arc(self.image, self.color, rect, 0, math.pi * 2 * progress,
                  int(rect[3] / 2))
         self.actualizar = True
         del math, rect
     elif not self.complete:
         import math
         pos = tuple(map(lambda val: int(val / 2), self.image.get_size()))
         draw.circle(self.image, self.color, pos, pos[1])
         del math, pos
         self.actualizar = True
         self.complete = True
Esempio n. 13
0
    def arc(self, color, Rect, start_angle, stop_angle, width=1):
        """楕円の弧を描画します.

        Parameters
        ----------
        color : tuple of int
            描画に使用される色を指定します.
        Rect : pygame.Rect or tuple of float
            楕円に外接する長方形を示すpygame.Rectオブジェクトもしくは座標を格納したタプル.
            タプルは(x_min, y_min, width, height)の順番で値を格納する.
        start_angle : float
            弧の始点に対応する角度.
            単位はラジアン.
        stop_angle : float
            弧の終点に対応する角度.
            単位はラジアン.
        width : float
            描画される弧の太さ.

        Returns
        -------
        rect : pygame.Rect
            描画によって影響を受けた範囲を示すpygame.Rectオブジェクトを返します.

        """

        return pyd.arc(self.pg.screen, color, Rect, start_angle, stop_angle, width)
def draw_screamer():
    """
    This function draws a terrifying cat
    :return:
    """

    # background
    draw.rect(screen, (0, 0, 0), (0, 0, 500, 700))

    # face
    draw.circle(screen, (255, 0, 0), (250, 350), 200)

    # mouth
    draw.arc(screen, (0, 0, 0), (110, 280, 280, 250), -3.1415, 0.03, 5)
    draw.line(screen, (0, 0, 0), (110, 405), (390, 405), 5)
    a = 128
    b = 5

    # teeth
    draw.polygon(screen, (255, 255, 255), ((b + 110, a + 280), (b + 140, a + 340), (b + 155, a + 280),
                                           (b + 165, a + 355), (b + 180, a + 280), (b + 200, a + 390),
                                           (b + 230, a + 280), (b + 250, a + 390), (b + 275, a + 280),
                                           (b + 285, a + 385), (b + 300, a + 280), (b + 330, a + 350),
                                           (b + 350, a + 280), (b + 360, a + 335), (b + 380, a + 280)))

    # eyes
    draw.circle(screen, (240, 240, 240), (250 - 80, 350 - 60), 50)
    draw.circle(screen, (240, 240, 240), (250 + 80, 350 - 60), 50)

    # ears
    draw.polygon(screen, (255, 0, 0), ((80, 300), (80, 100), (190, 180)))
    draw.polygon(screen, (255, 0, 0), ((500 - 80, 300), (500 - 80, 100), (500 - 190, 180)))

    # pupils
    draw.ellipse(screen, (0, 0, 0), (160, 240, 20, 100))
    draw.ellipse(screen, (0, 0, 0), (320, 240, 20, 100))

    # moustache
    draw.line(screen, (240, 100, 100), (120, 390), (10, 390), 5)
    draw.line(screen, (240, 100, 100), (100, 350), (20, 300), 5)
    draw.line(screen, (240, 100, 100), (100, 380), (10, 360), 5)
    draw.line(screen, (240, 100, 100), (500 - 120, 390), (500 - 10, 390), 5)
    draw.line(screen, (240, 100, 100), (500 - 100, 350), (500 - 20, 300), 5)
    draw.line(screen, (240, 100, 100), (500 - 100, 380), (500 - 10, 360), 5)
Esempio n. 15
0
	def __draw_view_area(self, obj):
		color = obj.color
		if obj.mode is 'hunting':
			color = (255, obj.color[1], obj.color[2])



		draw.line(self.window, color, obj.screen_position, obj.view_area[0])
		draw.line(self.window, color, obj.screen_position, obj.view_area[1])
		#draw.circle(self.window, obj.color, obj.screen_position, obj.view_area_radius, 1)

		r = obj.view_area_radius * X_CELL
		a = obj.view_area_angle

		draw.arc(self.window, color, 
				(d((r, r), obj.screen_position), 
							(r * 2, r * 2)),
				TRIGONOMETRY_SUCKS[obj.direction]['rad'] - a, 
							TRIGONOMETRY_SUCKS[obj.direction]['rad'] + a)
Esempio n. 16
0
def yurt(x1, y1, length, height):
    """
    функция рисует юрту заданных размеров в заданном месте
    :param x1: координата по х верхнего левого угла прямоугольника, в который будет вписана юрта
    :param y1: координата по у верхнего левого угла прямоугольника, в который будет вписана юрта
    :param length: ширина юрты
    :param height: высота юрты, умноженная на 2
    :return: функция ничего не возвращает
    """
    draw.ellipse(screen, (230, 230, 230), (x1, y1, length, height))
    draw.arc(screen, (0, 0, 0), (x1, y1, length, height), math.pi * 2, math.pi,
             3)
    draw.rect(screen, (255, 255, 255),
              (x1, y1 + height / 2, length, height / 2))
    draw.line(screen, (0, 0, 0), (x1, y1 + height / 2),
              (x1 + length, y1 + height / 2), 1)
    x2 = x1 + length / 8
    xx2 = x2 - x1 - length / 2
    l2 = length / 2
    y2 = -(height / 2) * math.sqrt(1 - (xx2**2) / (l2**2)) + y1 + height / 2
    draw.arc(screen, (0, 0, 0), (x2, y2 - 5, 0.75 * length, 10), math.pi,
             math.pi * 2, 2)
    x3 = x1 + length / 32
    xx3 = x3 - x1 - length / 2
    y3 = -(height / 2) * math.sqrt(1 - (xx3**2) / (l2**2)) + y1 + height / 2
    draw.arc(screen, (0, 0, 0), (x3, y3 - 5, 0.9375 * length, 10), math.pi,
             math.pi * 2, 2)
    x4 = x1 + length / 4
    xx4 = x4 - x1 - length / 2
    y4 = -(height / 2) * math.sqrt(1 - (xx4**2) / (l2**2)) + y1 + height / 2
    draw.arc(screen, (0, 0, 0), (x4, y4 - 5, 0.5 * length, 10), math.pi,
             math.pi * 2, 2)
    draw.line(screen, (0, 0, 0), (x3 + length / 5, y3),
              (x1 + length / 5, y1 + height / 2), 1)
    draw.line(screen, (0, 0, 0), (x3 + 2 * length / 5, y3),
              (x1 + 3 * length / 7, y1 + height / 2), 1)
    draw.line(screen, (0, 0, 0), (x3 + 3 * length / 5, y3),
              (x1 + 4 * length / 6, y1 + height / 2), 1)
    draw.line(screen, (0, 0, 0), (x3 + 4 * length / 5, y3),
              (x1 + 7 * length / 8, y1 + height / 2), 1)
    draw.line(screen, (0, 0, 0), (x2 + length / 4, y2),
              (x3 + 2 * length / 7, y3 + 5), 1)
    draw.line(screen, (0, 0, 0), (x2 + 4 * length / 7, y2),
              (x3 + 5 * length / 7, y3 + 5), 1)
    draw.line(screen, (0, 0, 0), (x4 + length / 10, y4),
              (x2 + length / 8, y2 + 5), 1)
    draw.line(screen, (0, 0, 0), (x4 + length / 4, y4),
              (x2 + 3 * length / 7, y2 + 5), 1)
    draw.line(screen, (0, 0, 0), (x4 + 5 * length / 11, y4),
              (x2 + 8 * length / 12, y2 + 5), 1)
    draw.line(screen, (0, 0, 0), (x1 + length / 2, y1),
              (x4 + 4 * length / 12, y4 + 5), 1)
Esempio n. 17
0
def draw_branches(screen, x, y, trunk_width, trunk_height, tree_color):
    ''' the center(x,y) of the tree is the point in the middle of its trunk '''

    right_low_branch_x = x
    right_low_branch_y = y - 5 * trunk_height // 57
    right_low_branch_width = 14 * trunk_width // 35
    right_low_branch_height = trunk_height // 2 + 5 * trunk_height // 57
    right_low_branch_start_ang = 3 * m.pi // 7
    right_low_branch_arc_size = 13 * m.pi // 35
    pgd.arc(screen, tree_color,
            [[right_low_branch_x, right_low_branch_y],
             [right_low_branch_width, right_low_branch_height]],
            right_low_branch_start_ang,
            right_low_branch_start_ang + right_low_branch_arc_size, 4)

    right_top_branch_x = x + trunk_width // 16
    right_top_branch_y = y - trunk_height // 2
    right_top_branch_width = trunk_width - trunk_width // 8
    right_top_branch_height = 6 * trunk_height // 7
    right_top_branch_start_ang = m.pi / 2
    right_top_branch_arc_size = 2 * m.pi // 5
    pgd.arc(screen, tree_color,
            [[right_top_branch_x, right_top_branch_y],
             [right_top_branch_width, right_top_branch_height]],
            right_top_branch_start_ang,
            right_top_branch_start_ang + right_top_branch_arc_size, 4)

    left_top_branch_x = x - trunk_width
    left_top_branch_y = y - trunk_height // 2
    left_top_branch_width = trunk_width
    left_top_branch_height = trunk_height
    left_top_branch_start_ang = m.pi / 10
    left_top_branch_arc_size = 2 * m.pi // 5
    pgd.arc(screen, tree_color,
            [[left_top_branch_x, left_top_branch_y],
             [left_top_branch_width, left_top_branch_height]],
            left_top_branch_start_ang,
            left_top_branch_start_ang + left_top_branch_arc_size, 4)

    left_low_branch_x = x - 11 * trunk_width // 24
    left_low_branch_y = y
    left_low_branch_width = 11 * trunk_width // 24
    left_low_branch_height = trunk_height // 2
    left_low_branch_start_ang = m.pi / 6
    left_low_branch_arc_size = 11 * m.pi // 24
    pgd.arc(screen, tree_color,
            [[left_low_branch_x, left_low_branch_y],
             [left_low_branch_width, left_low_branch_height]],
            left_low_branch_start_ang,
            left_low_branch_start_ang + left_low_branch_arc_size, 4)
Esempio n. 18
0
def draw_bear_head(screen, x, y, scale):
    w, h = 100 * scale, 60 * scale
    rect = [int(c) for c in [x - w // 2, y - h // 2, w, h]]

    # base
    bordered_ellipse(screen, COLORS["grey"], rect, 2)

    # eye and nose
    dr.ellipse(screen, COLORS["black"],
               [x - w // 6, y - h // 5, w // 8, h // 8])
    dr.ellipse(screen, COLORS["black"],
               [x + 4 * w // 9, y - h // 7, w // 8, h // 8])

    # mouth
    m_w, m_h = int(w * 1.1), h // 4
    dx, dy = int(-7 * scale), int(3 * scale)
    mouth_rect = [x - m_w // 2 + dx, y - m_h // 2 + dy, m_w, m_h]
    dr.arc(screen, COLORS["black"], mouth_rect, 3 * np.pi / 2, 2 * np.pi)

    # ear
    e_x, e_y = x - 3 * w // 9, y - 3 * h // 9
    e_w, e_h = w // 5, h // 5

    ear_rect1 = [e_x - e_w // 2, e_y - e_h // 2, e_w, e_h]
    ear_rect2 = [e_x - e_w // 2, e_y - e_h, e_w, e_h * 2]
    dr.ellipse(screen, COLORS["grey"], ear_rect1)
    dr.arc(screen, COLORS["black"], ear_rect1, 0, 1.1 * np.pi, 2)
    dr.arc(screen, COLORS["black"], ear_rect2, 1.05 * np.pi, 2 * np.pi, 2)
    def draw(self, screen):
        # Center point
        draw.line(screen, (0, 0, 0), (self.center - self.left * 5).as_tuple(),
                  (self.center + self.left * 5).as_tuple())
        draw.line(screen, (0, 0, 0), self.center.as_tuple(),
                  (self.center + self.forward * 8).as_tuple())
        # Sensor edges
        draw.line(screen, (255, 0, 0), self.center.as_tuple(),
                  (self.center + self.forward * self.CAMERA_DEPTH +
                   self.left * self.CAMERA_SIDE).as_tuple())
        draw.line(screen, (255, 0, 0), self.center.as_tuple(),
                  (self.center + self.forward * self.CAMERA_DEPTH + self.left *
                   (-self.CAMERA_SIDE)).as_tuple())
        draw.line(screen, (255,0,0), (self.center + self.forward*self.CAMERA_DEPTH + self.left*(-self.CAMERA_SIDE)).as_tuple(), \
               (self.center + self.forward*self.CAMERA_DEPTH + self.left*self.CAMERA_SIDE).as_tuple())
        # Circle
        # Angle we're pointing to:
        fwdangle = atan2(-self.forward.y, self.forward.x)
        fromangle = fwdangle + 0.86
        toangle = fwdangle - 0.86
        if (toangle < 0): toangle += 2 * 3.1415
        if (fromangle > toangle):
            fromangle -= 2 * 3.1415
        draw.arc(
            screen, (0, 0, 0),
            Rect(self.center.x - self.radius, self.center.y - self.radius,
                 2 * self.radius, 2 * self.radius), fromangle, toangle, 1)

        # Wheels
        for side in [1, -1]:
            draw.line(screen, (0, 0, 0),
                      (self.center + self.left * self.WHEEL_RADIUS * side -
                       self.forward * (30 / 5)).as_tuple(),
                      (self.center + self.left * self.WHEEL_RADIUS * side +
                       self.forward * (30 / 5)).as_tuple(), 5)
        # Sides
        for (f, t) in self.edges():
            draw.line(screen, (0, 0, 0), f.as_tuple(), t.as_tuple())
Esempio n. 20
0
 def head():
     s = 56
     head_parameters = (
     (dog_color, (x+s//2*n-s//2*abs(n), y, s*abs(n), s*abs(n)), (0, 0)),
     (box_color, (x+s//2*n-s//2*abs(n), y, s*abs(n), s*abs(n)), (2, 2)),
     (dog_color, (x-s//16*abs(n), y, s//8*abs(n), s//4*abs(n)), (0, 0)),
     (box_color, (x-s//16*abs(n), y, s//8*abs(n), s//4*abs(n)), (2, 2)),
     (dog_color, (x+s*n-s//16*abs(n), y, s//8*abs(n), s//4*abs(n)), (0, 0)),
     (box_color, (x+s*n-s//16*abs(n), y, s//8*abs(n), s//4*abs(n)), (2, 2)),
     (wh_color, (x+(s//8+s//8)*n-s//8*abs(n), y + s//4*abs(n), s//4*abs(n), s//8*abs(n)), (0, 0)),
     (box_color, (x+(s//8+s//8)*n-s//8*abs(n), y + s//4*abs(n), s//4*abs(n), s//8*abs(n)), (1, 1)),
     (bl_color, (x+int((s//4)*n), y+int((5*s//16)*abs(n)), int((s//16)*abs(n)), 0), (0, 0)),
     (wh_color, (x+(5*s//8+s//8)*n-s//8*abs(n), y + s//4*abs(n), s//4*abs(n), s//8*abs(n)), (0, 0)),
     (box_color, (x+(5*s//8+s//8)*n-s//8*abs(n), y + s//4*abs(n), s//4*abs(n), s//8*abs(n)), (1, 1)),
     (bl_color, (x+int((3*s//4)*n), y+int((5*s//16)*abs(n)), int((s//16)*abs(n)), 0), (0, 0)),
     (bl_color, (x+(s//4+0.75*s//3)*n-0.75*s//3*abs(n), y+3*s//4*abs(n), 1.5*s//3*abs(n), s//3*abs(n)), (m.pi//16, m.pi)),
     (wh_color, [(x+s//3*n,y+4*s//5*abs(n)),(x+s//3*n,y+7*s//10*abs(n)),(x+7*s//18*n, y+15*s//20*abs(n))],(0, 0)),
     (wh_color, [(x+(s-s//3)*n,y+4*s//5*abs(n)),(x+(s-s//3)*n,y+7*s//10*abs(n)),(x+(s-7*s//18)*n,y+15*s//20*abs(n))], (0, 0)),
     )
     '''
     the sequence of drawing
     the head is:
     head(2 rects), 2 ears(each ear - 2 ellipses), 2 eyes(each eye - 2 ellipses and 1 circle), 
     mouth(1 arc), teeth(each tooth - 1 polygon)
     '''
     k = 1
     for elem in head_parameters:
         if k < 3:
             pgd.rect(screen, elem[0], elem[1], elem[2][0])
         elif k == 9 or k == 12:
             pgd.circle(screen, elem[0], (elem[1][0], elem[1][1]), elem[1][2], elem[2][0])
         elif k == 13:
             pgd.arc(screen, elem[0], elem[1], elem[2][0], elem[2][1])
         elif k > 13:
             pgd.polygon(screen, elem[0], elem[1], elem[2][0])
         else:
             pgd.ellipse(screen, elem[0], elem[1], elem[2][0])
         k = k + 1
Esempio n. 21
0
 def get_imgs():
     """Load an return the images used as file and folder icons."""
     print "*** MCEDIT DEBUG: file_dialog:", __file__
     print "*** MCEDIT DEBUG: directory:", os.path.dirname(__file__)
     print "*** MCEDIT DEBUG: current directory:", os.getcwd()
     try:
         file_image = get_image('file.png', prefix='')
         folder_image = get_image('folder.png', prefix='')
     except Exception, e:
         print "MCEDIT DEBUG: Could not load file dialog images."
         print e
         from pygame import draw, Surface
         from pygame.locals import SRCALPHA
         from math import pi
         file_image = Surface((16, 16), SRCALPHA)
         file_image.fill((0,0,0,0))
         draw.lines(file_image, (255, 255, 255, 255), False, [[3, 15], [3, 1], [13, 1]], 2)
         draw.line(file_image, (255, 255, 255, 255), [3, 7], [10, 7], 2)
         folder_image = Surface((16, 16), SRCALPHA)
         folder_image.fill((0,0,0,0))
         draw.line(folder_image, (255, 255, 255, 255), [3, 15], [3, 1], 2)
         draw.arc(folder_image, (255, 255, 255, 255), [0, 1, 13, 15], 0, pi/1.9, 2)
         draw.arc(folder_image, (255, 255, 255, 255), [0, 1, 13, 15], 3*pi/2, 2*pi, 2)
Esempio n. 22
0
    def update(self, time):
        self.delta = time
        for comp in [x for x in self.components if x.active]:
            # prepare style options
            color = comp.style.get('color', common.BLACK)
            width = comp.style.get('width', 1)

            # draw debug objects
            if comp.rect:
                from pdb import set_trace
                set_trace()
                trans_rect = Rect(comp.rect.rect.x + comp.rect.anchor.body.x,
                                  comp.rect.rect.y + comp.rect.anchor.body.y,
                                  comp.rect.rect.w,
                                  comp.rect.rect.h)
                draw.rect(self.surface, color, trans_rect, width)
            if comp.circle:
                draw.circle(self.surface, color, comp.circle.pos,
                            comp.circle.radius, width)
            if comp.ellipse:
                draw.ellipse(self.surface, color, comp.ellipse.rect,
                             width)
            if comp.arc:
                draw.arc(self.surface, color, comp.arc.start,
                         comp.arc.end, width)
            if comp.line:
                draw.line(self.surface, color, comp.line.closed,
                          comp.line.points, width)

            if comp.get_value:
                text_val = str(comp.get_value())
                if text_val != comp.last_value:
                    # fire event to update rendered graphic for this
                    comp.last_value = text_val
                    tu_event = GameEvent(UPDATETEXT, component=comp.text,
                                         text=text_val)
                    self.delegate(tu_event)
Esempio n. 23
0
    def update(self, time):
        self.delta = time
        for comp in [x for x in self.components if x.active]:
            # prepare style options
            color = comp.style.get('color', common.BLACK)
            width = comp.style.get('width', 1)

            # draw debug objects
            if comp.rect:
                from pdb import set_trace
                set_trace()
                trans_rect = Rect(comp.rect.rect.x + comp.rect.anchor.body.x,
                                  comp.rect.rect.y + comp.rect.anchor.body.y,
                                  comp.rect.rect.w, comp.rect.rect.h)
                draw.rect(self.surface, color, trans_rect, width)
            if comp.circle:
                draw.circle(self.surface, color, comp.circle.pos,
                            comp.circle.radius, width)
            if comp.ellipse:
                draw.ellipse(self.surface, color, comp.ellipse.rect, width)
            if comp.arc:
                draw.arc(self.surface, color, comp.arc.start, comp.arc.end,
                         width)
            if comp.line:
                draw.line(self.surface, color, comp.line.closed,
                          comp.line.points, width)

            if comp.get_value:
                text_val = str(comp.get_value())
                if text_val != comp.last_value:
                    # fire event to update rendered graphic for this
                    comp.last_value = text_val
                    tu_event = GameEvent(UPDATETEXT,
                                         component=comp.text,
                                         text=text_val)
                    self.delegate(tu_event)
Esempio n. 24
0
 def head():
     s = 56
     head_parameters = (
     (dog_color, (x, y, s, s), (0, 0)),
     (box_color, (x, y, s, s), (2, 2)),
     (dog_color, (x - s//10, y, s//5, s//3 ), (0, 0)),
     (box_color, (x - s//10, y, s//5, s//3 ), (2, 2)),
     (dog_color, (x + s - s//10, y, s//5, s//3 ), (0, 0)),
     (box_color, (x + s - s//10, y, s//5, s//3 ), (2, 2)),
     (wh_color, (x + s//8, y + s//4, s//4, s//8), (0, 0)),
     (box_color, (x + s//8, y + s//4, s//4, s//8), (1, 1)),
     (bl_color, (x + 3*s//16, y + 4*s//16, s//8, s//8), (0, 0)),
     (wh_color, (x + 5*s//8, y + s//4, s//4, s//8), (0, 0)),
     (box_color, (x + 5*s//8, y + s//4, s//4, s//8), (1, 1)),
     (bl_color, (x + 11*s//16, y + 4*s//16, s//8, s//8), (0, 0)),
     (bl_color, (x + s//4, y + 3*s//4, s//2, s//3), (m.pi//16, m.pi)),
     (wh_color, [(x+s//3, y+4*s//5), (x+s//3, y+7*s//10), (x+7*s//18, y+15*s//20)], (0, 0)),
     (wh_color, [(x+s-s//3, y+4*s//5), (x+s-s//3, y+7*s//10), (x+s-7*s//18, y+15*s//20)], (0, 0)),
     )
     '''
     the sequence of drawing
     the head is:
     head(2 rects), 2 ears(each ear - 2 ellipses), 2 eyes(each eye - 3 ellipses), 
     mouth(1 arc), teeth(each tooth - 1 polygon)
     '''
     k = 1
     for elem in head_parameters:
         if k < 3:
             pgd.rect(screen, elem[0], elem[1], elem[2][0])
         elif k == 13:
             pgd.arc(screen, elem[0], elem[1], elem[2][0], elem[2][1])
         elif k > 13:
             pgd.polygon(screen, elem[0], elem[1], elem[2][0])
         else:
             pgd.ellipse(screen, elem[0], elem[1], elem[2][0])
         k = k + 1
Esempio n. 25
0
    def get_surface(self):
        """
		Returns a Surface to use as this element's background, decorated with whichever effect function
		is set on this widget having been applied.
		"""
        surface = Surface(self.rect.size)
        surface.fill(self.current_background_color())

        color = Color(*self.current_background_color())
        highlight = color.correct_gamma(2)
        shadow = color.correct_gamma(0.5)
        arc(surface, shadow, self._circle_rect, RADIANS_TOPRIGHT,
            RADIANS_BOTTOM_LEFT, self.bevel_depth)
        arc(surface, highlight, self._circle_rect, RADIANS_BOTTOM_LEFT,
            RADIANS_TOPRIGHT, self.bevel_depth)

        if self.selected:
            circle(surface, self.dot_color, self._circle_rect.center,
                   self.dot_radius)

        for att in ["disabled", "focused", "hovering"]:
            setattr(self._label, att, getattr(self, att))
        surface.blit(self._label.get_surface(), self._label_rect.topleft)
        return surface
Esempio n. 26
0
def draw_cat_mouth(x0, y0, length, width):
    """
    В функцию передаются параметры кота (функции cat в соответсвующие поля) и она рисует мордочку и усы
    :param x0: координата верхнего левого угла кошки по оХ
    :param y0: координата верхнего левого угла кошки по оУ
    :param length: длина кошки (оХ)
    :param width: ширина кошки (оУ)
    """
    draw.polygon(screen, (243, 163, 238),
                 [(x0 + 0.154 * length, y0 + 0.35 * width),
                  (x0 + 0.18 * length, y0 + 0.35 * width),
                  (x0 + 0.166 * length, y0 + 0.39 * width)])
    draw.polygon(screen, 'black', [(x0 + 0.154 * length, y0 + 0.35 * width),
                                   (x0 + 0.18 * length, y0 + 0.35 * width),
                                   (x0 + 0.166 * length, y0 + 0.39 * width)],
                 1)
    draw.line(screen, 'black', [x0 + 0.166 * length, y0 + 0.39 * width],
              [x0 + 0.166 * length, y0 + 0.415 * width])
    draw.arc(
        screen, 'black',
        (x0 + 0.145 * length, y0 + 0.4 * width, 0.028 * length, 0.05 * width),
        pi, 0)
    draw.arc(
        screen, 'black',
        (x0 + 0.166 * length, y0 + 0.4 * width, 0.028 * length, 0.05 * width),
        pi, 0)
    draw.arc(
        screen, 'black',
        (x0 + 0.2 * length, y0 + 0.35 * width, 0.196 * length, 0.05 * width),
        0, pi)
    draw.arc(
        screen, 'black',
        (x0 + 0.22 * length, y0 + 0.365 * width, 0.196 * length, 0.05 * width),
        0, pi)
    draw.arc(
        screen, 'black',
        (x0 + 0.23 * length, y0 + 0.38 * width, 0.196 * length, 0.05 * width),
        0, pi)
    draw.arc(
        screen, 'black',
        (x0 - 0.084 * length, y0 + 0.35 * width, 0.196 * length, 0.05 * width),
        0, pi)
    draw.arc(screen, 'black', (x0 - 0.075 * length, y0 + 0.365 * width,
                               0.196 * length, 0.05 * width), 0, pi)
    draw.arc(
        screen, 'black',
        (x0 - 0.084 * length, y0 + 0.38 * width, 0.196 * length, 0.05 * width),
        0, pi)
Esempio n. 27
0
	def draw(self, screen):
		# The field is a rect in the center of the screen
		BLACK = (0,0,0)
		WHITE = (255,255,255)
		GREEN = (43,252,43)
		self.field.fill(GREEN)	# Green fill
		draw.rect(self.field, WHITE, self.field.get_rect(), 20)	# White border
		draw.rect(self.field, BLACK, self.field.get_rect(), 1)		# Black border
		draw.rect(self.field, BLACK, (10, 10, self.cx-5-10, self.height-10-10), 1)	# Black square (left)
		draw.rect(self.field, BLACK, (self.cx + 5, 10, self.cx-5-10, self.height-10-10), 1)	# Black square (right)
		draw.circle(self.field, WHITE, (self.cx, self.cy), 80, 10)	# Central circle (white)
		draw.circle(self.field, BLACK, (self.cx, self.cy), 80-10, 1)		# Central circle (black, inner)
		draw.circle(self.field, BLACK, (self.cx, self.cy), 80, 1)			# Central circle (black, outer)
		draw.line(self.field, WHITE, (self.cx-1, 0+1), (self.cx-1, self.height-2),10)	# Central divider line (white)

		# Arcs
		#1
		draw.arc(self.field, WHITE, (10 - 100, 265 - 100, 200, 200), 0, 3.1415/2, 10)			# Left goal, upper arc, white filling
		draw.arc(self.field, BLACK, (10 - 100, 265 - 100, 200, 200), 0, 3.1415/2, 1)			# Left goal, upper arc, black, outer
		draw.arc(self.field, BLACK, (10 - 100 + 10, 265 - 100 + 10, 200 - 20, 200 - 20), 0, 3.1415/2, 1)	# Left goal, upper arc, black inner

		#2
		draw.arc(self.field, WHITE, (10 - 100, 265 - 100 + 70, 200, 200), 3*3.1415/2, 2*3.1415, 10)			# Left goal, lower arc, white filling
		draw.arc(self.field, BLACK, (10 - 100, 265 - 100 + 70, 200, 200), 3*3.1415/2, 2*3.1415, 1)			# Left goal, lower arc, black, outer
		draw.arc(self.field, BLACK, (10 - 100 + 10, 265 - 100 + 10 + 70, 200 - 20, 200 - 20), 3*3.1415/4, 2*3.1415, 1)	# Left goal, lower arc, black inner

		#3
		draw.arc(self.field, WHITE, (self.width - 10 - 100, 265 - 100, 200, 200), 3.1415/2, 3.1415, 10)			# Right goal, upper arc, white filling
		draw.arc(self.field, BLACK, (self.width - 10 - 100, 265 - 100, 200, 200), 3.1415/2, 3.1415,  1)			# Right goal, upper arc, black, outer
		draw.arc(self.field, BLACK, (self.width - 10 - 100 + 10, 265 - 100 + 10, 200 - 20, 200 - 20), 3.1415/2, 3.1415, 1)	# Left goal, upper arc, black inner

		#4
		draw.arc(self.field, WHITE, (self.width - 10 - 100, 265 - 100 + 70, 200, 200), 3.1415, 3*3.1415/2, 10)			# Right goal, lower arc, white filling
		draw.arc(self.field, BLACK, (self.width - 10 - 100, 265 - 100 + 70, 200, 200), 3.1415, 3*3.1415/2, 1)			# Right goal, lower arc, black, outer
		draw.arc(self.field, BLACK, (self.width - 10 - 100 + 10, 265 - 100 + 10 + 70, 200 - 20, 200 - 20),  3.1415, 3*3.1415/2, 1)	# Right goal, lower arc, black inner
		
		# Arc connectors
		draw.line(self.field, WHITE, (10 + 100 - 5, 265), (10 + 100 - 5, 265 + 70), 10) # Left goal, arc connector, white filling
		draw.line(self.field, BLACK, (10 + 100 - 10, 265), (10 + 100 - 10, 265 + 70), 1) # Left goal, arc connector, black inner
		draw.line(self.field, BLACK, (10 + 100, 265), (10 + 100, 265 + 70), 1) # Left goal, arc connector, black outer
		
		draw.line(self.field, WHITE, (self.width - 10 - 100 + 5, 265), (self.width - 10 - 100 + 5, 265 + 70), 10) # Right goal, arc connector, white filling
		draw.line(self.field, BLACK, (self.width - 10 - 100 + 10, 265), (self.width - 10 - 100 + 10, 265 + 70), 1) # Right goal, arc connector, black inner
		draw.line(self.field, BLACK, (self.width - 10 - 100, 265), (self.width - 10 - 100, 265 + 70), 1) # Right goal, arc connector, black outer
		
		# Left goal
		draw.rect(self.screen, (163, 163, 46), (self.field.get_offset()[0]-50, self.field.get_offset()[1]+self.cy-70, 50+10, 140), 0)
		text = self.font.render(str(self.scoreLeft), True, BLACK, (163, 163, 46))
		textRect = text.get_rect()
		# Center the rectangle
		textRect.centerx = self.field.get_offset()[0]-50 + 25 + 5
		textRect.centery = self.field.get_offset()[1]+self.cy
		# Blit the text
		self.screen.blit(text, textRect)
		
		# Right goal
		draw.rect(self.screen, (16, 57, 125), (self.field.get_offset()[0]+self.width-10, self.field.get_offset()[1]+self.cy-70, 50+10, 140), 0)
		text = self.font.render(str(self.scoreRight), True, WHITE, (16, 57, 125))
		textRect = text.get_rect()
		textRect.centerx = self.field.get_offset()[0]+self.width - 10 + 30
		textRect.centery = self.field.get_offset()[1]+self.cy
		self.screen.blit(text, textRect)
		
		# Cross in the middle
		#draw.line(self.field, BLACK, (self.cx-10, self.cy), (self.cx+10, self.cy))
		#draw.line(self.field, BLACK, (self.cx, self.cy-10), (self.cx, self.cy+10))
		
		for o in self.objects:
			o.draw(self.field)
Esempio n. 28
0
    def _draw(self, deco: List[Tuple[int, str, Any]], surface: 'pygame.Surface') -> None:
        """
        Draw.

        :param deco: Decoration list
        :param surface: Pygame surface
        :return: None
        """
        if len(deco) == 0:
            return
        rect = self._obj.get_rect()

        for d in deco:
            dtype, decoid, data = d
            if not self._decor_enabled[decoid]:
                continue

            if dtype == DECORATION_POLYGON:
                points, color, filled, width, gfx, kwargs = data
                points = self._update_pos_list(rect, decoid, points, **kwargs)
                if gfx:
                    if filled:
                        gfxdraw.filled_polygon(surface, points, color)
                    else:
                        gfxdraw.polygon(surface, points, color)
                else:
                    pydraw.polygon(surface, color, points, width)

            elif dtype == DECORATION_CIRCLE:
                points, r, color, filled, width, gfx, kwargs = data
                points = self._update_pos_list(rect, decoid, points, **kwargs)
                x, y = points[0]
                if filled:
                    if gfx:
                        gfxdraw.filled_circle(surface, x, y, r, color)
                    else:
                        pydraw.circle(surface, color, (x, y), r)
                else:
                    pydraw.circle(surface, color, (x, y), r, width)

            elif dtype == DECORATION_SURFACE or dtype == DECORATION_BASEIMAGE or dtype == DECORATION_TEXT:
                pos, surf, centered, kwargs = data
                if isinstance(surf, pygame_menu.BaseImage):
                    surf = surf.get_surface(new=False)
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)[0]
                surfrect = surf.get_rect()
                surfrect.x += pos[0]
                surfrect.y += pos[1]
                if centered:
                    surfrect.x -= surfrect.width / 2
                    surfrect.y -= surfrect.height / 2
                surface.blit(surf, surfrect)

            elif dtype == DECORATION_ELLIPSE:
                pos, rx, ry, color, filled, kwargs = data
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)[0]
                if filled:
                    gfxdraw.filled_ellipse(surface, pos[0], pos[1], rx, ry, color)
                else:
                    gfxdraw.ellipse(surface, pos[0], pos[1], rx, ry, color)

            elif dtype == DECORATION_CALLABLE:
                data(surface, self._obj)

            elif dtype == DECORATION_CALLABLE_NO_ARGS:
                data()

            elif dtype == DECORATION_TEXTURE_POLYGON:
                pos, texture, tx, ty, kwargs = data
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)
                if isinstance(texture, pygame_menu.BaseImage):
                    texture = texture.get_surface()
                gfxdraw.textured_polygon(surface, pos, texture, tx, ty)

            elif dtype == DECORATION_ARC:
                points, r, ia, fa, color, width, gfx, kwargs = data
                points = self._update_pos_list(rect, decoid, points, **kwargs)
                x, y = points[0]
                rectarc = pygame.Rect(x - r, y - r, x + 2 * r, y + 2 * r)
                if gfx:
                    gfxdraw.arc(surface, x, y, r, ia, fa, color)
                else:
                    pydraw.arc(surface, color, rectarc, ia / (2 * pi), fa / (2 * pi), width)

            elif dtype == DECORATION_PIE:
                points, r, ia, fa, color, kwargs = data
                points = self._update_pos_list(rect, decoid, points, **kwargs)
                x, y = points[0]
                gfxdraw.pie(surface, x, y, r, ia, fa, color)

            elif dtype == DECORATION_BEZIER:
                points, color, steps, kwargs = data
                points = self._update_pos_list(rect, decoid, points, **kwargs)
                gfxdraw.bezier(surface, points, steps, color)

            elif dtype == DECORATION_RECT:
                drect: 'pygame.Rect'
                pos, drect, color, width, kwargs = data
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)[0]
                drect = drect.copy()
                drect.x += pos[0]
                drect.y += pos[1]
                pygame.draw.rect(surface, color, drect, width)

            elif dtype == DECORATION_PIXEL:
                pos, color, kwargs = data
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)[0]
                gfxdraw.pixel(surface, pos[0], pos[1], color)

            elif dtype == DECORATION_LINE:
                pos, color, width, kwargs = data
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)
                pydraw.line(surface, color, pos[0], pos[1], width)

            else:
                raise ValueError('unknown decoration type')
Esempio n. 29
0
def budka_plus_cep():
    '''
    Draw the home for dogs
    :return:
    '''
    draw.polygon(screen, (235, 191, 0),
                 [[350, 450], [350, 650], [500, 700], [550, 650], [550, 450], [450, 300], [400, 350]])
    draw.aalines(screen, BLACK, False,
                 [[350, 450], [350, 650], [500, 700], [550, 650], [550, 450], [450, 300], [400, 350], [500, 500],
                  [500, 700]])
    draw.aalines(screen, BLACK, False, [[400, 350], [350, 450], [500, 500], [550, 450]])
    draw.ellipse(screen, BLACK, (375, 500, 100, 150))
    draw.arc(screen, YELLOW, (355, 610, 15, 30), 0, pi, 4)
    draw.arc(screen, YELLOW, (355, 610, 15, 30), pi, 2 * pi, 4)
    draw.arc(screen, YELLOW, (357, 630, 15, 30), 0, pi, 4)
    draw.arc(screen, YELLOW, (357, 630, 15, 30), pi, 2 * pi, 4)
    draw.arc(screen, YELLOW, (355, 650, 15, 30), 0, pi, 4)
    draw.arc(screen, YELLOW, (355, 650, 15, 30), pi, 2 * pi, 4)
    draw.arc(screen, YELLOW, (345, 665, 30, 15), 0, pi, 4)
    draw.arc(screen, YELLOW, (345, 665, 30, 15), pi, 2 * pi, 4)
    draw.arc(screen, YELLOW, (325, 663, 30, 15), 0, pi, 4)
    draw.arc(screen, YELLOW, (325, 663, 30, 15), pi, 2 * pi, 4)
    draw.arc(screen, YELLOW, (305, 665, 30, 15), 0, pi, 4)
    draw.arc(screen, YELLOW, (305, 665, 30, 15), pi, 2 * pi, 4)
    draw.arc(screen, YELLOW, (285, 663, 30, 15), 0, pi, 4)
    draw.arc(screen, YELLOW, (285, 663, 30, 15), pi, 2 * pi, 4)
    draw.arc(screen, YELLOW, (265, 665, 30, 15), 0, pi, 4)
    draw.arc(screen, YELLOW, (265, 665, 30, 15), pi, 2 * pi, 4)
Esempio n. 30
0
        folder_image = image.load("folder.png")
    except Exception, e:
        print "MCEDIT DEBUG: Could not load file dialog images."
        print e
        from pygame import draw, Surface
        from pygame.locals import SRCALPHA
        from math import pi

        file_image = Surface((16, 16), SRCALPHA)
        file_image.fill((0, 0, 0, 0))
        draw.lines(file_image, (255, 255, 255, 255), False, [[3, 15], [3, 1], [13, 1]], 2)
        draw.line(file_image, (255, 255, 255, 255), [3, 7], [10, 7], 2)
        folder_image = Surface((16, 16), SRCALPHA)
        folder_image.fill((0, 0, 0, 0))
        draw.line(folder_image, (255, 255, 255, 255), [3, 15], [3, 1], 2)
        draw.arc(folder_image, (255, 255, 255, 255), [0, 1, 13, 15], 0, pi / 1.9, 2)
        draw.arc(folder_image, (255, 255, 255, 255), [0, 1, 13, 15], 3 * pi / 2, 2 * pi, 2)
else:  # windows
    file_image = image.load("file.png")
    folder_image = image.load("folder.png")


class DirPathView(Widget):
    def __init__(self, width, client, **kwds):
        Widget.__init__(self, **kwds)
        self.set_size_for_text(width)
        self.client = client

    def draw(self, surf):
        frame = self.get_margin_rect()
        image = self.font.render(self.client.directory, True, self.fg_color)
Esempio n. 31
0
 def arc(self, color, rect, start, stop, width=1, screen=False):
     rect = rect if screen else self._rect_to_screen(rect)
     return draw.arc(self.surface, color, rect, start, stop, width)
Esempio n. 32
0
 def __draw_dist_circle__(self, r, line_width):
     loc_x = int(WIDTH / 2) - int(r)
     loc_y = AP_POS - r
     arc = (loc_x, loc_y, 2 * r, 2 * r)
     pgD.arc(self.gD, WHITE, arc, -1.1 * pi, pi, line_width)
     return
Esempio n. 33
0
newTiles(city,startPos,tileDimX,tileDimY)
print(playerStart,endPos)
npcs = []

total = 1500
for n in range(total):

	start, end = None,None
	while start == end:
		start = getIntersectionNear(roads,(randint(-100,100),randint(-100,100)))
		end = getIntersectionNear(roads,(randint(-100,100),randint(-100,100)))

	npcs.append(npc(start,end,roads,random() < -1))

	draw.arc(screen,(255,255,255),((width/2-50,height/2-50),(100,100)),0,((n/total)*math.pi*2),4)
	pygame.display.flip()


frames = 0
while 1:
	floatingPos[0] = player.pos[0]
	floatingPos[1] = player.pos[1]
	cameraPos = (round(floatingPos[0]),round(floatingPos[1])) #floatingPos is required since cameraPos must be int but I need slower movement.
	screen.fill(black)
	#print("PLAYER AT ",tileAt(cameraPos), "NPC AT ", tileAt(test.pos))
	frames+=1

	newTiles(city,(int(cameraPos[0]/tileSize),int(cameraPos[1]/tileSize)),tileDimX*2,tileDimY*2)
	
	#addRoads(city)
Esempio n. 34
0
        except Exception as e:
            print("MCEDIT DEBUG: Could not load file dialog images.")
            print(e)
            from pygame import draw, Surface
            from pygame.locals import SRCALPHA
            from math import pi

            file_image = Surface((16, 16), SRCALPHA)
            file_image.fill((0, 0, 0, 0))
            draw.lines(file_image, (255, 255, 255, 255), False,
                       [[3, 15], [3, 1], [13, 1]], 2)
            draw.line(file_image, (255, 255, 255, 255), [3, 7], [10, 7], 2)
            folder_image = Surface((16, 16), SRCALPHA)
            folder_image.fill((0, 0, 0, 0))
            draw.line(folder_image, (255, 255, 255, 255), [3, 15], [3, 1], 2)
            draw.arc(folder_image, (255, 255, 255, 255), [0, 1, 13, 15], 0,
                     pi / 1.9, 2)
            draw.arc(folder_image, (255, 255, 255, 255), [0, 1, 13, 15],
                     3 * pi / 2, 2 * pi, 2)
    else:  # windows
        # file_image = image.load(os.path.join(getDataDir(), 'file.png'))
        # folder_image = image.load(os.path.join(getDataDir(), 'folder.png'))
        file_image = image.load(getDataFile('file.png'))
        folder_image = image.load(getDataFile('folder.png'))


class DirPathView(Widget):
    def __init__(self, width, client, **kwds):
        Widget.__init__(self, **kwds)
        self.set_size_for_text(width)
        self.client = client
Esempio n. 35
0
def knit(x0, y0, r, surface):
    """
    Функция отрисовки клубо44ка
    :param x0: центр клубочка по оХ
    :param y0: центр клубочка оУ
    :param r: радиус клубочка
    :param surface: вспомогательная поверхность для отрисовки клубка
    """

    draw.circle(surface, 'grey', (x0, y0), r)
    draw.circle(surface, (0, 0, 1), (x0, y0), r, 1)
    draw.arc(surface, (1, 1, 1),
             (x0 - 0.75 * r, y0 - 0.5 * r, 1.62 * r, 1.75 * r), 0.1 * pi,
             0.55 * pi)
    draw.arc(surface, (1, 1, 1),
             (x0 - 0.875 * r, y0 - 0.375 * r, 1.62 * r, 1.75 * r), 0.1 * pi,
             0.55 * pi)
    draw.arc(surface, (1, 1, 1),
             (x0 - 0.75 * r, y0 - 0.75 * r, 1.62 * r, 1.75 * r), 0.1 * pi,
             0.6 * pi)
    draw.arc(surface, (1, 1, 1),
             (x0 - 0.375 * r, y0 - 0.375 * r, 1.5 * r, 1.62 * r), 0.7 * pi,
             1.1 * pi)
    draw.arc(surface, (1, 1, 1),
             (x0 - 0.25 * r, y0 - 0.25 * r, 1.5 * r, 1.62 * r), 0.7 * pi,
             1.1 * pi)
    draw.arc(surface, (1, 1, 1),
             (x0 - 0.125 * r, y0 - 0.125 * r, 1.5 * r, 1.62 * r), 0.8 * pi,
             1.1 * pi)
    draw.arc(surface, 'grey',
             (x0 - 1.875 * r, y0 - 0.5 * r, 1.75 * r, 1.87 * r), 1.3 * pi,
             1.8 * pi)
    draw.arc(surface, 'grey', (x0 - 3.225 * r, y0 + 0.9 * r, 2 * r, 1.5 * r),
             0.2 * pi, 0.8 * pi)
Esempio n. 36
0
def head():
    '''
    draw the head of the dog
    :return:
    '''
    draw.rect(SnoopDogg, (153, 102, 0), (45, 545, 80, 80))  # морда
    draw.aalines(SnoopDogg, BLACK_KOSTYL, True, [[45, 545], [125, 545], [125, 625], [45, 625]])
    draw.ellipse(SnoopDogg, (153, 102, 0), (30, 545, 20, 30))  # left ear
    draw.arc(SnoopDogg, BLACK_KOSTYL, (30, 545, 20, 30), pi, 2 * pi, 1)
    draw.arc(SnoopDogg, BLACK_KOSTYL, (30, 545, 20, 30), 0, pi, 1)
    draw.ellipse(SnoopDogg, (153, 102, 0), (120, 545, 20, 30))  # right ear
    draw.arc(SnoopDogg, BLACK_KOSTYL, (120, 545, 20, 30), pi, 2 * pi, 1)
    draw.arc(SnoopDogg, BLACK_KOSTYL, (120, 545, 20, 30), 0, pi, 1)
    draw.ellipse(SnoopDogg, WHITE, (100, 570, 20, 15))  # right zrachok
    draw.arc(SnoopDogg, BLACK_KOSTYL, (100, 570, 20, 15), pi, 2 * pi, 2)
    draw.arc(SnoopDogg, BLACK_KOSTYL, (100, 570, 20, 15), 0, pi, 2)
    draw.ellipse(SnoopDogg, WHITE, (50, 570, 20, 15))  # left zrachok
    draw.arc(SnoopDogg, BLACK_KOSTYL, (50, 570, 20, 15), pi, 2 * pi, 2)
    draw.arc(SnoopDogg, BLACK_KOSTYL, (50, 570, 20, 15), 0, pi, 2)
    draw.ellipse(SnoopDogg, BLACK_KOSTYL, (55, 575, 5, 5))  # tocka right
    draw.ellipse(SnoopDogg, BLACK_KOSTYL, (110, 575, 5, 5))  # tocka left
    draw.arc(SnoopDogg, BLACK_KOSTYL, (65, 590, 40, 20), pi, 2 * pi, 2)  # mouth
    draw.polygon(SnoopDogg, WHITE, [[70, 605], [70, 615], [75, 610]])  # left tooth
    # animation is here
    draw.ellipse(SnoopDogg, (66, 170, 255), (70, 615 + i, 5, 5))
    draw.ellipse(SnoopDogg, (66, 170, 255), (100, 615 + k, 5, 5))

    draw.polygon(SnoopDogg, WHITE, [[100, 605], [100, 615], [95, 610]])  # right tooth
    draw.aalines(SnoopDogg, BLACK_KOSTYL, True, [[70, 605], [70, 615], [75, 610]])
    draw.aalines(SnoopDogg, BLACK_KOSTYL, True, [[100, 605], [100, 615], [95, 610]])
def draw_cat(x, y):
    """
    This function draws a cat, parameters determine where the left cat's ear is
    :param x:
    :param y:
    :return:
    """
    # body
    draw.ellipse(screen, catColor, (x - 22 + 53, y - 364 + 353, 320, 140))
    draw.ellipse(screen, (0, 0, 0), (x - 22 + 53, y - 364 + 353, 320, 140), 1)

    # front legs
    draw.ellipse(screen, catColor, (x - 22 + 43, y - 364 + 433, 28, 41))
    draw.ellipse(screen, (0, 0, 0), (x - 22 + 43, y - 364 + 433, 28, 41), 1)
    draw.ellipse(screen, catColor, (x - 22 + 70, y - 364 + 456, 70, 40))
    draw.ellipse(screen, (0, 0, 0), (x - 22 + 70, y - 364 + 456, 70, 40), 1)

    # head
    draw.circle(screen, catColor, (x - 22 + 75, y - 364 + 413), 50)
    draw.circle(screen, (0, 0, 0), (x - 22 + 75, y - 364 + 413), 50, 1)

    # ears
    draw.polygon(screen, pink, ((x - 22 + 22, y - 364 + 364), (x - 22 + 45, y - 364 + 373),
                                (x - 22 + 29, y - 364 + 391)))  # left ear
    draw.polygon(screen, red, ((x - 22 + 22, y - 364 + 364), (x - 22 + 45, y - 364 + 373),
                               (x - 22 + 29, y - 364 + 391)), 4)  # left ear
    draw.polygon(screen, pink, ((x - 22 + 113, y - 364 + 357), (x - 22 + 114, y - 364 + 382),
                                (x - 22 + 96, y - 364 + 368)))  # right ear
    draw.polygon(screen, red, ((x - 22 + 113, y - 364 + 357), (x - 22 + 114, y - 364 + 382),
                               (x - 22 + 96, y - 364 + 368)), 4)  # right ear

    # eyes
    draw.circle(screen, orange, (x - 22 + 54, y - 364 + 413), 17)  # left eye
    draw.circle(screen, orange, (x - 22 + 96, y - 364 + 413), 17)  # right eye

    # pupils
    draw.ellipse(screen, (0, 0, 0), (x - 22 + 56, y - 364 + 400, 4, 26))  # left pupil
    draw.ellipse(screen, (0, 0, 0), (x - 22 + 98, y - 364 + 400, 4, 26))  # right pupil

    # blick on left eye
    surface = pygame.Surface((10, 10))
    surface.fill(catColor)
    draw.ellipse(surface, (255, 255, 255), (x - 22 + 0, y - 364 + 0, 5, 10))
    a = pygame.transform.rotate(surface, 50)
    screen.blit(a, (x - 22 + 43, y - 364 + 397))
    draw.circle(screen, (0, 0, 0), (x - 22 + 54, y - 364 + 413), 17, 1)

    # blick on right eye
    surface1 = pygame.Surface((10, 10))
    surface1.fill(catColor)
    draw.ellipse(surface, (255, 255, 255), (x - 22 + 0, y - 364 + 0, 5, 10))
    b = pygame.transform.rotate(surface, 50)
    screen.blit(b, (x - 22 + 84, y - 364 + 397))
    draw.circle(screen, (0, 0, 0), (x - 22 + 96, y - 364 + 413), 17, 1)

    # nose
    draw.polygon(screen, pink, ((x - 22 + 70, y - 364 + 433), (x - 22 + 78, y - 364 + 433),
                                (x - 22 + 74, y - 364 + 438)))
    draw.polygon(screen, (0, 0, 0), ((x - 22 + 69, y - 364 + 432), (x - 22 + 79, y - 364 + 432),
                                     (x - 22 + 74, y - 364 + 440)), 1)

    # mouth
    draw.aaline(screen, (0, 0, 0), (x - 22 + 74, y - 364 + 440), (x - 22 + 74, y - 364 + 447))
    draw.arc(screen, (0, 0, 0), (x - 22 + 75, y - 364 + 444, 10, 6), math.pi, 0)
    draw.arc(screen, (0, 0, 0), (x - 22 + 65, y - 364 + 444, 10, 6), math.pi, 0)

    # tale
    surface_tail = pygame.Surface((200, 100))
    surface_tail.fill((0, 128, 0))
    surface_tail.set_colorkey(catColor)
    surface_tail.set_colorkey((0, 128, 0))
    draw.ellipse(surface_tail, catColor, (0, 0, 180, 60))
    draw.ellipse(surface_tail, (0, 0, 0), (0, 0, 180, 60), 1)
    c = pygame.transform.rotate(surface_tail, -30)
    screen.blit(c, (x - 22 + 280, y - 364 + 360))

    # back legs
    draw.circle(screen, catColor, (x - 22 + 340, y - 364 + 458), 42)
    draw.circle(screen, (0, 0, 0), (x - 22 + 340, y - 364 + 458), 42, 1)
    draw.ellipse(screen, catColor, (x - 22 + 362, y - 364 + 468, 28, 65))
    draw.ellipse(screen, (0, 0, 0), (x - 22 + 362, y - 364 + 468, 28, 65), 1)

    # moustache
    draw.arc(screen, (0, 0, 0), (x - 22 + 78, y - 364 + 428, 120, 50), math.pi/3, 5*math.pi/6)
    draw.arc(screen, (0, 0, 0), (x - 22 + 70, y - 364 + 434, 130, 50), math.pi/3, 4*math.pi/5.3)
    draw.arc(screen, (0, 0, 0), (x - 22 + 62, y - 364 + 440, 140, 50), math.pi/3, 4*math.pi/5.55)

    draw.arc(screen, (0, 0, 0), (x - 22 - 48, y - 364 + 425, 120, 50), math.pi/6, 5*math.pi/6)
    draw.arc(screen, (0, 0, 0), (x - 22 - 56, y - 364 + 430, 130, 50), math.pi/5.4, 5*math.pi/6)
    draw.arc(screen, (0, 0, 0), (x - 22 - 64, y - 364 + 435, 140, 50), math.pi/5.1, 5*math.pi/6)