-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Almost done with blending mode without PASS_THROUGH and opacities case.
- Loading branch information
Showing
16 changed files
with
153 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 22 additions & 26 deletions
48
src/api/services/figma/nodes/has-only-valid-blend-modes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,22 @@ | ||
// import { type PolychromNode, type FigmaPaint } from '~types/figma.ts'; | ||
// import { isEmpty, notEmpty } from '~utils/not-empty.ts'; | ||
// | ||
// // PLUS_LIGHTER is LINEAR_DODGE | ||
// // PLUS_DARKER is LINEAR_BURN | ||
// const unprocessedBlendModes = ['LINEAR_BURN', 'LINEAR_DODGE']; | ||
// | ||
// const isVisibleSolidFill = (fill: FigmaPaint): boolean => | ||
// fill.visible === true && | ||
// (notEmpty(fill.opacity) ? fill.opacity > 0 : true) && | ||
// fill.type === 'SOLID'; | ||
// | ||
// const hasValidBlendMode = (fill: FigmaPaint): boolean => { | ||
// if (isEmpty(fill.blendMode)) return true; | ||
// | ||
// return !unprocessedBlendModes.includes(fill.blendMode); | ||
// }; | ||
// | ||
// export const hasOnlyValidBlendModes = (nodes: PolychromNode[]): boolean => | ||
// nodes.every( | ||
// (node) => | ||
// node.fills | ||
// .filter((fill) => isVisibleSolidFill(fill)) | ||
// .every(hasValidBlendMode) && | ||
// !unprocessedBlendModes.includes(node.blendMode) | ||
// ); | ||
import { type FigmaPaint, type PolychromNode } from '~types/figma.ts'; | ||
import { flattenPolychromNodesTree } from '~utils/figma/flatten-polychrom-nodes-tree.ts'; | ||
import { isVisibleSolidFill } from '~utils/figma/is-visible-solid-fill.ts'; | ||
import { isEmpty } from '~utils/not-empty.ts'; | ||
|
||
// PLUS_DARKER is LINEAR_BURN | ||
const unprocessedBlendModes = ['LINEAR_BURN']; | ||
|
||
const hasValidBlendMode = (fill: FigmaPaint): boolean => { | ||
if (isEmpty(fill.blendMode)) return true; | ||
|
||
return !unprocessedBlendModes.includes(fill.blendMode); | ||
}; | ||
|
||
export const hasOnlyValidBlendModes = (nodes: PolychromNode): boolean => | ||
flattenPolychromNodesTree(nodes).every( | ||
(node) => | ||
node.fills | ||
.filter((fill) => isVisibleSolidFill(fill)) | ||
.every(hasValidBlendMode) && | ||
!unprocessedBlendModes.includes(node.blendMode) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.