-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
213 additions
and
20 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class CustomPatternPainter extends CustomPainter { | ||
final ColorScheme colors; | ||
CustomPatternPainter(this.colors); | ||
@override | ||
void paint(Canvas canvas, Size size) { | ||
final paint = Paint() | ||
..color = colors.primary | ||
..style = PaintingStyle.fill; | ||
|
||
double tileWidth = 50.0; // Largura fixa dos losangos | ||
double tileHeight = 30.0; // Altura fixa dos losangos | ||
int columns = (size.width / tileWidth).floor(); | ||
|
||
Path path = Path(); | ||
|
||
double x = 0; | ||
|
||
for (int i = 0; i < columns; i++) { | ||
if (i == 0) { | ||
x = 0; | ||
} else { | ||
x = x + (tileWidth * 2); | ||
} | ||
|
||
path.moveTo(x, 0); | ||
path.lineTo(x + tileWidth / 2, 0); | ||
path.lineTo(x, tileHeight / 2); | ||
path.lineTo(x, 0); | ||
path.close(); | ||
|
||
path.moveTo(x + tileWidth / 2, tileHeight / 2); | ||
path.lineTo(x + tileWidth, 0); | ||
path.lineTo(x + tileWidth * 3 / 2, tileHeight / 2); | ||
path.lineTo(x + tileWidth, tileHeight); | ||
path.close(); | ||
|
||
path.moveTo(x + tileWidth * 3 / 2, 0); | ||
path.lineTo(x + tileWidth * 2, 0); | ||
path.lineTo(x + tileWidth * 2, tileHeight / 2); | ||
path.lineTo(x + tileWidth * 3 / 2, 0); | ||
path.close(); | ||
} | ||
|
||
canvas.drawPath(path, paint); | ||
} | ||
|
||
@override | ||
bool shouldRepaint(covariant CustomPainter oldDelegate) { | ||
return false; | ||
} | ||
} |