stringAnchorRgba method
Implementation
bool stringAnchorRgba(
math.Point<double> p,
String s,
math.Point<double> anchorPoint,
int r,
int g,
int b,
int a, {
int? charRotation,
}) {
var result = true;
var curx = p.x;
var cury = p.y;
final stringWidth = s.length * gfx.charWidthLocal.toDouble();
final stringHeight = gfx.charHeightLocal.toDouble();
double calcx = 0;
double calcy = 0;
charRotation ??= gfx.charRotation;
switch (charRotation) {
case 0:
calcx = -stringWidth * anchorPoint.x;
calcy = -stringHeight * anchorPoint.y;
case 2:
calcx = stringWidth * anchorPoint.x;
calcy = -stringHeight * anchorPoint.y;
case 1:
calcx = -stringHeight * anchorPoint.y;
calcy = -stringWidth * anchorPoint.x;
case 3:
calcx = -stringHeight * anchorPoint.y;
calcy = stringWidth * anchorPoint.x;
}
for (var i = 0; i < s.length; i++) {
final curchar = s[i];
if (result) {
result = gfx.characterRgba(
this,
curx + calcx,
cury + calcy,
curchar.codeUnitAt(0),
r,
g,
b,
a,
);
}
switch (charRotation) {
case 0:
curx += gfx.charWidthLocal;
case 2:
curx -= gfx.charWidthLocal;
case 1:
cury += gfx.charHeightLocal;
case 3:
cury -= gfx.charHeightLocal;
}
}
return result;
}