pygame.draw.line
来源:互联网 发布:软件推广渠道 编辑:程序博客网 时间:2024/06/06 09:31
import tracebackimport mathimport pygamefrom pygame.locals import *pygame.display.init()pygame.font.init()sizes = { "screen" : ( 300, 480 )}colors = { "line" : ( 255, 255, 255 ), "rect" : ( 100, 100, 100 ), "circle" : ( 100, 100, 100 ), "border" : ( 52, 135, 184 ), "background" : ( 255, 255, 255 )}screen = pygame.display.set_mode( sizes["screen"], 0, 32 )def cin(): for e in pygame.event.get(): mouse_pos = pygame.mouse.get_pos() print mouse_pos if e.type == KEYDOWN: if e.key == K_ESCAPE: return False return True def draw(): screen.fill( colors["background"] ) ### 1 pygame.draw.line( screen, colors["border"], ( 0, 0 ), ( 0, sizes["screen"][1] ), 10 ) pygame.draw.line( screen, colors["line"], ( 0, 0 ), ( 0, sizes["screen"][1] ), 1 ) ### 2 pygame.draw.line( screen, colors["border"], ( 100, 0 ), ( 100, 300 ), 10 ) pygame.draw.line( screen, colors["line"], ( 100, 0 ), ( 100, 300 ), 1 ) ### 3 pygame.draw.line( screen, colors["border"], ( 200, 100 ), ( 200, -100 ), 10 ) pygame.draw.line( screen, colors["line"], ( 200, 100 ), ( 200, -100 ), 1 ) ### 4 pygame.draw.line( screen, colors["border"], ( sizes["screen"][0], 0 ), ( sizes["screen"][0], sizes["screen"][1] ), 10 ) pygame.draw.line( screen, ( 255, 255, 255 ), ( sizes["screen"][0], 0 ), ( sizes["screen"][0], sizes["screen"][1] ), 1 ) ### 5 pygame.draw.circle( screen, colors["circle"], ( 100, 100 ), 50 ) pygame.draw.arc( screen, colors["circle"], ( 150, 150, 100, 100 ), 0, math.pi, 2 ) ### 6 X = 10 / 2 + 1 DX = 100 - ( ( ( 10 / 2 ) + 1 ) + ( ( 10 / 2 ) - 1 ) ) pygame.draw.rect( screen, colors["rect"], ( X, 200, DX, 50 ) ) pygame.display.update()def prepare( func ): def _pre(): pygame.event.set_grab( True ) func() pygame.event.set_grab( False ) pygame.quit() return _pre@preparedef main(): while True: if not cin(): break draw() if __name__ == '__main__': try: main() except: traceback.print_exc() pygame.quit() input()
==> 先按照元线段上色,再在右边上色,再在左边上色,所以左右长度各为 width / 2 - 1, width / 2 + 1
### 5
==> PyGame 画弧线真难看。
### 6 若要填充矩形,先计算好。(连小学数学也要为难我。。。。)
1 0
- pygame.draw.line
- Draw Line
- Draw Line
- pygame中画圆方法pygame.draw.circle()使用
- CG : Draw Line And Draw Circle
- C# 画线 Draw a Line
- pygame
- pygame
- pygame
- 【pygame】
- Java : how to draw a line in thickness
- Draw Line and Bar Chart with Matplotlib 画线和图表
- C# Graphic - DrawLine - draw line and move it
- pygame库写游戏——入门<7>——python.draw
- Draw
- Draw
- Draw
- DRAW
- 获取文件夹大小
- java jdk windows 环境变量配置
- SqlServer 时分秒函数
- Shell_NotifyIcon
- 登录DS时出现ODBC call 错误
- pygame.draw.line
- spring 自动扫描 注入
- BPM(业务流程管理)和管理系统对比
- scrollview 去掉滚动条
- mysql性能优化概述
- JAVA之代码混淆proguard基础(一)
- windows tomcat 环境变量配置 (建立在jdk环境的正确配置之上)
- BPM(业务流程管理)和管理系统对比
- js 中编码(encode)和解码(decode)的三种方法