Skip to content

Instantly share code, notes, and snippets.

@divyanshub024
Created April 9, 2020 19:24
Show Gist options
  • Save divyanshub024/72ac490995712f4e3ea8a94e3fcf0463 to your computer and use it in GitHub Desktop.
Save divyanshub024/72ac490995712f4e3ea8a94e3fcf0463 to your computer and use it in GitHub Desktop.
Path createPath(int sides, double radius) {
var path = Path();
var angle = (math.pi * 2) / sides;
path.moveTo(radius * math.cos(0.0), radius * math.sin(0.0));
for (int i = 1; i <= sides; i++) {
double x = radius * math.cos(angle * i);
double y = radius * math.sin(angle * i);
path.lineTo(x, y);
}
path.close();
return path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment