Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CI320
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wellington Gabriel Vicente de Souza
CI320
Commits
cf854af1
Commit
cf854af1
authored
7 years ago
by
Wellington Gabriel Vicente de Souza
Browse files
Options
Downloads
Patches
Plain Diff
[T3] add polygon functions
parent
d60631f6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
T3/canvas.css
+11
-0
11 additions, 0 deletions
T3/canvas.css
T3/lines.html
+7
-1
7 additions, 1 deletion
T3/lines.html
T3/lines.js
+60
-0
60 additions, 0 deletions
T3/lines.js
with
78 additions
and
1 deletion
T3/canvas.css
+
11
−
0
View file @
cf854af1
...
@@ -11,4 +11,15 @@ canvas {
...
@@ -11,4 +11,15 @@ canvas {
display
:
block
;
display
:
block
;
height
:
100%
;
height
:
100%
;
width
:
100%
;
width
:
100%
;
}
div
{
position
:
absolute
;
left
:
10px
;
top
:
10px
;
width
:
300px
;
}
#number
{
width
:
50px
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
T3/lines.html
+
7
−
1
View file @
cf854af1
...
@@ -8,7 +8,13 @@
...
@@ -8,7 +8,13 @@
<canvas
id=
"canvas"
>
<canvas
id=
"canvas"
>
Your browser does not support the HTML5 canvas tag.
Your browser does not support the HTML5 canvas tag.
</canvas>
</canvas>
<p>
asdsadsa
</p>
<div>
<h3>
Gerador de Polígonos
</h3>
Informe um número de 3 a 8:
<input
type=
"number"
id=
"number"
step=
"1"
min=
"3"
max=
"8"
value=
"3"
required
/>
<input
type=
"submit"
onclick=
"generatePolygon()"
value=
"Gerar"
/>
<span
class=
"validity"
></span>
</div>
</body>
</body>
<script
type=
"text/javascript"
src=
"lines.js"
></script>
<script
type=
"text/javascript"
src=
"lines.js"
></script>
...
...
This diff is collapsed.
Click to expand it.
T3/lines.js
+
60
−
0
View file @
cf854af1
...
@@ -155,6 +155,66 @@ function handleMouse() {
...
@@ -155,6 +155,66 @@ function handleMouse() {
}
}
}
}
function
generatePolygon
()
{
edges
=
parseInt
(
document
.
getElementById
(
"
number
"
).
value
,
10
);
if
(
edges
>=
3
&&
edges
<=
8
)
{
lines
=
[];
switch
(
edges
)
{
case
3
:
lines
=
[
new
Line
(
centerX
,
centerY
-
300
,
centerX
+
300
,
centerY
+
300
),
//linha \
new
Line
(
centerX
,
centerY
-
300
,
centerX
-
300
,
centerY
+
300
),
//linha /
new
Line
(
centerX
-
300
,
centerY
+
300
,
centerX
+
300
,
centerY
+
300
)];
//linha _
break
;
case
4
:
lines
=
[
new
Line
(
centerX
-
300
,
200
,
centerX
+
300
,
200
),
//linha _ topo
new
Line
(
centerX
+
300
,
200
,
centerX
+
300
,
800
),
//linha | direita
new
Line
(
centerX
-
300
,
200
,
centerX
-
300
,
800
),
//linha | esquerda
new
Line
(
centerX
-
300
,
800
,
centerX
+
300
,
800
)];
//linha _ baixo
break
;
case
5
:
lines
=
[
new
Line
(
centerX
,
centerY
-
350
,
centerX
+
300
,
centerY
-
150
),
//linha \ direita
new
Line
(
centerX
,
centerY
-
350
,
centerX
-
300
,
centerY
-
150
),
//linha / esquerda
new
Line
(
centerX
+
300
,
centerY
-
150
,
centerX
+
215
,
centerY
+
200
),
//linha \ esquerda
new
Line
(
centerX
-
300
,
centerY
-
150
,
centerX
-
215
,
centerY
+
200
),
//linha / direita
new
Line
(
centerX
-
215
,
centerY
+
200
,
centerX
+
215
,
centerY
+
200
)];
//linha _ baixo
break
;
case
6
:
lines
=
[
new
Line
(
centerX
-
200
,
200
,
centerX
+
200
,
200
),
//linha _ topo
new
Line
(
centerX
-
200
,
200
,
centerX
-
400
,
550
),
//linha / esq
new
Line
(
centerX
-
400
,
550
,
centerX
-
200
,
900
),
//linha \ esq
new
Line
(
centerX
+
200
,
200
,
centerX
+
400
,
550
),
//linha / dir
new
Line
(
centerX
+
400
,
550
,
centerX
+
200
,
900
),
//linha \ dir
new
Line
(
centerX
-
200
,
900
,
centerX
+
200
,
900
)];
//linha _ baixo
break
;
case
7
:
lines
=
[
new
Line
(
centerX
-
250
,
300
,
centerX
,
200
),
//linha / topo
new
Line
(
centerX
,
200
,
centerX
+
250
,
300
),
//linha / topo
new
Line
(
centerX
-
250
,
300
,
centerX
-
350
,
630
),
//linha / esq
new
Line
(
centerX
+
250
,
300
,
centerX
+
350
,
630
),
//linha \ dir
new
Line
(
centerX
-
350
,
630
,
centerX
-
170
,
900
),
//linha \ esq
new
Line
(
centerX
+
350
,
630
,
centerX
+
170
,
900
),
//linha / dir
new
Line
(
centerX
-
170
,
900
,
centerX
+
170
,
900
)];
//linha _ baixo
break
;
case
8
:
lines
=
[
new
Line
(
centerX
-
220
,
100
,
centerX
+
220
,
100
),
//linha _ topo
new
Line
(
centerX
-
220
,
100
,
centerX
-
420
,
375
),
//linha / esq
new
Line
(
centerX
-
420
,
375
,
centerX
-
420
,
650
),
//linha | esq
new
Line
(
centerX
-
420
,
650
,
centerX
-
220
,
925
),
//linha \ esq
new
Line
(
centerX
+
220
,
100
,
centerX
+
420
,
375
),
//linha / esq
new
Line
(
centerX
+
420
,
375
,
centerX
+
420
,
650
),
//linha | esq
new
Line
(
centerX
+
420
,
650
,
centerX
+
220
,
925
),
//linha \ esq
new
Line
(
centerX
-
220
,
925
,
centerX
+
220
,
925
)];
//linha _ baixo
break
;
default
:
break
;
}
drawCurrentCanvas
();
}
else
{
console
.
log
(
"
Valor inválido.
"
);
alert
(
"
Valor inválido! O número de arestas deve estar no intervalo de [3..8].
"
)
}
}
//function that updates screen
//function that updates screen
function
drawCurrentCanvas
()
{
function
drawCurrentCanvas
()
{
drawLines
();
drawLines
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment