mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 20:27:58 +03:00
Canvas: implement drawCircle() and a drawText() variant
This commit is contained in:
parent
3fb1f56da2
commit
587aeaba74
2 changed files with 16 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue