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
Hide 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
)
{
KityMinder
.
registerProtocal
(
'png'
,
function
()
{
function
loadImage
(
url
,
callback
)
{
...
...
@@ -15,8 +14,9 @@ if (!kity.Browser.ie) {
svgXml
,
$svg
,
bgDeclare
=
getComputedStyle
(
domContainer
).
backgroundImage
,
bgUrl
=
/url
\((
.+
)\)
$/
.
exec
(
bgDeclare
)[
1
],
bgDeclare
=
km
.
getStyle
(
'background'
).
toString
(),
bgUrl
=
/url
\((
.+
)\)
/
.
exec
(
bgDeclare
),
bgColor
=
kity
.
Color
.
parse
(
bgDeclare
),
renderContainer
=
km
.
getRenderContainer
(),
renderBox
=
renderContainer
.
getRenderBox
(),
...
...
@@ -29,7 +29,6 @@ if (!kity.Browser.ie) {
ctx
=
canvas
.
getContext
(
'2d'
),
blob
,
DomURL
,
url
,
img
,
finishCallback
;
bgUrl
=
bgUrl
.
replace
(
/"/g
,
''
);
renderContainer
.
translate
(
-
renderBox
.
x
,
-
renderBox
.
y
);
svgXml
=
km
.
getPaper
().
container
.
innerHTML
;
...
...
@@ -60,10 +59,10 @@ if (!kity.Browser.ie) {
canvas
.
width
=
width
+
padding
*
2
;
canvas
.
height
=
height
+
padding
*
2
;
function
fillBackground
(
ctx
,
image
,
width
,
height
)
{
function
fillBackground
(
ctx
,
style
)
{
ctx
.
save
();
ctx
.
fillStyle
=
ctx
.
createPattern
(
image
,
"repeat"
)
;
ctx
.
fillRect
(
0
,
0
,
width
,
height
);
ctx
.
fillStyle
=
style
;
ctx
.
fillRect
(
0
,
0
,
canvas
.
width
,
canvas
.
height
);
ctx
.
restore
();
}
...
...
@@ -75,11 +74,11 @@ if (!kity.Browser.ie) {
var
url
=
canvas
.
toDataURL
(
'png'
);
return
url
;
}
loadImage
(
url
,
function
()
{
var
svgImage
=
this
;
loadImage
(
bgUrl
,
function
()
{
function
drawSVG
()
{
loadImage
(
url
,
function
()
{
var
svgImage
=
this
;
var
downloadUrl
;
fillBackground
(
ctx
,
this
,
canvas
.
width
,
canvas
.
height
);
drawImage
(
ctx
,
svgImage
,
padding
,
padding
);
DomURL
.
revokeObjectURL
(
url
);
downloadUrl
=
generateDataUrl
(
canvas
);
...
...
@@ -87,7 +86,17 @@ if (!kity.Browser.ie) {
finishCallback
(
downloadUrl
);
}
});
});
}
if
(
bgUrl
)
{
loadImage
(
bgUrl
[
1
],
function
()
{
fillBackground
(
ctx
,
ctx
.
createPattern
(
this
,
'repeat'
));
drawSVG
();
});
}
else
{
fillBackground
(
ctx
,
bgColor
.
toString
());
drawSVG
();
}
return
{
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