Welcome to the Rose Curves Flutter project! This project showcases how to create beautiful and interactive rose curves using Flutter's powerful drawing capabilities. Whether you're a seasoned developer or just starting, this project offers a fun and educational way to explore Flutter's custom painting and UI design features.
Rose curves, also known as rhodonea curves, are a family of mathematical curves that produce beautiful, flower-like patterns. These curves are defined by a simple polar equation but result in stunning and intricate designs. This Flutter project recreates the experience, allowing users to generate and manipulate these fascinating patterns through an intuitive mobile interface.
- Interactive UI: Modify parameters in real-time to transform and explore various rose curve patterns.
- Customizable Designs: Adjust the number of petals, curve density, and other variables to create unique patterns.
- Responsive Layout: The app seamlessly adapts to different screen sizes and orientations for a consistent and engaging experience.
- Smooth Animations: Experience fluid transitions as you tweak parameters and watch the rose curves evolve instantly.
- Educational Value: An excellent tool for learning about mathematical curves and their geometric properties.
Before you begin, ensure you have the following installed on your local machine:
-
Clone the repository:
git clone https://github.com/yourusername/rose-curves-flutter.git cd rose-curves-flutter
-
Install dependencies:
flutter pub get
-
Run the app:
flutter run
After running the app, you will see a rose curve pattern displayed on the screen. Use the slider at the bottom to adjust the parameters and explore different designs.
- Number of Petals (k): Controls the number of petals in the rose curve.
- Curve Density: Adjusts the density of the curve lines.
- RoseCurvesDemo: This is the main widget containing the UI elements, including the slider and the CustomPaint widget.
- RoseCurvesPainter: A custom painter class responsible for drawing the rose curves on the canvas.
Here is an example of the RoseCurvesPainter
class:
class RoseCurvesPainter extends CustomPainter {
final double t;
final int k;
RoseCurvesPainter({required this.t, required this.k});
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.red
..strokeWidth = 2.0
..style = PaintingStyle.stroke;
final path = Path();
for (double theta = 0.0; theta < 2 * pi; theta += 0.01) {
final r = cos(k * theta);
final x = r * cos(theta);
final y = r * sin(theta);
if (theta == 0.0) {
path.moveTo(size.width / 2 + x * size.width / 2, size.height / 2 + y * size.height / 2);
} else {
path.lineTo(size.width / 2 + x * size.width / 2, size.height / 2 + y * size.height / 2);
}
}
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(RoseCurvesPainter oldDelegate) {
return oldDelegate.t != t || oldDelegate.k != k;
}
}
You can modify the RoseCurvesPainter
class to change how the rose curves are drawn. Adjust the parameters like k
to see different patterns. Here's how you might do it:
class RoseCurvesPainter extends CustomPainter {
final double t;
final int k;
RoseCurvesPainter({required this.t, required this.k});
@override
void paint(Canvas canvas, Size size) {
// Drawing logic
}
@override
bool shouldRepaint(RoseCurvesPainter oldDelegate) {
return oldDelegate.t != t || oldDelegate.k != k;
}
}
Contributions are welcome! Feel free to open an issue or submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
If you have any questions or suggestions, feel free to reach out:
- Email: saadi47123@gmail.com
- GitHub: Saad-Rajpoot
- LinkedIn: Saad Rajpoot
Thank you for checking out the Rose Curves Flutter project! Enjoy creating your own unique patterns and feel free to share your creations with the community.