-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeizer.py
More file actions
70 lines (58 loc) · 1.44 KB
/
Copy pathbeizer.py
File metadata and controls
70 lines (58 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import sys
import pygame
from pygame import gfxdraw
def mul(A, B):
result = [[0, 0, 0, 0]]
for i in range(len(A)):
for j in range(len(B[0])):
for k in range(len(B)):
result[i][j] += A[i][k] * B[k][j]
return result
def beizer(Cx, Cy):
B = [[-1, 3, -3, 1], [3, -6, 3, 0], [-3, 3, 0, 0], [1, 0, 0, 0]]
t = 0
A = [[0, 0, 0, 0]]
while(t < 1):
A[0][0] = t*t*t
A[0][1] = t*t
A[0][2] = t
A[0][3] = 1
C = mul(A, B)
D1 = mul(C, Cx)
D2 = mul(C, Cy)
gfxdraw.pixel(screen, round(D1[0][0]), round(D2[0][0]), (0, 0, 0))
t = t+0.005
pygame.init()
screen = pygame.display.set_mode((640, 480))
screen.fill((255, 255, 255))
pygame.display.flip()
white = (255, 255, 255)
# left neck
Cx = [[90], [100], [100], [90]]
Cy = [[20], [40], [60], [80]]
beizer(Cx, Cy)
# right neck
Cx = [[130], [120], [120], [130]]
Cy = [[20], [40], [60], [80]]
beizer(Cx, Cy)
# top
Cx = [[90], [110], [110], [130]]
Cy = [[20], [25], [25], [20]]
beizer(Cx, Cy)
# left body
Cx = [[90], [60], [60], [100]]
Cy = [[80], [110], [140], [170]]
beizer(Cx, Cy)
# right body
Cx = [[130], [160], [160], [120]]
Cy = [[80], [110], [140], [170]]
beizer(Cx, Cy)
# bottom
Cx = [[100], [105], [115], [120]]
Cy = [[170], [170], [170], [170]]
beizer(Cx, Cy)
pygame.display.update()
while 1:
for event in pygame.event.get():
if(event.type == pygame.QUIT):
sys.exit()