-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex2.html
More file actions
516 lines (497 loc) · 19.6 KB
/
index2.html
File metadata and controls
516 lines (497 loc) · 19.6 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>大咖-红猫女</title>
<link rel="stylesheet" href="css/css.css">
<style>
#loadRadius{left:50%;top:50%;margin-left:-25px;margin-top:-25px;position:fixed;z-index:10010}
</style>
</head>
<body>
<div class="loading" id="loading">
<canvas id="loadRadius" style="position:fixed;z-index:11000;left:50%;top:50%;margin-left:-25px;margin-top:-25px;"></canvas><p>加载模板中,请稍后..</p></div>
<canvas id="radiusBorder"></canvas>
<div class="loadLogo" style="display:none"><img src="images/Logo1024.png"></div>
<script>
//扇形
var showImg;
CanvasRenderingContext2D.prototype.sector = function (x, y, radius, sDeg, eDeg) {// 初始保存
this.save();// 位移到目标点
this.translate(x, y);
this.beginPath();// 画出圆弧
this.arc(0,0,radius,sDeg, eDeg);// 再次保存以备旋转
this.save();// 旋转至起始角度
this.rotate(eDeg);// 移动到终点,准备连接终点与圆心
this.moveTo(radius,0);// 连接到圆心
this.lineTo(0,0);// 还原
this.restore();// 旋转至起点角度
this.rotate(sDeg);// 从圆心连接到起点
this.lineTo(radius,0);
this.closePath();// 还原到最初保存的状态
this.restore();
return this;
}
var loadwidth=document.getElementById("loading").offsetWidth;
loadwidth=loadwidth/2-25;
var loadheight=document.getElementById("loading").offsetHeight;
loadheight=loadheight/2-50;
document.getElementById("loadRadius").style.left=loadwidth+"px";
document.getElementById("loadRadius").style.top=loadheight+"px";
var ctxLoading = document.getElementById('loadRadius').getContext('2d');
var ctxLoading2 = document.getElementById('loadRadius').getContext('2d');
ctxLoading.fillStyle="#ccc";
ctxLoading2.strokeStyle="#ccc";
ctxLoading2.beginPath();// 画出圆弧
ctxLoading2.arc(50,50,28,0,Math.PI/180*360)
ctxLoading2.stroke();
var deg = Math.PI/180;
ctxLoading.sector(50,50,25,0,Math.PI/180*30).fill();
</script>
<div class="indexMain">
<div class="indexPic"><img src="images/3.jpg"></div>
<form name="myForm" id="myForm" method="POST" enctype="multipart/form-data">
<div class="indexButton">我要制作</div>
<input type="file" id='Files' name='files' class='file' accept='image/*' capture="camera">
</form>
</div>
<div class="ydMain" style="display:none">
<div class="ydBg"></div>
<div class="ydLoadPic" style="display:none;color:#fff"><img src=""></div>
<div class="ydCon">
<p class="yd_1"><img src="images/ydd1.png"></p>
<p class="yd_2"><img src="images/ydd2.png"></p>
<p class="yd_3"><img src="images/ydd3.png"></p>
</div>
<div class="ydCon2" style="display:none;">
<p class="yd_4"><img src="images/ydd4.png"></p>
<p class="yd_2"><img src="images/ydd2.png"></p>
</div>
<div class="ydShow">
<div class="filpButton" style="z-index:10999"><img src="images/filpICON.png"><span>翻转</span></div>
<div class="makeBottom" style="z-index:10999;background:none;left:0;">
<ul>
<li style="opacity:0.3"><i><img src="images/backIcon.png"></i><p>返回</p></li>
<li><i><img src="images/lightIcon.png"></i><p>亮度</p></li>
<li><i><img src="images/colorIcon.png"></i><p>颜色</p></li>
<li style="opacity:0.3"><i><img src="images/okIcon.png"></i><p>结束</p></li>
</ul>
<div class="clear"></div>
</div>
</div>
</div>
<div class="makeMain">
<div class="num" style="position:absolute;left:50%;top:50%;z-index:999;font-size:60px;width:100px;text-align:center;height:60px;line-height:60px;color:#ffffff;font-family:'Arial Black', Gadget, sans-serif;margin-left:-50px;margin-top:-70px;z-index:9999;display:none;">0</div>
<div class="makeBorder" style="width:100%;height:100%;position:fixed;z-index:99;left:100%">
<div id="makeTopPic"><img src="images/7.png" id="ll"></div>
</div>
<div id="yes"></div>
<div id="photo"><img src="" id="photoImg"/></div>
<div id="photo1" style="display:none;"><img src="" id="photoImg1"/></div>
<canvas id="picCanvas" style="z-index:2;display:none"></canvas>
<div class="makeBottom" style="z-index:999">
<ul>
<li class="back"><i><img src="images/backIcon.png"></i><p>返回</p></li>
<li id="light"><i><img src="images/lightIcon.png"></i><p>亮度</p></li>
<li id="color"><i><img src="images/colorIcon.png"></i><p>颜色</p></li>
<li class="makeButton"><i><img src="images/okIcon.png"></i><p>结束</p></li>
</ul>
<div class="clear"></div>
<div class="config" style="display:none">
<div id="configTxt">亮度</div>
<div class="configClose"><img src="images/close.png"></div>
<div class="adjust">
<a class="circle" id="circle" style="display:none;"></a>
<a class="circle" id="circle1" style="display:none;"></a>
</div>
</div>
</div>
<div class="helpButton"><img src="images/helpIcon.png"><span>帮助</span></div>
<div class="filpButton"><img src="images/filpICON.png"><span>翻转</span></div>
</div>
<canvas id="myCanvas"></canvas>
<div id="displaymain" style="position:fixed;left:0;top:0;z-index:20000;width:100%;height:100%;background:#fff;color:#333;display:none"><a id="mainbutton" style="margin-top:100px;margin-bottom:20px;display:block;">跳转</a><p id="mainTXT"></p></div>
</body>
<script>
ctxLoading.sector(50,50,25,Math.PI/180*30,Math.PI/180*100).fill();
</script>
<script src="js/jquery.js"></script>
<script src="js/touch.js"></script>
<script src="js/alloyimage-1.1.js"></script>
<script>ctxLoading.sector(50,50,25,Math.PI/180*30,Math.PI/180*180).fill();</script>
<script src="js/mobileFix.mini.js"></script>
<script src="js/exif.js"></script>
<script src="js/lrz.js"></script>
<script src="js/sha1.js"></script>
<script src="js/RGB2HSV.js"></script>
<script src="js/BrightnessContrast.js"></script>
</html>
<script type="text/javascript">
ctxLoading.sector(50,50,25,Math.PI/180*50,Math.PI/180*260).fill();
function browser() {
var u = navigator.userAgent.toLowerCase();
var app = navigator.appVersion.toLowerCase();
return {
txt: u, // 浏览器版本信息
version: (u.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1], // 版本号
msie: /msie/.test(u) && !/opera/.test(u), // IE内核
mozilla: /mozilla/.test(u) && !/(compatible|webkit)/.test(u), // 火狐浏览器
safari: /safari/.test(u) && !/chrome/.test(u), //是否为safair
chrome: /chrome/.test(u), //是否为chrome
opera: /opera/.test(u), //是否为oprea
presto: u.indexOf('presto/') > -1, //opera内核
webKit: u.indexOf('applewebkit/') > -1, //苹果、谷歌内核
gecko: u.indexOf('gecko/') > -1 && u.indexOf('khtml') == -1, //火狐内核
mobile: !!u.match(/applewebkit.*mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( u;)? cpu.+mac os x/), //ios终端
android: u.indexOf('android') > -1, //android终端
iPhone: u.indexOf('iphone') > -1, //是否为iPhone
iPad: u.indexOf('ipad') > -1, //是否iPad
webApp: !!u.match(/applewebkit.*mobile.*/) && u.indexOf('safari/') == -1 //是否web应该程序,没有头部与底部
};
}
var u = navigator.userAgent.toLowerCase();
var androidMicromessenger
var b=browser();
if(b.android){
if(/micromessenger/.test(u)){
androidMicromessenger=1;
}
else {androidMicromessenger=0}
}
else{androidMicromessenger=0}
window.onload=function(){
var IndexPicHeight=$(".indexPic").height();
$(".indexPic").css("margin-top",-IndexPicHeight/2+"px");
ctxLoading.sector(50,50,25,Math.PI/180*30,Math.PI/180*360).fill();
$(".loading").hide();
var awayLeft=0.1882,awayRight=0.87,awayTop=0.203,_S=3/*饱和度*/,_C=6/*对比度*/,_B=0.3/*亮度*/,_CUR=128-15/*曲线*/,_CUR1=128+15/*曲线*/,_H=17/*色相*/,_G=0/*高斯模糊*/,_SHA=0/*锐化*/;
$("#onloadBg").remove();
var offx,offy,offx1,offx2,colorNum=0,lightNum=100,brightness=1,brightnessLast=0
var isFilp=0,locationSrc,ccc,photoLoading;
var totalAngle=0;
var currentScale=1;
var configColor;
var dx=0,dy=0,bx=0,by=0,cx=0,cy=0;
var circleLeft,dd,evScale
var initialScale = 1;
var picWidth,picHeight;
var currentScaleLast=1;
var angle=0;
var c=new Array();
var picCanvas=document.getElementById("picCanvas");
var mobanWidth
var mobanHeight
document.getElementById('Files').onchange = function (e) {
/*$(".ydMain").show()
*/
var src = window.URL.createObjectURL(this.files[0]);
/* document.getElementById("ydPic").src=src;*/
mobanWidth=$("#ll").width();
mobanHeight=$("#ll").height();
$(".indexMain").animate({left:"-100%"},500);
$(".makeMain").animate({left:"0%"},500);
$(".makeBottom").animate({left:"0%"},500);
$(".makeBorder").animate({left:"0%"},500);
$(".loading").show().css("background","#000");
$("#loadRadius").hide();
$("#radiusBorder").hide();
$(".loadLogo").show();
$(".loading p").html("照片处理中..").css({"position":"relative","z-index":"11000"});
lrz(this.files[0],{width: 320},function(results){
document.getElementById("photoImg").src=results.base64;
locationSrc=results.base64;
var target = document.getElementById("photoImg");
var target1=document.getElementById("photoImg1");
target.style.position="absolute";
target.onload = function ()
{
psLib(this).act("setHSI",_H,_S,0,false). act("brightness",_B,_C).act("curve",[0,_CUR,255], [0,_CUR1,255]).act("gaussBlur",_G).act("sharp",_SHA).replace(this);
document.getElementById("photoImg1").src=this.src;
this.onload = function ()
{
$(".loading").hide();
$(".loadLogo").hide();
if(localStorage.userId==undefined){
$(".ydMain").show();
$(".ydCon p.yd_2").click(function(){
$(".ydCon").hide();
$(".ydCon2").show();
$(".ydLoadPic").show();
$(".ydLoadPic").height($(".ydLoadPic").width())
$(".ydLoadPic img").attr("src",document.getElementById("photoImg1").src)
})
$(".ydCon2 p.yd_2").click(function(){
$(".ydMain").hide();
})
}
var allWidth=$(".makeBorder").width();
var allHeight=$(".makeBorder").height();
picWidth=$("#photoImg").width();
$("#yes").css("width",picWidth+"px")
picHeight=$("#photoImg").height();
$("#yes").css("height",picHeight+"px")
bigPic(awayLeft,awayRight,awayTop,mobanWidth,mobanHeight,false);
target.style.webkitTransition = 'all ease 0.05s';
$("#photoImg").css("-webkit-transform","scale(-1,1)")
var yes=document.getElementById("yes");
picCanvas.width=picWidth;
picCanvas.height=picHeight;
var picCxt=picCanvas.getContext("2d");
picCxt.translate(picWidth,0);
picCxt.scale(-1,1);
picCxt.drawImage(target,0,0,picWidth,picHeight);
var imgData=picCxt.getImageData(0,0,picWidth,picHeight);
var cc=imgData.data;
for(var i=0;i<cc.length;++i){
c[i]=cc[i];
}
$(".back").click(function(e) {
history.go(0);
});
$(".filpButton").click(function(){
if(isFilp==0){
picCxt.translate(picWidth,0);
picCxt.scale(-1,1);
picCxt.drawImage(target,0,0,picWidth,picHeight);
target.style.webkitTransform = 'rotate(' + totalAngle + 'deg) scale('+currentScale+','+currentScale+')';
isFilp=1;
}
else if(isFilp==1){
target.style.webkitTransform = 'rotate(' + totalAngle + 'deg) scale(-'+currentScale+','+currentScale+')';
isFilp=0;
}
})
var picTranseObj2
touch.on('#yes', 'touchstart', function(ev){
ev.preventDefault();
});
touch.on('#yes', 'rotate drag', function(ev){
if(evScale==undefined)evScale=currentScale;
(ev.scale==undefined)?ev.scale=evScale:ev.scale=ev.scale;
if(ev.rotation==undefined)ev.rotation=0;
currentScale = ev.scale - 1;
currentScale = initialScale + currentScale;
currentScale = currentScale > 3 ? 3 : currentScale;
currentScale = currentScale < 0.3 ? 0.3 : currentScale;
totalAngle = angle + ev.rotation;
dx = dx || 0;
dy = dy || 0;
offx = dx + ev.x + "px";
offy = dy + ev.y + "px";
this.style.webkitTransform = 'rotate(' + totalAngle + 'deg) scale('+currentScale+')';
this.style.top=offy;
this.style.left=offx;
if(isFilp==0){
picCanvas.style.webkitTransform = 'rotate(' + totalAngle + 'deg) scale(-'+currentScale+','+currentScale+')';
}else if(isFilp==1){
picCanvas.style.webkitTransform = 'rotate(' + totalAngle + 'deg) scale('+currentScale+','+currentScale+')';
}
picCanvas.style.top=offy;
picCanvas.style.left=offx;
if(isFilp==0){
target.style.webkitTransform = 'rotate(' + totalAngle + 'deg) scale(-'+currentScale+','+currentScale+')';
}else if(isFilp==1){
target.style.webkitTransform = 'rotate(' + totalAngle + 'deg) scale('+currentScale+','+currentScale+')';
}
target.style.top=offy;
target.style.left=offx;
currentScaleLast=currentScale;
if(ev.fingerStatus === 'end'){
angle =totalAngle;
initialScale=currentScale
currentScaleLast=currentScale;
}
});
touch.on('#yes', 'dragend', function(ev){
angle=totalAngle;
currentScaleLast=currentScale;
dx += ev.x;
dy += ev.y;
});
touch.on('#circle', 'touchstart', function(ev){
ev.preventDefault();
});
touch.on('#circle', 'drag', function(ev){
bx = bx || 0;
circleLeft=parseInt($(".adjust").width()*0.5);
offx1=bx+ev.x;
var evX=ev.x;
makeLight(imgData,offx1,evX)
function makeLight(obj,num,evX){
if(num>90||num<-90)return;
var left1=document.getElementById("circle").style.left;
var left;
var left2=num+circleLeft;
if(Number(left1.slice(0,-2))<left2){
left=0
}
else{
left=1;
}
$(".num").show().html(num);
colorNum=num*2;
document.getElementById("circle").style.left=(num+circleLeft)+"px";
}
});
touch.on('#circle', 'dragend', function(ev){
bx += ev.x;
$(".num").hide()
picTranseObj2 = AlloyImage(target1);
var grayPic = picTranseObj2.clone().act("brightness",(brightness-1)*100/3.5,0).act("setHSI",colorNum/1.5,0,0,false);
grayPic.replace(target);
});
touch.on('#circle1', 'touchstart', function(ev){
ev.preventDefault();
});
touch.on('#circle1', 'drag', function(ev){
cx = cx || 0;
circleLeft=parseInt($(".adjust").width()*0.5);
offx2=cx+ev.x;
var evX=ev.x
makeLight(imgData,offx2,evX)
function makeLight(obj,num,evX){
if(num>90||num<-90)return;
var left1=document.getElementById("circle1").style.left;
var left;
var left2=num+circleLeft;
if(Number(left1.slice(0,-2))<left2){
left=0
}
else{
left=1;
}
$(".num").show().html(num);
brightness=1+num/100;
document.getElementById("circle1").style.left=(num+circleLeft)+"px";
}
});
touch.on('#circle1', 'dragend', function(ev){
cx += ev.x;
picTranseObj2 = AlloyImage(target1);
var grayPic = picTranseObj2.clone().act("brightness",(brightness-1)*100/3.5,0).act("setHSI",colorNum/1.5,0,0,false);
grayPic.replace(target);
$(".num").hide()
});
$("#light").click(function(e) {
for(var i=0;i<cc.length;++i){
c[i]=cc[i];
}
$(".config").show();
$("#circle1").show();
$("#configTxt").html("亮度");
$("#circle").hide();
$(this).css("background","#222");
$("#color").css("background","#333");
});
$("#color").click(function(e) {
for(var i=0;i<cc.length;++i){
c[i]=cc[i];
}
$(".config").show();
$("#circle").show();
$("#configTxt").html("颜色");
$("#circle1").hide();
$(this).css("background","#222");
$("#light").css("background","#333");
});
$(".configClose").click(function(e) {
$(".config").hide();
$("#light").css("background","#333");
$("#color").css("background","#333");
});
}
}
})
}
function bigPic(a,b,c,allW,allH,yd){
dd=1/(b-a);
allW=allW*a*dd
allH=allH*c*dd
if(yd==false){
$(".makeBorder").css({"marginLeft":"-"+(allW)+"px","marginTop":"-"+(allH)+"px","-webkit-transform":"scale("+dd+","+dd+")","-webkit-transform-origin":"0% 0%"})}
else{
$(".basePic").css({"marginLeft":"-"+(allW)+"px","marginTop":"-"+(allH)+"px","-webkit-transform":"scale("+dd+","+dd+")","-webkit-transform-origin":"0% 0%"})
}
}
var topPicWidth=$("#makeTopPic").width();
var topPicHeight=$("#makeTopPic").height();
var mainWidth=$(".makeMain").width();
var mainHeight=$(".makeMain").height();
$(".makeButton").click(function(){
$(".loading").show();
$(".loadLogo").show();
$(".loading p").html("图片生成中..");
var target = document.getElementById("photoImg");
if(androidMicromessenger==0){
psLib(target).act("setHSI",1,0,0,false). act("brightness",0,1).replace(target);
}else{
psLib(target).act("setHSI",0,0,0,false). act("brightness",0,0).replace(target);
}
var img=new Image();
img.src=document.getElementById('ll').src;
target.onload=function(){
document.getElementById('myCanvas').width=topPicWidth;
document.getElementById('myCanvas').height=topPicHeight;
picCanvas.width=picWidth;
picCanvas.height=picHeight;
var picCxt=picCanvas.getContext("2d");
if(isFilp==0){
picCxt.translate(picWidth,0);
picCxt.scale(-1,1);
}
picCxt.drawImage(target,0,0,picWidth,picHeight);
var ctx = document.getElementById('myCanvas').getContext('2d');
ctx.save()
/* alert("dd="+dd+",dx="+dx+",dy="+dy+",currentScaleLast="+currentScaleLast+",angle"+angle)*/
var turnLeft=dx/dd;
var turnTop=dy/dd;
var canvasAwayLeft=awayLeft*mobanWidth;
var canvasAwayTop=awayTop*mobanHeight;
var scaleLeft=(picWidth*currentScaleLast-picWidth)/(2*dd)
var scaleTop=(picHeight*currentScaleLast-picHeight)/(2*dd)
ctx.translate(canvasAwayLeft+turnLeft-scaleLeft,canvasAwayTop+turnTop-scaleTop)
ctx.scale(currentScaleLast,currentScaleLast)
ctx.translate(picWidth/dd*0.5,picHeight/dd*0.5)
ctx.rotate(angle*Math.PI/180)
ctx.translate(-picWidth/dd*0.5,-picHeight/dd*0.5)
ctx.drawImage(picCanvas,0,0,picWidth/dd,picHeight/dd)
$(".indexMain").remove()
$(".makeMain").remove()
ctx.restore()
ctx.drawImage(img,0,0,topPicWidth,topPicHeight)
showImg= document.getElementById('myCanvas').toDataURL("image/jpeg");
/*document.write("<img src='"+showImg+"' alt='from canvas' class='dataImg'/>")*/
loadXMLDoc();
}
})
}
ctxLoading.sector(50,50,25,Math.PI/180*30,Math.PI/180*300).fill();
var now=new Date().getTime()-new Date("2001-01-01").getTime();
var appKey = hex_sha1("A6995678227283"+"UZ"+"1ED1BF5A-0DEA-1F4D-1F52-6912CB10ABB0"+"UZ"+now);
Key = appKey+"."+now // 结果 b132021b1389d075d31451b1b174f710f9c6fc1d.461820253716
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
var picId=xmlhttp.responseText
picId=JSON.parse(picId)
picId=picId.id
localStorage.userId=picId;
window.location.href="pic.html?pic="+picId;
}
xmlhttp.open("POST","https://d.apicloud.com/mcm/api/DKWebFile",true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("X-APICloud-AppKey",Key);
xmlhttp.setRequestHeader("X-APICloud-AppId","A6995678227283");
xmlhttp.send("file="+showImg+"&&moban=2&&name=红猫女");
}
</script>