Canvas: implement drawCircle() and a drawText() variant

This commit is contained in:
Julian Winkler 2025-02-18 18:57:06 +01:00
parent 3fb1f56da2
commit 587aeaba74
2 changed files with 16 additions and 6 deletions

View file

@ -118,11 +118,8 @@ public class Canvas {
* @param paint The paint used for the text (e.g. color, size, style)
*/
public void drawText(String text, int start, int end, float x, float y, Paint paint) {
/* if ((start | end | (end - start) | (text.length() - end)) < 0) {
throw new IndexOutOfBoundsException();
}
native_drawText(mNativeCanvas, text, start, end, x, y, paint.mBidiFlags,
paint.mNativePaint);*/
gsk_canvas.snapshot = bitmap.getSnapshot();
gsk_canvas.drawText(text, start, end, x, y, paint);
}
/**
@ -422,7 +419,10 @@ public class Canvas {
public void translate(float dx, float dy) {}
public void drawCircle(float cx, float cy, float radius, Paint paint) {}
public void drawCircle(float cx, float cy, float radius, Paint paint) {
gsk_canvas.snapshot = bitmap.getSnapshot();
gsk_canvas.drawCircle(cx, cy, radius, paint);
}
public Rect getClipBounds() {
return new Rect(0, 0, 10, 10);

View file

@ -73,6 +73,11 @@ public class GskCanvas extends Canvas {
native_drawText(snapshot, text, x, y, paint != null ? paint.paint : default_paint.paint);
}
@Override
public void drawText(String text, int start, int end, float x, float y, Paint paint) {
drawText(text.substring(start, end), x, y, paint);
}
@Override
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
native_drawLine(snapshot, startX, startY, stopX, stopY, paint != null ? paint.paint : default_paint.paint);
@ -116,6 +121,11 @@ public class GskCanvas extends Canvas {
native_drawRoundRect(snapshot, left, top, right, bottom, rx, ry, paint != null ? paint.paint : default_paint.paint);
}
@Override
public void drawCircle(float cx, float cy, float radius, Paint paint) {
drawRoundRect(cx - radius, cy - radius, cx + radius, cy + radius, radius, radius, paint);
}
@Override
public void scale(float sx, float sy) {
native_scale(snapshot, sx, sy);