# pygame 练习之 PIE game （以及简单图形训练）

``` 1 import math
2 import pygame, sys
3 from pygame.locals import *
4 pygame.init()
5 screen = pygame.display.set_mode((600, 500))
6 pygame.display.set_caption("The Pie Game -- Press 1 2 3 4")
7 myfont = pygame.font.Font(None, 60)
8
9 color = 200, 80, 60
10 width = 5
11 x = 300
12 y = 250
15
16 piece1 = False
17 piece2 = False
18 piece3 = False
19 piece4 = False
20
21 # main game loop
22 while True:
23     for event in pygame.event.get():
24         if event.type == pygame.QUIT:
25             pygame.quit()
26             sys.exit()
27         elif event.type == KEYUP:
28             if event.key == pygame.K_ESCAPE:
29                 pygame.quit()
30                 sys.exit()
31             elif event.key == pygame.K_1:
32                 piece1 = True
33             elif event.key == pygame.K_2:
34                 piece2 = True
35             elif event.key == pygame.K_3:
36                 piece3 = True
37             elif event.key == pygame.K_4:
38                 piece4 = True
39     #clear the screen
40     screen.fill((0,0,200))
41
42     textImg1 = myfont.render("1", True, color)
44
45     textImg2 = myfont.render("2", True, color)
47
48     textImg3 = myfont.render("3", True, color)
50
51     textImg4 = myfont.render("4", True, color)
53
54     #should the pieces be drawn?
55     if piece1:
58         pygame.draw.arc(screen, color, position, start_angle, end_angle, width)
59         pygame.draw.line(screen, color, (x, y), (x, y-radius), width)
60         pygame.draw.line(screen, color, (x, y), (x+radius, y), width)
61
62     if piece2:
65         pygame.draw.arc(screen, color, position, start_angle, end_angle, width)
66         pygame.draw.line(screen, color, (x, y), (x, y-radius), width)
67         pygame.draw.line(screen, color, (x, y), (x-radius, y), width)
68
69     if piece3:
72         pygame.draw.arc(screen, color, position, start_angle, end_angle, width)
73         pygame.draw.line(screen, color, (x, y), (x-radius, y), width)
74         pygame.draw.line(screen, color, (x, y), (x, y+radius), width)
75
76     if piece4:
79         pygame.draw.arc(screen, color, position, start_angle, end_angle, width)
80         pygame.draw.line(screen, color, (x, y), (x, y+radius), width)
81         pygame.draw.line(screen, color, (x, y), (x+radius, y), width)
82
83     #finished?
84     if piece1 and piece2 and piece3 and piece4:
85         color = 0, 255, 0
86
87     pygame.display.update()```

## 40 个用css 绘制出来的简单图形

http://www.codeceo.com/article/40-css-shapes.html 个人觉得svg 应该是更强大些,不过css 是比较简单的应该. Talk Bubble(聊天框) 这个是我比较感兴趣的.

## html5——canva 绘图1简单图形

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> body{background: #131115;} #c1{background: #fbf7fe;} </style> <script> window.onload=f

## 利用Microsoft VC++6.0 的MFC 的绘图工具实现简单图形的绘制

MFC运算功能强大,拥有完备的绘图功能. 在Windows平台上,应用程序的图形设备接口(graphics device interface,GDI)被抽象为设备上下文(Device Context,DC). 在微软基类库MFC中,CDC类是定义设备上下文对象的基类,所有绘图函数都在CDC基类中定义.当需要输出文字或图形时,就需要调用CDC类的成员函数,这些成员函数具备输出文本.绘制图形的功能. 本文讲解的例程全部在TestView.cpp文件的void CTestView::OnDraw(CD