-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavatar.html
116 lines (98 loc) · 2.79 KB
/
avatar.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
<html>
<head>
<script src="avatar.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"
media="screen">
<style>
body {
font-family: helvetica, arial, "lucida grande", verdana, "メイリオ", "MS Pゴシック", sans-serif;
font-size: 1.2em;
color: #00406D;
}
#window {
width: 400px;
height: 400px;
margin: auto;
border: 2px dashed #00406D;
overflow: hidden;
border-radius: 15px;
}
#avatar {
height: 200px;
width: 200px;
position: relative;
border: 100px solid rgba(255, 255, 255, 0.5);
cursor: move;
}
#blurb {
width: 400px;
margin: auto;
}
.component {
width: 100%;
margin: 5px;
height: 30px;
font-size: 18px;
color: #00406D;
}
.avatar-over .fa-camera {
display: none;
}
.fa-upload {
color: green;
display: none;
}
.avatar-over .fa-upload {
display: inline-block;
}
.preview {
display: block;
float: left;
width: 100px;
height: 100px;
border: 1px dashed grey;
margin-top: 15px;
}
.preview img {
width: 100%;
}
.controls {
display: block;
float: left;
width: 290px;
}
</style>
</head>
<body>
<div id="blurb">
<h1><i class="fa fa-user"></i>vatar </h1>
<div id="window">
<div id="avatar"><i class="fa fa-upload fa-5x"></i><i class="fa fa-camera fa-5x"></i> Drag & Drop your image
here
</div>
</div>
<br>
<div>
<div class="preview">
<img id="img-preview">
</div>
<div class="controls">
<input id="zoom" type="range" class="component" value="0" min="0" max="100" step="1">
<input type="text" placeholder="File upload URL" class="component">
<button class="component" id="done"><i class="fa fa-crop"></i> crop</button>
</div>
</div>
</div>
<script>
var avatar = new Avatar('avatar', {border: 100, constrain: 350});
document.getElementById('zoom').addEventListener('input', function () {
avatar.paint(null, 1 + 3 / 100 * this.value);
});
document.getElementById('done').addEventListener('click', function () {
var data = avatar.crop('http://localhost:8081:/upload', function(err,data){
});
document.getElementById('img-preview').src = data;
});
</script>
</body>
</html>