Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
psd.js
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
regiostart
psd.js
Commits
6d3f1eb8
Commit
6d3f1eb8
authored
Mar 28, 2015
by
Ryan LeFevre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compile for web and add text data to node export
parent
2ac22aef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
4 deletions
+95
-4
psd.js
dist/psd.js
+93
-3
layer.coffee
lib/psd/nodes/layer.coffee
+2
-1
No files found.
dist/psd.js
View file @
6d3f1eb8
...
@@ -1674,10 +1674,12 @@ module.exports = NestedSectionDivider = (function(_super) {
...
@@ -1674,10 +1674,12 @@ module.exports = NestedSectionDivider = (function(_super) {
},{
"../layer_info.coffee"
:
26
}],
37
:[
function
(
require
,
module
,
exports
){
},{
"../layer_info.coffee"
:
26
}],
37
:[
function
(
require
,
module
,
exports
){
var
Descriptor
,
LayerInfo
,
TextElements
,
parseEngineData
,
var
Descriptor
,
LayerInfo
,
TextElements
,
parseEngineData
,
_
,
__hasProp
=
{}.
hasOwnProperty
,
__hasProp
=
{}.
hasOwnProperty
,
__extends
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
__hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
__extends
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
__hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
_
=
require
(
'lodash'
);
parseEngineData
=
require
(
'parse-engine-data'
);
parseEngineData
=
require
(
'parse-engine-data'
);
LayerInfo
=
require
(
'../layer_info.coffee'
);
LayerInfo
=
require
(
'../layer_info.coffee'
);
...
@@ -1744,12 +1746,98 @@ module.exports = TextElements = (function(_super) {
...
@@ -1744,12 +1746,98 @@ module.exports = TextElements = (function(_super) {
});
});
};
};
TextElements
.
prototype
.
sizes
=
function
()
{
if
((
this
.
engineData
==
null
)
&&
(
this
.
styles
().
FontSize
==
null
))
{
return
[];
}
return
this
.
styles
().
FontSize
;
};
TextElements
.
prototype
.
alignment
=
function
()
{
var
alignments
;
if
(
this
.
engineData
==
null
)
{
return
[];
}
alignments
=
[
'left'
,
'right'
,
'center'
,
'justify'
];
return
this
.
engineData
.
EngineDict
.
ParagraphRun
.
RunArray
.
map
(
function
(
s
)
{
return
alignments
[
Math
.
min
(
parseInt
(
s
.
ParagraphSheet
.
Properties
.
Justification
,
10
),
3
)];
});
};
TextElements
.
prototype
.
colors
=
function
()
{
if
((
this
.
engineData
==
null
)
||
(
this
.
styles
().
FillColor
==
null
))
{
return
[[
0
,
0
,
0
,
255
]];
}
return
this
.
styles
().
FillColor
.
map
(
function
(
s
)
{
var
values
;
values
=
s
.
Values
.
map
(
function
(
v
)
{
return
Math
.
round
(
v
*
255
);
});
values
.
push
(
values
.
shift
());
return
values
;
});
};
TextElements
.
prototype
.
styles
=
function
()
{
var
data
;
if
(
this
.
engineData
==
null
)
{
return
{};
}
if
(
this
.
_styles
!=
null
)
{
return
this
.
_styles
;
}
data
=
this
.
engineData
.
EngineDict
.
StyleRun
.
RunArray
.
map
(
function
(
r
)
{
return
r
.
StyleSheet
.
StyleSheetData
;
});
return
this
.
_styles
=
_
.
reduce
(
data
,
function
(
m
,
o
)
{
var
k
,
v
;
for
(
k
in
o
)
{
if
(
!
__hasProp
.
call
(
o
,
k
))
continue
;
v
=
o
[
k
];
m
[
k
]
||
(
m
[
k
]
=
[]);
m
[
k
].
push
(
v
);
}
return
m
;
},
{});
};
TextElements
.
prototype
.
toCSS
=
function
()
{
var
css
,
definition
,
k
,
v
;
definition
=
{
'font-family'
:
this
.
fonts
().
join
(
', '
),
'font-size'
:
""
+
(
this
.
sizes
()[
0
])
+
"pt"
,
'color'
:
"rgba("
+
(
this
.
colors
()[
0
].
join
(
', '
))
+
")"
,
'text-align'
:
this
.
alignment
()[
0
]
};
css
=
[];
for
(
k
in
definition
)
{
v
=
definition
[
k
];
if
(
v
==
null
)
{
continue
;
}
css
.
push
(
""
+
k
+
": "
+
v
+
";"
);
}
return
css
.
join
(
"
\n
"
);
};
TextElements
.
prototype
[
"export"
]
=
function
()
{
return
{
value
:
this
.
textValue
,
font
:
this
.
fonts
()[
0
],
left
:
this
.
coords
.
left
,
top
:
this
.
coords
.
top
,
right
:
this
.
coords
.
right
,
bottom
:
this
.
coords
.
bottom
,
transform
:
this
.
transform
};
};
return
TextElements
;
return
TextElements
;
})(
LayerInfo
);
})(
LayerInfo
);
},{
"../descriptor.coffee"
:
5
,
"../layer_info.coffee"
:
26
,
"parse-engine-data"
:
82
}],
38
:[
function
(
require
,
module
,
exports
){
},{
"../descriptor.coffee"
:
5
,
"../layer_info.coffee"
:
26
,
"
lodash"
:
81
,
"
parse-engine-data"
:
82
}],
38
:[
function
(
require
,
module
,
exports
){
var
LayerInfo
,
UnicodeName
,
var
LayerInfo
,
UnicodeName
,
__hasProp
=
{}.
hasOwnProperty
,
__hasProp
=
{}.
hasOwnProperty
,
__extends
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
__hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
__extends
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
__hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
...
@@ -2357,9 +2445,11 @@ module.exports = Layer = (function(_super) {
...
@@ -2357,9 +2445,11 @@ module.exports = Layer = (function(_super) {
};
};
Layer
.
prototype
[
"export"
]
=
function
()
{
Layer
.
prototype
[
"export"
]
=
function
()
{
return
_
.
merge
(
Layer
.
__super__
[
"export"
].
apply
(
this
,
arguments
),
{
var
_ref
;
return
_
.
merge
(
Layer
.
__super__
[
"export"
].
call
(
this
),
{
type
:
'layer'
,
type
:
'layer'
,
mask
:
this
.
layer
.
mask
[
"export"
](),
mask
:
this
.
layer
.
mask
[
"export"
](),
text
:
(
_ref
=
this
.
get
(
'typeTool'
))
!=
null
?
_ref
[
"export"
]()
:
void
0
,
image
:
{}
image
:
{}
});
});
};
};
...
...
lib/psd/nodes/layer.coffee
View file @
6d3f1eb8
...
@@ -7,7 +7,8 @@ module.exports = class Layer extends Node
...
@@ -7,7 +7,8 @@ module.exports = class Layer extends Node
isEmpty
:
->
@
width
is
0
or
@
height
is
0
isEmpty
:
->
@
width
is
0
or
@
height
is
0
export
:
->
export
:
->
_
.
merge
super
,
_
.
merge
super
()
,
type
:
'layer'
type
:
'layer'
mask
:
@
layer
.
mask
.
export
()
mask
:
@
layer
.
mask
.
export
()
text
:
@
get
(
'typeTool'
)
?
.
export
()
image
:
{}
image
:
{}
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