-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (29 loc) · 1.08 KB
/
app.js
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
function run() {
$("#color, #bgcolor, #rotation").change(function() {
$("#avatar").attr("src", "sofeavatar.php?hex=" + $("#color").val() + "&bghex=" + $("#bgcolor").val() + "&rot=" + $("#rotation").val());
});
$("#random").click(function() {
document.getElementById("color").jscolor.fromRGB(getrandcol(), getrandcol(), getrandcol());
document.getElementById("bgcolor").jscolor.fromRGB(getrandcol(), getrandcol(), getrandcol());
$("#rotation").val(getrandrot());
$("#avatar").attr("src", "sofeavatar.php?hex=" + $("#color").val() + "&bghex=" + $("#bgcolor").val() + "&rot=" + $("#rotation").val());
});
$("#download").click(function() {
$.fileDownload("sofeavatar.php?hex=" + $("#color").val() + "&bghex=" + $("#bgcolor").val() + "&rot=" + $("#rotation").val()+"&dodownload");
});
}
function getrandcol() {
return Math.floor((Math.random() * 255) + 0);
}
function getrandrot() {
$rand = Math.floor((Math.random() * 4) + 1);
if ($rand == 1) {
return 0;
} else if ($rand == 2) {
return 90;
} else if ($rand == 3) {
return 180;
} else if ($rand == 4) {
return 270;
}
}