drawTextRotated method
void
drawTextRotated(
- Paragraph paragraph,
- double theta,
- MappointRelative reference
)
Implementation
void drawTextRotated(ui.Paragraph paragraph, double theta, MappointRelative reference) {
// since the text is rotated, use the textwidth as margin in all directions
// if (start.x + textwidth < 0 ||
// start.y + textwidth < 0 ||
// start.x - textwidth > size.width ||
// start.y - textwidth > size.height) return;
//double theta = segment.getTheta();
// https://stackoverflow.com/questions/51323233/flutter-how-to-rotate-an-image-around-the-center-with-canvas
_uiCanvas.save();
_uiCanvas.translate(
/*translateX +*/
reference.dx,
/*translateY +*/ reference.dy,
);
_uiCanvas.rotate(theta);
_uiCanvas.translate(0, -paragraph.height / 2);
// uiCanvas.drawRect(
// ui.Rect.fromLTWH(0, 0, paragraph.longestLine, paragraph.height),
// ui.Paint()..color = Colors.red);
// uiCanvas.drawCircle(Offset.zero, 10, ui.Paint()..color = Colors.green);
_uiCanvas.drawParagraph(paragraph, ui.Offset.zero);
_uiCanvas.restore();
++_textCount;
}