🇬🇧 English Examples (Click to Expand)
This file provides a quick, standalone code example for the equation_painter package.
Use the following code to render a basic sine wave with a linear animation from left to right.
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:equation_painter/equation_painter.dart';
void main() => runApp(const MaterialApp(home: SimpleDemo()));
class SimpleDemo extends StatelessWidget {
const SimpleDemo({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: Center(
child: EquationPainterWidget(
width: 400,
height: 400,
alignment: Alignment.center,
unitsPerSquare: 60.0,
equations: [
EquationConfig(
function: (x, y) => y - 60 * sin(x / 30), // y = 60 * sin(x/30)
color: Colors.cyanAccent,
strokeWidth: 3,
animationType: AnimationType.linearX,
),
],
),
),
);
}
}You can stack multiple equations by passing them to the equations list.
EquationPainterWidget(
width: 400,
height: 400,
equations: [
EquationConfig(
function: (x, y) => x * x + y * y - pow(100, 2), // x^2 + y^2 = 100^2
color: Colors.amberAccent,
animationType: AnimationType.radial,
),
EquationConfig(
function: (x, y) => y - 50 * sin(x / 20),
color: Colors.pinkAccent,
animationType: AnimationType.linearX,
),
],
)For more advanced examples, please check the example/lib/main.dart file.
🇧🇩 টেক্সট উদাহরণ (বিস্তারিত দেখতে ক্লিক করুন)
এই ফাইলটি equation_painter প্যাকেজের জন্য একটি দ্রুত এবং স্ট্যান্ডঅ্যালোন কোড উদাহরণ প্রদান করে।
বাম থেকে ডানে লিনিয়ার অ্যানিমেশন সহ একটি বেসিক সাইন ওয়েভ রেন্ডার করতে নিচের কোডটি ব্যবহার করুন।
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:equation_painter/equation_painter.dart';
void main() => runApp(const MaterialApp(home: SimpleDemo()));
class SimpleDemo extends StatelessWidget {
const SimpleDemo({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: Center(
child: EquationPainterWidget(
width: 400,
height: 400,
alignment: Alignment.center,
unitsPerSquare: 60.0,
equations: [
EquationConfig(
function: (x, y) => y - 60 * sin(x / 30), // y = 60 * sin(x/30)
color: Colors.cyanAccent,
strokeWidth: 3,
animationType: AnimationType.linearX,
),
],
),
),
);
}
}আপনি equations লিস্টে পাঠিয়ে একাধিক সমীকরণ একসাথে দেখাতে পারেন।
EquationPainterWidget(
width: 400,
height: 400,
equations: [
EquationConfig(
function: (x, y) => x * x + y * y - pow(100, 2), // x² + y² = 100²
color: Colors.amberAccent,
animationType: AnimationType.radial,
),
EquationConfig(
function: (x, y) => y - 50 * sin(x / 20),
color: Colors.pinkAccent,
animationType: AnimationType.linearX,
),
],
)আরও উন্নত উদাহরণের জন্য, অনুগ্রহ করে example/lib/main.dart ফাইলটি দেখুন।