Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pptist
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
pptist
Commits
a292b2a3
Commit
a292b2a3
authored
May 30, 2024
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化字体旋转角度,缩放计算
parent
1d2d7a34
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
+24
-4
text.ts
src/utils/psdParser/text.ts
+24
-4
No files found.
src/utils/psdParser/text.ts
View file @
a292b2a3
...
@@ -17,16 +17,16 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
...
@@ -17,16 +17,16 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
const
{
colors
,
styles
,
alignment
,
sizes
,
names
,
weights
}
=
font
const
{
colors
,
styles
,
alignment
,
sizes
,
names
,
weights
}
=
font
let
fontSize
=
24.0
let
fontSize
=
24.0
let
newSizes
=
sizes
?
sizes
:[
12
]
let
newSizes
=
sizes
?
sizes
:[
12
]
//if(value=='12980') console.log(newSizes,transform,extractScale(transform))
if
(
newSizes
&&
newSizes
[
0
])
{
if
(
newSizes
&&
newSizes
[
0
])
{
if
(
transform
.
yy
!==
1
)
{
if
(
transform
)
{
fontSize
=
(
Math
.
round
((
newSizes
[
0
]
*
transform
.
yy
)
*
100
)
*
0.01
)
fontSize
=
Math
.
round
(
newSizes
[
0
]
*
extractScale
(
transform
)
)
}
else
{
}
else
{
fontSize
=
newSizes
[
0
]
fontSize
=
newSizes
[
0
]
}
}
}
}
if
(
transform
){
if
(
transform
){
let
angle
=
Math
.
atan2
(
transform
.
xy
,
transform
.
xx
)
transformRotate
=
extractRotation
(
transform
)
transformRotate
=
Math
.
floor
(
angle
*
(
180
/
Math
.
PI
))
}
}
const
StyleSheet
=
item
.
layer
.
adjustments
.
typeTool
.
obj
.
engineData
.
EngineDict
.
StyleRun
.
RunArray
[
0
].
StyleSheet
||
{}
const
StyleSheet
=
item
.
layer
.
adjustments
.
typeTool
.
obj
.
engineData
.
EngineDict
.
StyleRun
.
RunArray
[
0
].
StyleSheet
||
{}
...
@@ -130,6 +130,26 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
...
@@ -130,6 +130,26 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
return
element
return
element
}
}
const
extractScale
=
(
matrix
:
any
)
=>
{
const
scaleX
=
Math
.
sqrt
(
matrix
.
xx
*
matrix
.
xx
+
matrix
.
xy
*
matrix
.
xy
);
const
scaleY
=
Math
.
sqrt
(
matrix
.
yx
*
matrix
.
yx
+
matrix
.
yy
*
matrix
.
yy
);
return
scaleY
>
scaleX
?
scaleY
:
scaleX
;
}
const
extractRotation
=
(
matrix
:
any
)
=>
{
const
a
=
matrix
.
xx
;
const
b
=
matrix
.
yx
;
const
c
=
matrix
.
xy
;
const
d
=
matrix
.
yy
;
// Calculate rotation in radians
const
rotationRadians
=
Math
.
atan2
(
b
,
a
);
// Convert to degrees
const
rotationDegrees
=
rotationRadians
*
(
180
/
Math
.
PI
);
return
-
rotationDegrees
;
}
const
getGradient
=
(
obj
:
any
)
=>
{
const
getGradient
=
(
obj
:
any
)
=>
{
const
{
GrFl
}
=
obj
.
data
const
{
GrFl
}
=
obj
.
data
const
angle
=
GrFl
.
Angl
.
value
-
90
const
angle
=
GrFl
.
Angl
.
value
-
90
...
...
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