forked from AlloyTeam/AlloyCrop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
138 lines (120 loc) · 4.98 KB
/
index.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<title>AlloyCrop base on AlloyFinger</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
background-color: black;
text-align: center;
}
#crop_btn {
color: white;
background-color: #836FFF;
height: 40px;
display: inline-block;
line-height: 40px;
width: 110px;
text-align: center;
border-radius: 2px;
}
button{
appearance: none;
-webkit-appearance: none;
border: 0;
background: none;
}
#crop_circle_btn {
color: white;
background-color: #836FFF;
height: 40px;
line-height: 40px;
width: 110px;
text-align: center;
border-radius: 2px;
display: inline-block;
margin-left: 20px;
}
#crop_circle_btn:active,#crop_btn:active{
background-color: #6854e4;
}
</style>
</head>
<body>
<img src="./asset/test.png" style="display: none;">
<div id="crop_result" style="text-align: center; padding-top: 30px; height: 230px; line-height: 300px;"></div>
<button class="btn" id="crop_btn">Crop Rect</button>
<button class="btn" id="crop_circle_btn">Crop Circle</button>
<script src="./asset/transform.js"></script>
<script src="./asset/alloy-finger.js"></script>
<script src="alloy-crop.js"></script>
<script>
; (function () {
var crop_btn = document.querySelector("#crop_btn");
var crop_result = document.querySelector("#crop_result");
var crop_circle_btn = document.querySelector("#crop_circle_btn");
var mAlloyCrop;
function showToolPanel() {
crop_btn.style.display = "inline-block";
crop_result.style.display = "block";
crop_circle_btn.style.display = "inline-block";
}
function hideToolPanel() {
crop_btn.style.display = "none";
crop_result.style.display = "none";
crop_circle_btn.style.display = "none";
crop_result.innerHTML = "";
}
new AlloyFinger(crop_btn, {
tap: function () {
hideToolPanel();
mAlloyCrop = new AlloyCrop({
image_src: "./asset/test.png",
width: 200,
height: 100,
output: 1.5,
className: 'm-clip-box',
ok: function (base64, canvas) {
crop_result.appendChild(canvas);
crop_result.querySelector("canvas").style.borderRadius = "0%";
mAlloyCrop.destroy();
showToolPanel();
},
cancel: function () {
mAlloyCrop.destroy();
showToolPanel();
}
});
}
});
new AlloyFinger(crop_circle_btn, {
tap: function () {
hideToolPanel();
mAlloyCrop = new AlloyCrop({
image_src: "./asset/test.png",
circle: true,
width: 200,
height: 200,
output: 1,
ok: function (base64, canvas) {
crop_result.appendChild(canvas);
crop_result.querySelector("canvas").style.borderRadius = "50%";
mAlloyCrop.destroy();
showToolPanel();
},
cancel: function () {
mAlloyCrop.destroy();
showToolPanel();
}
});
}
});
})();
</script>
<a href="https://github.com/AlloyTeam/AlloyCrop">
<img style="position: absolute; top: 0; right: 0; border: 0; z-index: 1000;" src="https://camo.githubusercontent.com/52760788cde945287fbb584134c4cbc2bc36f904/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png">
</a>
</body>
</html>