Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
php
/
pingan-marathon
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
13f90a2c
authored
Nov 09, 2019
by
doszhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dos
parent
774236ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
121 additions
and
4 deletions
+121
-4
Public/static/css/index.css
+6
-0
Public/static/js/common.js
+115
-4
No files found.
Public/static/css/index.css
View file @
13f90a2c
...
...
@@ -38,3 +38,8 @@ input::-webkit-input-placeholder {
.hd
{
background
:
rgba
(
0
,
0
,
0
,
0.8
);
}
#myCanvas
{
width
:
330px
;
height
:
330px
;
}
\ No newline at end of file
Public/static/js/common.js
View file @
13f90a2c
...
...
@@ -44,7 +44,8 @@ if ($('div').length > 0) {
// var myCanvas;
var
myCanvas
;
var
ctx
;
// var username = '';
preloadimages
(
preloadImageList
,
function
()
{
...
...
@@ -54,7 +55,7 @@ preloadimages(preloadImageList, function () {
});
// $('input[name=username]').attr('placeholder','点击输入您的名字');
// $('.canvas-block').html('<canvas id="myCanvas" width="'+ pxchange(315) +'" height="'+ pxchange(316) +'"></canvas><img class="posterimg" /
>');
$
(
'.canvas-block'
).
html
(
'<canvas id="myCanvas" width="'
+
330
+
'" height="'
+
330
+
'"></canvas
>'
);
$
(
'.page1'
).
show
();
...
...
@@ -68,6 +69,105 @@ $(document).ready(function () {
$
(
'.logo-bottom'
).
css
(
'top'
,
parseInt
(
getTranslateDistance
(
$
(
'.wrap'
).
height
()))
-
50
+
'px'
);
$
(
'.btn-go'
).
on
(
'click'
,
homeBtnGoHandleClick
);
$
(
'[name=upload]'
).
change
(
function
()
{
imgInfo
.
rotation
=
0
;
imgInfo
.
x
=
0
;
imgInfo
.
y
=
0
;
imgInfo
.
scale
=
1
;
event
.
preventDefault
();
var
imgData
=
this
.
files
[
0
];
EXIF
.
getData
(
imgData
,
function
()
{
//获取旋转信息
var
orientation
=
EXIF
.
getTag
(
this
,
"Orientation"
);
switch
(
orientation
)
{
case
3
:
imgInfo
.
rotation
=
180
;
break
;
case
6
:
imgInfo
.
rotation
=
90
;
break
;
case
8
:
imgInfo
.
rotation
=
270
;
break
;
default
:
imgInfo
.
rotation
=
0
;
}
if
(
navigator
.
userAgent
.
indexOf
(
'iPhone'
)
>
-
1
)
{
imgInfo
.
rotation
=
0
;
}
lrz
(
imgData
,
{
width
:
640
},
function
(
results
)
{
img
=
new
Image
();
img
.
onload
=
function
()
{
$
(
'.btn_test'
).
hide
();
$
(
'.btn_holder'
).
show
();
$
(
'.page_test .picture'
).
css
({
'opacity'
:
0
,
'-webkit-animation'
:
'none'
,
'animation'
:
'none'
,
'z-index'
:
9
});
drawImage
();
results
=
null
;
imgData
=
null
;
};
img
.
src
=
results
.
base64
;
});
});
return
false
;
});
var
mc
=
new
Hammer
(
$
(
'.template1'
).
get
(
0
));
mc
.
get
(
'pan'
).
set
({
direction
:
Hammer
.
DIRECTION_ALL
});
mc
.
get
(
'pinch'
).
set
({
enable
:
true
});
mc
.
get
(
'rotate'
).
set
({
enable
:
true
});
var
oldpoz
=
{};
mc
.
on
(
'panstart panmove panend'
,
function
(
event
)
{
if
(
!
img
)
{
return
;
}
if
(
event
.
type
==
'panstart'
||
event
.
type
==
'panend'
)
{
oldpoz
.
x
=
0
;
oldpoz
.
y
=
0
;
}
else
{
var
movedX
=
(
event
.
deltaX
-
oldpoz
.
x
);
var
movedY
=
(
event
.
deltaY
-
oldpoz
.
y
);
oldpoz
.
x
=
event
.
deltaX
;
oldpoz
.
y
=
event
.
deltaY
;
//console.log("movedX:" + movedX + ' movedY:' + movedY + 'event.deltaX:' + event.deltaX + ' event.deltaY:' + event.deltaY + "\r\n");
imgInfo
.
x
+=
movedX
;
imgInfo
.
y
+=
movedY
;
drawImage
();
}
});
var
oldScale
=
1
;
mc
.
on
(
'pinchstart pinchmove pinchend'
,
function
(
event
)
{
if
(
!
img
)
{
return
;
}
if
(
event
.
type
==
'pinchstart'
||
event
.
type
==
'pinchend'
)
{
oldScale
=
1
;
}
else
{
var
nowScale
=
event
.
scale
/
oldScale
;
oldScale
=
event
.
scale
;
imgInfo
.
scale
*=
nowScale
;
drawImage
();
}
});
var
oldRotation
=
0
;
mc
.
on
(
'rotatestart rotatemove rotateend'
,
function
(
event
)
{
if
(
!
img
)
{
return
;
}
if
(
event
.
type
==
'rotatestart'
||
event
.
type
==
'rotateend'
)
{
oldRotation
=
0
;
}
else
{
nowRotation
=
event
.
rotation
-
oldRotation
;
oldRotation
=
event
.
rotation
;
imgInfo
.
rotation
+=
nowRotation
;
drawImage
();
}
});
});
function
homeBtnGoHandleClick
()
...
...
@@ -76,6 +176,17 @@ function homeBtnGoHandleClick()
$
(
'.btn-tocreate,.copywriting2'
).
delay
(
200
).
fadeIn
(
300
);
}
function
drawImage
()
{
ctx
.
save
();
ctx
.
clearRect
(
0
,
0
,
myCanvas
.
width
,
myCanvas
.
height
);
ctx
.
translate
(
myCanvas
.
width
/
2
,
myCanvas
.
height
/
2
);
ctx
.
translate
(
imgInfo
.
x
,
imgInfo
.
y
);
ctx
.
rotate
(
Math
.
PI
/
180
*
imgInfo
.
rotation
);
ctx
.
scale
(
imgInfo
.
scale
,
imgInfo
.
scale
);
ctx
.
drawImage
(
img
,
-
img
.
width
/
2
,
-
img
.
height
/
2
);
ctx
.
restore
();
}
function
checkWord
(
name
,
callback
)
{
$
.
ajax
({
url
:
'index/checkWord'
,
...
...
@@ -130,8 +241,8 @@ function initCanvas() {
myCanvas
=
$
(
'#myCanvas'
)[
0
];
ctx
=
myCanvas
.
getContext
(
"2d"
);
ctx
.
scale
(
2
,
2
);
myCanvas
.
width
=
12
60
;
myCanvas
.
height
=
1264
;
myCanvas
.
width
=
6
60
;
myCanvas
.
height
=
660
;
}
function
getTranslateDistance
(
cardinal
=
0
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment