Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
e9ddf87a
Commit
e9ddf87a
authored
Jul 02, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix background export issue
parent
9f991aea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
12 deletions
+21
-12
png.js
src/protocal/png.js
+21
-12
No files found.
src/protocal/png.js
View file @
e9ddf87a
if
(
!
kity
.
Browser
.
ie
)
{
if
(
!
kity
.
Browser
.
ie
)
{
KityMinder
.
registerProtocal
(
'png'
,
function
()
{
KityMinder
.
registerProtocal
(
'png'
,
function
()
{
function
loadImage
(
url
,
callback
)
{
function
loadImage
(
url
,
callback
)
{
...
@@ -15,8 +14,9 @@ if (!kity.Browser.ie) {
...
@@ -15,8 +14,9 @@ if (!kity.Browser.ie) {
svgXml
,
svgXml
,
$svg
,
$svg
,
bgDeclare
=
getComputedStyle
(
domContainer
).
backgroundImage
,
bgDeclare
=
km
.
getStyle
(
'background'
).
toString
(),
bgUrl
=
/url
\((
.+
)\)
$/
.
exec
(
bgDeclare
)[
1
],
bgUrl
=
/url
\((
.+
)\)
/
.
exec
(
bgDeclare
),
bgColor
=
kity
.
Color
.
parse
(
bgDeclare
),
renderContainer
=
km
.
getRenderContainer
(),
renderContainer
=
km
.
getRenderContainer
(),
renderBox
=
renderContainer
.
getRenderBox
(),
renderBox
=
renderContainer
.
getRenderBox
(),
...
@@ -29,7 +29,6 @@ if (!kity.Browser.ie) {
...
@@ -29,7 +29,6 @@ if (!kity.Browser.ie) {
ctx
=
canvas
.
getContext
(
'2d'
),
ctx
=
canvas
.
getContext
(
'2d'
),
blob
,
DomURL
,
url
,
img
,
finishCallback
;
blob
,
DomURL
,
url
,
img
,
finishCallback
;
bgUrl
=
bgUrl
.
replace
(
/"/g
,
''
);
renderContainer
.
translate
(
-
renderBox
.
x
,
-
renderBox
.
y
);
renderContainer
.
translate
(
-
renderBox
.
x
,
-
renderBox
.
y
);
svgXml
=
km
.
getPaper
().
container
.
innerHTML
;
svgXml
=
km
.
getPaper
().
container
.
innerHTML
;
...
@@ -60,10 +59,10 @@ if (!kity.Browser.ie) {
...
@@ -60,10 +59,10 @@ if (!kity.Browser.ie) {
canvas
.
width
=
width
+
padding
*
2
;
canvas
.
width
=
width
+
padding
*
2
;
canvas
.
height
=
height
+
padding
*
2
;
canvas
.
height
=
height
+
padding
*
2
;
function
fillBackground
(
ctx
,
image
,
width
,
height
)
{
function
fillBackground
(
ctx
,
style
)
{
ctx
.
save
();
ctx
.
save
();
ctx
.
fillStyle
=
ctx
.
createPattern
(
image
,
"repeat"
)
;
ctx
.
fillStyle
=
style
;
ctx
.
fillRect
(
0
,
0
,
width
,
height
);
ctx
.
fillRect
(
0
,
0
,
canvas
.
width
,
canvas
.
height
);
ctx
.
restore
();
ctx
.
restore
();
}
}
...
@@ -75,11 +74,11 @@ if (!kity.Browser.ie) {
...
@@ -75,11 +74,11 @@ if (!kity.Browser.ie) {
var
url
=
canvas
.
toDataURL
(
'png'
);
var
url
=
canvas
.
toDataURL
(
'png'
);
return
url
;
return
url
;
}
}
function
drawSVG
()
{
loadImage
(
url
,
function
()
{
loadImage
(
url
,
function
()
{
var
svgImage
=
this
;
var
svgImage
=
this
;
loadImage
(
bgUrl
,
function
()
{
var
downloadUrl
;
var
downloadUrl
;
fillBackground
(
ctx
,
this
,
canvas
.
width
,
canvas
.
height
);
drawImage
(
ctx
,
svgImage
,
padding
,
padding
);
drawImage
(
ctx
,
svgImage
,
padding
,
padding
);
DomURL
.
revokeObjectURL
(
url
);
DomURL
.
revokeObjectURL
(
url
);
downloadUrl
=
generateDataUrl
(
canvas
);
downloadUrl
=
generateDataUrl
(
canvas
);
...
@@ -87,7 +86,17 @@ if (!kity.Browser.ie) {
...
@@ -87,7 +86,17 @@ if (!kity.Browser.ie) {
finishCallback
(
downloadUrl
);
finishCallback
(
downloadUrl
);
}
}
});
});
}
if
(
bgUrl
)
{
loadImage
(
bgUrl
[
1
],
function
()
{
fillBackground
(
ctx
,
ctx
.
createPattern
(
this
,
'repeat'
));
drawSVG
();
});
});
}
else
{
fillBackground
(
ctx
,
bgColor
.
toString
());
drawSVG
();
}
return
{
return
{
then
:
function
(
callback
)
{
then
:
function
(
callback
)
{
...
...
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