Skip to content

Commit

Permalink
Merge pull request #7 from Rahiche/ft-reverse-control-points-order-
Browse files Browse the repository at this point in the history
Reverse control points order
  • Loading branch information
Rahiche authored Sep 17, 2024
2 parents 5384b67 + 2116f1a commit 3a45faa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
11 changes: 1 addition & 10 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,7 @@ class _HomePageState extends State<HomePage> {
Map<EdgeType, List<ControlPoint>> controlPointsPerEdge = {};

for (var edge in _selectedEdges) {
List<ControlPoint> controlPointsToUse = _controlPoints;
if (edge == EdgeType.rightEdge || edge == EdgeType.bottomEdge) {
controlPointsToUse = _controlPoints.map((cp) {
return ControlPoint(
position: 1.0 - cp.position,
type: cp.type,
);
}).toList();
}
controlPointsPerEdge[edge] = controlPointsToUse;
controlPointsPerEdge[edge] = _controlPoints;
}

return Scaffold(
Expand Down
23 changes: 17 additions & 6 deletions lib/src/soft_edge_blur.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,23 @@ class SoftEdgeBlur extends StatelessWidget {
final sortedColors = [for (var i in sortedPairs) colors[i]];

// Create linear gradient based on orientation
return ui.Gradient.linear(
isVertical ? rect.topCenter : rect.centerLeft,
isVertical ? rect.bottomCenter : rect.centerRight,
sortedColors,
sortedPositions,
);
if ((edge.type == EdgeType.rightEdge) ||
(edge.type == EdgeType.bottomEdge)) {
// Reverse from/to when we are in the right/bottom edge
return ui.Gradient.linear(
isVertical ? rect.bottomCenter : rect.centerRight,
isVertical ? rect.topCenter : rect.centerLeft,
sortedColors,
sortedPositions,
);
} else {
return ui.Gradient.linear(
isVertical ? rect.topCenter : rect.centerLeft,
isVertical ? rect.bottomCenter : rect.centerRight,
sortedColors,
sortedPositions,
);
}
}

Rect _getEdgeRect(EdgeBlur edge, Size size, double devicePixelRatio) {
Expand Down

0 comments on commit 3a45faa

Please sign in to comment.