-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCartoon.py
153 lines (146 loc) · 3.61 KB
/
Cartoon.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import numpy as np
from math import *
def draw():
glClearColor(1, 1, 0, 0)
glClear(GL_COLOR_BUFFER_BIT)
glBegin(GL_POLYGON)
# Body
glColor(0.000, 0.000, 0.545)
glVertex2d(.2, .2)
glVertex2d(-.2, .2)
glVertex2d(-.2, -.2)
glVertex2d(.2, - .2)
glEnd()
# Right Leg
glColor(00.000, 0.000, 0.545)
glBegin(GL_POLYGON)
glVertex2d(.05, - .2)
glVertex2d(.15, - .2)
glVertex2d(.15, -.5)
glVertex2d(.05, - .5)
glEnd()
# Left Leg
glColor(0.000, 0.000, 0.545)
glBegin(GL_POLYGON)
glVertex2d(-.05, - .2)
glVertex2d(-.15, - .2)
glVertex2d(-.15, -.5)
glVertex2d(-.05, - .5)
glEnd()
# Left Hand
glColor(0.000, 0.000, 0.545)
glBegin(GL_POLYGON)
glVertex2d(-.2, .2)
glVertex2d(-.2, .1)
glVertex2d(-.4, -.1)
glVertex2d(-.45, -.05)
glEnd()
# Right Hand
glColor(0.000, 0.000, 0.545)
glBegin(GL_POLYGON)
glVertex2d(.2, .2)
glVertex2d(.2, .1)
glVertex2d(0.4, -.1)
glVertex2d(.45, -.05)
glEnd()
# Neck
glColor(0.000, 0.000, 0.545)
glBegin(GL_POLYGON)
glVertex2d(.035, .2)
glVertex2d(-.035, .2)
glVertex2d(-.035, .28)
glVertex2d(.035, .28)
glEnd()
# Head
glColor(0.000, 0.000, 0.545)
glBegin(GL_POLYGON)
glVertex2d(.2, .28)
glVertex2d(-.2, .28)
glVertex2d(-.2, .52)
glVertex2d(.2, .52)
glEnd()
# Mouth
glColor(0, 0, 0)
glBegin(GL_POLYGON)
a = .02
b = .05
for th in np.arange(0, 2 * pi, .001):
r = (a * b) / sqrt(((b ** 2) * (cos(th) ** 2)) + ((a ** 2) * (sin(th) ** 2)))
x = r * sin(th)
y = r * cos(th)
glVertex2d(x, y + .32)
glEnd()
# Nose
glColor(0, 0, 0)
glBegin(GL_POLYGON)
glVertex2d(0, .41)
glVertex2d(-.03, .37)
glVertex2d(.03, .37)
glEnd()
# Right Eye
glColor(0, 0, 0)
glBegin(GL_POLYGON)
r = .04
for th in np.arange(0, 2 * pi, .001):
x = r * sin(th)
y = r * cos(th)
glVertex2d(x+.09, y+.44)
glEnd()
# Left Eye
glColor(0, 0, 0)
glBegin(GL_POLYGON)
r = .04
for th in np.arange(0, 2 * pi, .001):
x = r * sin(th)
y = r * cos(th)
glVertex2d(x-.09, y+.44)
glEnd()
# Tears
glColor(0.000, 1.000, 1.000)
glBegin(GL_POLYGON)
r = .007
for th in np.arange(0, 2 * pi, .001):
x = r * sin(th)
y = r * cos(th)
glVertex2d(x - .09, y + .37)
glEnd()
glBegin(GL_POLYGON)
for th in np.arange(0, 2 * pi, .001):
x = r * sin(th)
y = r * cos(th)
glVertex2d(x - .09, y + .31)
glEnd()
glBegin(GL_POLYGON)
for th in np.arange(0, 2 * pi, .001):
x = r * sin(th)
y = r * cos(th)
glVertex2d(x - .09, y + .34)
glEnd()
glBegin(GL_POLYGON)
for th in np.arange(0, 2 * pi, .001):
x = r * sin(th)
y = r * cos(th)
glVertex2d(x + .09, y + .37)
glEnd()
glBegin(GL_POLYGON)
for th in np.arange(0, 2 * pi, .001):
x = r * sin(th)
y = r * cos(th)
glVertex2d(x + .09, y + .31)
glEnd()
glBegin(GL_POLYGON)
for th in np.arange(0, 2 * pi, .001):
x = r * sin(th)
y = r * cos(th)
glVertex2d(x + .09, y + .34)
glEnd()
glFlush()
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowSize(600, 600)
glutCreateWindow(b"Likes Please")
glutDisplayFunc(draw)
glutMainLoop()