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
ad21712f
Commit
ad21712f
authored
May 04, 2014
by
Ryan LeFevre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change children to a function for consistency
parent
33021c04
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
12 deletions
+14
-12
parse.js
examples/parse.js
+1
-1
node.coffee
lib/psd/node.coffee
+3
-3
ancestry.coffee
lib/psd/nodes/ancestry.coffee
+5
-3
group.coffee
lib/psd/nodes/group.coffee
+2
-2
root.coffee
lib/psd/nodes/root.coffee
+3
-3
No files found.
examples/parse.js
View file @
ad21712f
...
@@ -8,4 +8,4 @@ console.log(psd.header.export());
...
@@ -8,4 +8,4 @@ console.log(psd.header.export());
// console.log("Finished!");
// console.log("Finished!");
// });
// });
console
.
log
(
psd
.
tree
().
children
[
0
].
children
[
0
].
nextSibling
().
export
());
console
.
log
(
psd
.
tree
().
children
()[
0
].
children
()[
0
].
nextSibling
().
export
());
\ No newline at end of file
\ No newline at end of file
lib/psd/node.coffee
View file @
ad21712f
...
@@ -10,7 +10,7 @@ module.exports = class Node extends Module
...
@@ -10,7 +10,7 @@ module.exports = class Node extends Module
constructor
:
(
@
layer
,
@
parent
=
null
)
->
constructor
:
(
@
layer
,
@
parent
=
null
)
->
@
layer
.
node
=
@
@
layer
.
node
=
@
@
children
=
[]
@
_
children
=
[]
@
name
=
@
layer
.
name
@
name
=
@
layer
.
name
...
@@ -82,11 +82,11 @@ module.exports = class Node extends Module
...
@@ -82,11 +82,11 @@ module.exports = class Node extends Module
updateDimensions
:
->
updateDimensions
:
->
return
if
@
isLayer
()
return
if
@
isLayer
()
child
.
updateDimensions
()
for
child
in
@
children
child
.
updateDimensions
()
for
child
in
@
_
children
return
if
@
isRoot
()
return
if
@
isRoot
()
nonEmptyChildren
=
@
children
.
filter
((
c
)
->
not
c
.
isEmpty
())
nonEmptyChildren
=
@
_
children
.
filter
((
c
)
->
not
c
.
isEmpty
())
@
left
=
_
.
min
(
nonEmptyChildren
.
map
((
c
)
->
c
.
left
))
or
0
@
left
=
_
.
min
(
nonEmptyChildren
.
map
((
c
)
->
c
.
left
))
or
0
@
top
=
_
.
min
(
nonEmptyChildren
.
map
((
c
)
->
c
.
top
))
or
0
@
top
=
_
.
min
(
nonEmptyChildren
.
map
((
c
)
->
c
.
top
))
or
0
@
bottom
=
_
.
max
(
nonEmptyChildren
.
map
((
c
)
->
c
.
bottom
))
or
0
@
bottom
=
_
.
max
(
nonEmptyChildren
.
map
((
c
)
->
c
.
bottom
))
or
0
...
...
lib/psd/nodes/ancestry.coffee
View file @
ad21712f
...
@@ -7,16 +7,18 @@ module.exports =
...
@@ -7,16 +7,18 @@ module.exports =
isRoot
:
->
@
depth
()
is
0
isRoot
:
->
@
depth
()
is
0
children
:
->
@
_children
ancestors
:
->
ancestors
:
->
return
[]
if
not
@
parent
?
or
@
parent
.
isRoot
()
return
[]
if
not
@
parent
?
or
@
parent
.
isRoot
()
return
@
parent
.
ancestors
().
concat
[
@
parent
]
return
@
parent
.
ancestors
().
concat
[
@
parent
]
hasChildren
:
->
@
children
.
length
>
0
hasChildren
:
->
@
_
children
.
length
>
0
childless
:
->
not
@
hasChildren
()
childless
:
->
not
@
hasChildren
()
siblings
:
->
siblings
:
->
return
[]
unless
@
parent
?
return
[]
unless
@
parent
?
@
parent
.
children
@
parent
.
children
()
nextSibling
:
->
nextSibling
:
->
return
null
unless
@
parent
?
return
null
unless
@
parent
?
...
@@ -31,7 +33,7 @@ module.exports =
...
@@ -31,7 +33,7 @@ module.exports =
hasSiblings
:
->
@
siblings
().
length
>
1
hasSiblings
:
->
@
siblings
().
length
>
1
onlyChild
:
->
not
@
hasSiblings
()
onlyChild
:
->
not
@
hasSiblings
()
descendants
:
->
_
.
flatten
@
children
.
map
((
n
)
->
n
.
subtree
())
descendants
:
->
_
.
flatten
@
_
children
.
map
((
n
)
->
n
.
subtree
())
subtree
:
->
[
@
].
concat
@
descendants
()
subtree
:
->
[
@
].
concat
@
descendants
()
...
...
lib/psd/nodes/group.coffee
View file @
ad21712f
...
@@ -8,9 +8,9 @@ module.exports = class Group extends Node
...
@@ -8,9 +8,9 @@ module.exports = class Group extends Node
@
get
(
'blendingMode'
)
is
'passthru'
@
get
(
'blendingMode'
)
is
'passthru'
isEmpty
:
->
isEmpty
:
->
return
false
unless
child
.
isEmpty
()
for
child
in
@
children
return
false
unless
child
.
isEmpty
()
for
child
in
@
_
children
export
:
->
export
:
->
_
.
merge
super
(),
_
.
merge
super
(),
type
:
'group'
type
:
'group'
children
:
@
children
.
map
((
c
)
->
c
.
export
())
children
:
@
_children
.
map
((
c
)
->
c
.
export
())
\ No newline at end of file
\ No newline at end of file
lib/psd/nodes/root.coffee
View file @
ad21712f
...
@@ -30,7 +30,7 @@ module.exports = class Root extends Node
...
@@ -30,7 +30,7 @@ module.exports = class Root extends Node
fillOpacity
:
->
255
fillOpacity
:
->
255
export
:
->
export
:
->
children
:
@
children
.
map
((
c
)
->
c
.
export
())
children
:
@
_
children
.
map
((
c
)
->
c
.
export
())
document
:
document
:
width
:
@
width
width
:
@
width
height
:
@
height
height
:
@
height
...
@@ -50,9 +50,9 @@ module.exports = class Root extends Node
...
@@ -50,9 +50,9 @@ module.exports = class Root extends Node
currentGroup
=
new
Group
(
layer
,
_
.
last
(
parseStack
))
currentGroup
=
new
Group
(
layer
,
_
.
last
(
parseStack
))
else
if
layer
.
isFolderEnd
()
else
if
layer
.
isFolderEnd
()
parent
=
parseStack
.
pop
()
parent
=
parseStack
.
pop
()
parent
.
children
.
push
currentGroup
parent
.
children
()
.
push
currentGroup
currentGroup
=
parent
currentGroup
=
parent
else
else
currentGroup
.
children
.
push
new
Layer
(
layer
,
currentGroup
)
currentGroup
.
children
()
.
push
new
Layer
(
layer
,
currentGroup
)
@
updateDimensions
()
@
updateDimensions
()
\ No newline at end of file
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