-
Notifications
You must be signed in to change notification settings - Fork 0
/
aula1.html
261 lines (245 loc) · 7.39 KB
/
aula1.html
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/prism.css" />
<link rel="stylesheet" href="css/codemirror.css" />
<title>Técnicas de programação para Games - Aula 1 - Desenhando via programação usando Processing</title>
</head>
<body>
<div class="container">
<h1>Aula 1 - Desenhando com Processing e JavaScript</h1>
<section>
<div class="well">
<label>Objetivos</label>
<ul>
<li>Familiarizar-se com a sintaxe da linguagem JavaScript</li>
<li>Conhecer alguns comandos de desenho do ProcessingJS</li>
<li>Aprender a consultar a documentação do ProcessingJS</li>
</ul>
</div>
</section>
<section>
<h2>Laboratório</h2>
<div class="row laboratorio" codeid="aula1">
<div class="col-md-5">
<div class="form-group">
<textarea class="form-control" rows="16" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
size(360,300);
ellipse(180,150,100,80);</textarea>
</div>
<div class="form-group">
<button class="btn btn-primary btn-block execute">Executar</button>
</div>
<div class="alert alert-danger messagecontainer" style="display:none;"></div>
</div>
<div class="col-md-7">
<canvas></canvas>
</div>
</div>
</section>
<!--
<section>
<h2>Conceitos</h2>
<dl class="dl-horizontal">
<dt>Comandos</dt>
<dd>...</dd>
<dt>Javascript</dt>
<dd>...</dd>
<dt>Comentário</dt>
<dd>...</dd>
<dt>Parâmetros</dt>
<dd>...</dd>
</dl>
</section>-->
<section>
<h2>Comandos Processing JS</h2>
<div class="row">
<div class="col-md-4">
<pre><code class="language-javascript autoprism">//primitivas 2D
arc(x, y, width, height, start, stop)
ellipse(x, y, width, height)
line(x1, y1, x2, y2)
point(x, y)
quad(x1, y1, x2, y2, x3, y3, x4, y4)
rect(x, y, width, height)
triangle(x1, y1, x2, y2, x3, y3)
</code></pre>
</div>
<div class="col-md-4">
<pre><code class="language-javascript autoprism">//cores
background(gray)
background(gray, alpha)
background(red, green, blue)
background(red, green, blue, alpha)
background(color)
background(color, alpha)
background(hex)
background(hex)
background(hex, alpha)
fill(*)
stroke(*)
</code></pre>
</div>
<div class="col-md-4">
<pre><code class="language-javascript autoprism">//texto
text(data, x, y)
text(stringdata, x, y, width, height)
loadFont(fontname)
textFont(font)
textFont(font, size)
// controle de preenchimento/linha
noFill()
noStroke()
strokeWeight(width)
</code></pre>
</div>
</section>
<section>
<h2>Exemplos</h2>
<div class="row">
<div class="col-md-4 example">
<pre><code class="language-javascript">size(360,300);
// esta linha é ignorada pelo programa!
// <- as duas barras iniciam o comentário
// dura até o fim da linha
rect(150,150,50,50); //desenha retângulo
strokeWeight(3); //muda grossura linha
ellipse(150,150,50,50); //desenha elipse
line(200,250,300,200); //linha</code></pre>
<canvas></canvas>
</div>
<div class="col-md-4 example">
<pre><code class="language-javascript">//não esqueça do ponto-e-vírgula
//após cada comando
size(360,300); // largura=360, altura=300
fill(255, 255, 0); //preench. - amarelo
stroke(255, 0, 0); //linha - vermelho
ellipse(150,150,150,150);//desenha elipse
fill(0, 0, 0); //preench. - preto
ellipse(150,150,50,100); //desenha elipse
</code></pre>
<canvas></canvas>
</div>
<div class="col-md-4 example">
<pre><code class="language-javascript">size(360,300);
//aspas simples iniciam e terminam uma string
//escrever "100, 50" na posição (100, 50)
text('100, 50', 100, 50);
fill(0,0,0); //preenchimento preto
//escrever "50, 100" na posição (50, 100)
text('50, 100', 50, 100);
</code></pre>
<canvas></canvas>
</div>
</div>
</section>
<section>
<h2>Exercícios - Escreva o código que tenha a mesma saída</h2>
<div class="row">
<div class="col-md-4">
<div class="example">
<pre class="hidden"><code class="language-javascript ">size(360,300);
fill(255, 255, 0);
ellipse(150,150,150,150);
fill(0, 0, 0);
ellipse(100,130,10,10);
ellipse(200,130,10,10);
line(120, 170, 180, 170);
</code></pre>
<canvas></canvas>
</div>
<div class="laboratorio" codeid="aula1-ex1">
<div class="form-group">
<label>Digite seu código aqui</label>
<textarea class="form-control" rows="16" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
</div>
<div class="form-group">
<button class="btn btn-primary btn-block execute">Executar</button>
</div>
<div class="alert alert-danger messagecontainer" style="display:none;"></div>
<canvas></canvas>
</div>
</div>
<div class="col-md-4">
<div class="example">
<pre class="hidden"><code class="language-javascript ">size(360,300);
background(180,200,255);
fill(0,100,0);
rect(0,180,359,119);
fill(255,255,255);
ellipse(180,220,120,120);
ellipse(180,130,100,100);
ellipse(180,60,80,80);
fill(0,0,0);
ellipse(160,50,5,5);
ellipse(200,50,5,5);
ellipse(180,80,15,10);
fill(255,50,0);
ellipse(180,60,15,15);
</code></pre>
<canvas></canvas>
</div>
<div class="laboratorio" codeid="aula1-ex2">
<div class="form-group">
<label>Digite seu código aqui</label>
<textarea class="form-control" rows="16" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
</div>
<div class="form-group">
<button class="btn btn-primary btn-block execute">Executar</button>
</div>
<div class="alert alert-danger messagecontainer" style="display:none;"></div>
<canvas></canvas>
</div>
</div>
<div class="col-md-4">
<div class="example">
<pre class="hidden"><code class="language-javascript ">size(360,300);
strokeWeight(4);
stroke(0,0,0);
fill(255, 255, 0);
ellipse(180,150,150,150);
noFill();
stroke(0,0,0);
arc(180, 160, 50, 50, 0, 3.14);
noStroke();
fill(0, 0, 0);
ellipse(130,140,15,15);
ellipse(230,140,15,15);
text('Hello', 160, 50);
</code></pre>
<canvas></canvas>
</div>
<div class="laboratorio" codeid="aula1-ex3">
<div class="form-group">
<label>Digite seu código aqui</label>
<textarea class="form-control" rows="16" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
</div>
<div class="form-group">
<button class="btn btn-primary btn-block execute">Executar</button>
</div>
<div class="alert alert-danger messagecontainer" style="display:none;"></div>
<canvas></canvas>
</div>
</div>
</div>
</section>
<section>
<h2>Referência</h2>
<ul>
<li><a href="https://pt.khanacademy.org/computing/computer-programming/programming/drawing-basics/p/making-drawings-with-code">Desenhando com código (Khan Academy)</a></li>
<li><a href="http://processingjs.org/reference/">ProcessingJS - Reference</a></li>
<li><a href="http://www.w3schools.com/js/js_syntax.asp">JavaScript Syntax (W3Schools)</a></li>
</ul>
</section>
</div>
<script src="js/jquery-3.0.0.min.js"></script>
<script src="js/prism.js" data-manual></script>
<script src="js/processing.min.js"></script>
<script src="js/codemirror.js"></script>
<script src="js/codemirror/mode/javascript/javascript.js"></script>
<script src="js/laboratorio.js"></script>
</body>
</html>