Skip to content

Commit

Permalink
Fix opacity processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhin committed Sep 27, 2023
1 parent 992c763 commit 6022737
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type FigmaNode } from '~types/figma.ts';
import { getFirstVisibleNodeFill } from '~utils/figma/get-first-visible-node-fill.ts';
import { notEmpty } from '~utils/not-empty.ts';

export const handleOpaqueLayer = (
export const handleOpaqueBackground = (
selectedNode: FigmaNode,
firstIntersectingNode: FigmaNode
): ColorPair | null => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type ColorPair } from '~api/types.ts';
import { type FigmaNode } from '~types/figma.ts';
import { notEmpty } from '~utils/not-empty.ts';

export const handleTransparentLayer = (
export const handleTransparentBackground = (
selectedNode: FigmaNode,
intersectingNodes: FigmaNode[]
): ColorPair | null => {
Expand All @@ -14,7 +14,7 @@ export const handleTransparentLayer = (
const fgFill = getComputedNodeFill(selectedNode);

if (notEmpty(fgFill) && notEmpty(blendedBgColor))
buildColorsPair(selectedNode.id, fgFill, blendedBgColor);
return buildColorsPair(selectedNode.id, fgFill, blendedBgColor);

return null;
};
8 changes: 4 additions & 4 deletions src/api/services/selection/process-node-for-selection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { handleOpaqueLayer } from '~api/services/colors/handle-opaque-layer.ts';
import { handleTransparentLayer } from '~api/services/colors/handle-transparent-layer.ts';
import { handleOpaqueBackground } from '~api/services/colors/handle-opaque-background.ts';
import { handleTransparentBackground } from '~api/services/colors/handle-transparent-background.ts';
import { getIntersectingNodesWithPage } from '~api/services/figma/intersections/get-intersecting-nodes-with-page.ts';
import { createFigmaNode } from '~api/services/figma/nodes/create-figma-node.ts';
import { isLayerHasTransparency } from '~api/services/figma/visibility/is-layer-has-transparency.ts';
Expand All @@ -17,8 +17,8 @@ export const processNodeForSelection = (node: SceneNode): ColorPair | null => {
if (!notEmpty(firstIntersectingNode)) return null;

if (isLayerHasTransparency(firstIntersectingNode)) {
return handleTransparentLayer(figmaNode, intersectingNodes);
return handleTransparentBackground(figmaNode, intersectingNodes);
} else {
return handleOpaqueLayer(figmaNode, firstIntersectingNode);
return handleOpaqueBackground(figmaNode, firstIntersectingNode);
}
};

0 comments on commit 6022737

Please sign in to comment.