-
Notifications
You must be signed in to change notification settings - Fork 0
/
cartao-verso.html
134 lines (118 loc) · 3.94 KB
/
cartao-verso.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"
></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.min.js"></script>
<script>
// some constants
var PLANET_WIDTH = 9,
ASPECT_STROKE = PLANET_WIDTH / 2;
var planets = [];
var data_is_dirty = false,
svgs_are_dirty = true,
__svgs_are_dirty = true,
recalculate_deltas = false;
function retrieve_data(date) {
if (!date) {
console.log("date is empty!");
return;
}
var year = date.slice(0, 4);
var month = date.slice(5, 7);
var day = date.slice(8);
if (parseInt(year) < 1900 || parseInt(year) > 2100) {
alert("Sinto, mas temos dados apenas entre os anos de 1900 e 2100!");
return;
}
$.getJSON("clean_data/" + year + ".json", function(data) {
console.log("Data retrieved for: " + year + "/" + month + "/" + day);
var sign_adjustment = 180;
var angles = [];
// angles = [0,90,180,270,0,90,0];
// angles = [0,0,0,0,0,0,0];
// angles = [270,270,270,270,270,270,270];
angles.push(data[month][day]["sun"] + sign_adjustment);
angles.push(data[month][day]["moon"] + sign_adjustment);
angles.push(data[month][day]["mercury"] + sign_adjustment);
angles.push(data[month][day]["venus"] + sign_adjustment);
angles.push(data[month][day]["mars"] + sign_adjustment);
angles.push(data[month][day]["jupiter"] + sign_adjustment);
angles.push(data[month][day]["saturn"] + sign_adjustment);
planets = angles;
svgs_are_dirty = true;
});
}
function return_date() {
return $("#date").val();
}
function download_svg() {
var file_name = "cartao_verso-" + return_date() + ".svg";
var url =
"data:image/svg+xml;utf8," +
encodeURIComponent(paper.project.exportSVG({ asString: true }));
var link = document.createElement("a");
link.download = file_name;
link.href = url;
link.click();
}
function download_png() {
var file_name = "cartao_frente-" + return_date() + ".png";
var canvas = document.getElementById("canvas-frente"),
ctx = canvas.getContext("2d");
canvas.toBlob(function(blob) {
saveAs(blob, file_name);
});
}
</script>
<script type="text/javascript" src="paper-full.js"></script>
<script
type="text/paperscript"
src="cartao-verso.js"
canvas="canvas-verso"
async
></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="c">
<input
type="date"
id="date"
name="date"
min="1900-01-01"
max="2100-12-31"
/>
<button class="emoji" onclick="retrieve_data($('#date').val());">
🔭
</button>
<br /><br />
<div class="canvas-container" id="canvas-container">
<canvas
id="canvas-verso"
class="default-canvas"
style="width: 284px; height: 195px; box-shadow: 0 1px 2px rgba(0,0,0,0.2);"
></canvas>
</div>
<br /><br />
<button onclick="download_svg()">Download SVG</button>
</div>
<div class="other-pages">
<a href="index.html">logotipo</a>
<a href="cartao-frente.html">cartão-frente</a>
<a class="not-a-link">cartão-verso</a>
<a href="recorte.html">recorte</a>
</div>
<script>
$(function() {
document.getElementById("date").valueAsDate = new Date();
retrieve_data($("#date").val());
});
</script>
</body>
</html>