Reputation: 73
I have a following function that calculate the offset points for alphabet A
void buildAlphabetA() {
if (alphabetApoints.isEmpty) {
double startX = 100;
double startY = 500;
for (int i = 1; i <= 10; i++) {
Offset circlePoint = Offset(startX, startY);
alphabetApoints.add(circlePoint);
startX += 10;
startY -= 30;
if(i==5){
double horX=startX;
double horY=startY;
for(int j=1;j<4;j++){
horX+=25;
alphabetApoints.add(Offset(horX, horY));
}
}
}
for (int i = 1; i <= 11; i++) {
Offset circlePoint = Offset(startX, startY);
alphabetApoints.add(circlePoint);
startX += 10;
startY += 30;
}
alphabetATotalPoints=alphabetApoints.length;
}
}
and following functions draws it using circles
void paintAlphabets(Canvas canvas) {
double radius = 7;
Paint paint = Paint()
..style = PaintingStyle.stroke
..strokeWidth = 3
..color = Colors.black;
for (var element in alphaApoints) {
canvas.drawCircle(element!, radius, paint);
}
}
After drawing I allow users to draw on canvas. Drawing accuracy is calculated if the drawing point coincides with alphabets point. If I use this approach to draw all the alphabets it will take lot of time. Is there any way to draw these dotted alphabets from jpeg/png etc from assets.
Upvotes: 0
Views: 47