2022-10-02 23:06:56 +02:00
|
|
|
package android.graphics;
|
|
|
|
|
|
|
|
|
|
public class Paint {
|
2023-09-12 19:30:20 +02:00
|
|
|
public long skia_paint = 0;
|
|
|
|
|
private Typeface typeface = null;
|
|
|
|
|
public long skia_font = 0;
|
2024-03-24 21:12:13 +01:00
|
|
|
ColorFilter colorFilter = null;
|
2022-10-02 23:06:56 +02:00
|
|
|
|
2023-08-17 10:46:24 +02:00
|
|
|
public Paint() {
|
2023-08-28 20:03:32 +02:00
|
|
|
skia_paint = native_constructor();
|
2023-08-17 10:46:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Paint (int flags) {
|
|
|
|
|
this();
|
|
|
|
|
setFlags(flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Paint(Paint paint) {
|
2023-08-28 20:03:32 +02:00
|
|
|
/* TODO: use sk_paint_clone */
|
|
|
|
|
this();
|
2023-08-17 10:46:24 +02:00
|
|
|
setColor(paint.getColor());
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 17:21:21 +01:00
|
|
|
public void setColor(int color) {
|
2023-08-28 20:03:32 +02:00
|
|
|
native_set_color(skia_paint, color);
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-27 17:21:21 +01:00
|
|
|
public int getColor() {
|
2023-08-28 20:03:32 +02:00
|
|
|
return native_get_color(skia_paint);
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAntiAlias(boolean aa) {}
|
2024-04-08 23:15:05 +02:00
|
|
|
public void setStrokeWidth(float width) {
|
|
|
|
|
native_set_stroke_width(skia_paint, width);
|
|
|
|
|
}
|
2023-09-12 19:30:20 +02:00
|
|
|
public void setTextSize(float size) {
|
|
|
|
|
if(skia_font == 0)
|
|
|
|
|
skia_font = native_create_font();
|
|
|
|
|
|
|
|
|
|
native_set_text_size(skia_font, size);
|
|
|
|
|
}
|
2022-10-02 23:06:56 +02:00
|
|
|
|
2022-12-27 17:21:21 +01:00
|
|
|
public Typeface setTypeface(Typeface typeface) {
|
2023-09-12 19:30:20 +02:00
|
|
|
this.typeface = typeface;
|
|
|
|
|
if(skia_font == 0)
|
|
|
|
|
skia_font = native_create_font();
|
|
|
|
|
|
2023-10-14 11:13:10 +02:00
|
|
|
if (typeface != null)
|
|
|
|
|
native_set_typeface(skia_font, typeface.skia_typeface);
|
2023-09-12 19:30:20 +02:00
|
|
|
return this.typeface;
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
2022-12-27 17:21:21 +01:00
|
|
|
public void getTextBounds(String text, int start, int end, Rect bounds) {}
|
|
|
|
|
public void getTextBounds(char[] text, int index, int count, Rect bounds) {}
|
2022-10-02 23:06:56 +02:00
|
|
|
public void setFlags(int flags) {}
|
|
|
|
|
public void setFilterBitmap(boolean filter) {}
|
2024-04-08 23:15:05 +02:00
|
|
|
public void setStyle(Style style) {
|
|
|
|
|
native_set_style(skia_paint, style.nativeInt);
|
|
|
|
|
}
|
2023-09-12 19:30:20 +02:00
|
|
|
public float ascent() {
|
|
|
|
|
if(skia_font == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
return native_ascent(skia_font);
|
|
|
|
|
}
|
2022-12-27 17:21:21 +01:00
|
|
|
|
|
|
|
|
public float measureText(char[] text, int index, int count) { return 10; }
|
|
|
|
|
public float measureText(String text, int start, int end) { return 10; }
|
2023-09-12 19:30:20 +02:00
|
|
|
public float measureText(String text) {
|
|
|
|
|
return native_measure_text(skia_font, text, 0, text.length(), skia_paint);
|
|
|
|
|
}
|
2022-12-27 17:21:21 +01:00
|
|
|
public float measureText(CharSequence text, int start, int end) { return 10; }
|
|
|
|
|
|
2024-03-24 21:12:13 +01:00
|
|
|
public ColorFilter setColorFilter(ColorFilter colorFilter) {
|
|
|
|
|
this.colorFilter = colorFilter;
|
|
|
|
|
return colorFilter;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-24 20:43:47 +01:00
|
|
|
public Shader setShader(Shader shader) { return shader; }
|
|
|
|
|
|
2022-12-27 17:21:21 +01:00
|
|
|
public enum Style {
|
|
|
|
|
/**
|
|
|
|
|
* Geometry and text drawn with this style will be filled, ignoring all
|
|
|
|
|
* stroke-related settings in the paint.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
FILL(0),
|
2022-12-27 17:21:21 +01:00
|
|
|
/**
|
|
|
|
|
* Geometry and text drawn with this style will be stroked, respecting
|
|
|
|
|
* the stroke-related fields on the paint.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
STROKE(1),
|
2022-12-27 17:21:21 +01:00
|
|
|
/**
|
|
|
|
|
* Geometry and text drawn with this style will be both filled and
|
|
|
|
|
* stroked at the same time, respecting the stroke-related fields on
|
|
|
|
|
* the paint. This mode can give unexpected results if the geometry
|
|
|
|
|
* is oriented counter-clockwise. This restriction does not apply to
|
|
|
|
|
* either FILL or STROKE.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
FILL_AND_STROKE(2);
|
|
|
|
|
|
2022-12-27 17:21:21 +01:00
|
|
|
Style(int nativeInt) {
|
|
|
|
|
this.nativeInt = nativeInt;
|
|
|
|
|
}
|
|
|
|
|
final int nativeInt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class FontMetrics {
|
|
|
|
|
/**
|
2023-06-22 11:45:46 +02:00
|
|
|
* The maximum distance above the baseline for the tallest glyph in
|
2022-12-27 17:21:21 +01:00
|
|
|
* the font at a given text size.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
public float top;
|
2022-12-27 17:21:21 +01:00
|
|
|
/**
|
|
|
|
|
* The recommended distance above the baseline for singled spaced text.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
public float ascent;
|
2022-12-27 17:21:21 +01:00
|
|
|
/**
|
|
|
|
|
* The recommended distance below the baseline for singled spaced text.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
public float descent;
|
2022-12-27 17:21:21 +01:00
|
|
|
/**
|
2023-06-22 11:45:46 +02:00
|
|
|
* The maximum distance below the baseline for the lowest glyph in
|
2022-12-27 17:21:21 +01:00
|
|
|
* the font at a given text size.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
public float bottom;
|
2022-12-27 17:21:21 +01:00
|
|
|
/**
|
|
|
|
|
* The recommended additional space to add between lines of text.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
public float leading;
|
2022-12-27 17:21:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class FontMetricsInt {
|
2023-06-22 11:45:46 +02:00
|
|
|
public int top;
|
|
|
|
|
public int ascent;
|
|
|
|
|
public int descent;
|
|
|
|
|
public int bottom;
|
|
|
|
|
public int leading;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
2022-12-27 17:21:21 +01:00
|
|
|
return "FontMetricsInt: top=" + top + " ascent=" + ascent +
|
2023-06-22 11:45:46 +02:00
|
|
|
" descent=" + descent + " bottom=" + bottom +
|
|
|
|
|
" leading=" + leading;
|
2022-12-27 17:21:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
public /*native*/ int getFlags() { return 0; }
|
2022-12-27 17:21:21 +01:00
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
public /*native*/ int getHinting() { return 0; }
|
2022-12-27 17:21:21 +01:00
|
|
|
public /*native*/ void setHinting(int mode) {}
|
|
|
|
|
|
|
|
|
|
public /*native*/ void setDither(boolean dither) {}
|
|
|
|
|
public /*native*/ void setLinearText(boolean linearText) {}
|
|
|
|
|
public /*native*/ void setSubpixelText(boolean subpixelText) {}
|
|
|
|
|
public /*native*/ void setUnderlineText(boolean underlineText) {}
|
|
|
|
|
public /*native*/ void setStrikeThruText(boolean strikeThruText) {}
|
|
|
|
|
public /*native*/ void setFakeBoldText(boolean fakeBoldText) {}
|
|
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
public /*native*/ int getAlpha() { return 0; }
|
2022-12-27 17:21:21 +01:00
|
|
|
public /*native*/ void setAlpha(int a) {}
|
2023-06-22 11:45:46 +02:00
|
|
|
public /*native*/ float getStrokeWidth() { return 0; }
|
2022-12-27 17:21:21 +01:00
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
public /*native*/ float getStrokeMiter() { return 0; }
|
2022-12-27 17:21:21 +01:00
|
|
|
public /*native*/ void setStrokeMiter(float miter) {}
|
2023-06-22 11:45:46 +02:00
|
|
|
public /*native*/ float getTextSize() { return 0; }
|
2022-12-27 17:21:21 +01:00
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
public /*native*/ float getTextScaleX() { return 0; }
|
2022-12-27 17:21:21 +01:00
|
|
|
public /*native*/ void setTextScaleX(float scaleX) {}
|
2023-06-22 11:45:46 +02:00
|
|
|
public /*native*/ float getTextSkewX() { return 0; }
|
2022-12-27 17:21:21 +01:00
|
|
|
public /*native*/ void setTextSkewX(float skewX) {}
|
|
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
public /*native*/ float descent() { return 0; }
|
|
|
|
|
public /*native*/ float getFontMetrics(FontMetrics metrics) { return 0; }
|
|
|
|
|
public /*native*/ int getFontMetricsInt(FontMetricsInt fmi) { return 0; }
|
2022-12-27 17:21:21 +01:00
|
|
|
|
2023-01-14 14:32:37 +01:00
|
|
|
public void setShadowLayer(float radius, float dx, float dy, int color) {}
|
|
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
public Xfermode setXfermode(Xfermode xfermode) { return xfermode; }
|
2023-01-14 14:32:37 +01:00
|
|
|
|
2023-11-03 18:23:20 +01:00
|
|
|
public void setLetterSpacing(float spacing) {}
|
|
|
|
|
|
2023-01-14 14:32:37 +01:00
|
|
|
public enum Cap {
|
|
|
|
|
/**
|
|
|
|
|
* The stroke ends with the path, and does not project beyond it.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
BUTT(0),
|
2023-01-14 14:32:37 +01:00
|
|
|
/**
|
|
|
|
|
* The stroke projects out as a semicircle, with the center at the
|
|
|
|
|
* end of the path.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
ROUND(1),
|
2023-01-14 14:32:37 +01:00
|
|
|
/**
|
|
|
|
|
* The stroke projects out as a square, with the center at the end
|
|
|
|
|
* of the path.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
SQUARE(2);
|
2023-01-14 14:32:37 +01:00
|
|
|
|
|
|
|
|
private Cap(int nativeInt) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum Join {
|
|
|
|
|
/**
|
|
|
|
|
* The outer edges of a join meet at a sharp angle
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
MITER(0),
|
2023-01-14 14:32:37 +01:00
|
|
|
/**
|
|
|
|
|
* The outer edges of a join meet in a circular arc.
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
ROUND(1),
|
2023-01-14 14:32:37 +01:00
|
|
|
/**
|
|
|
|
|
* The outer edges of a join meet with a straight line
|
|
|
|
|
*/
|
2023-06-22 11:45:46 +02:00
|
|
|
BEVEL(2);
|
2023-01-14 14:32:37 +01:00
|
|
|
|
|
|
|
|
private Join(int nativeInt) {}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-29 23:56:28 +01:00
|
|
|
public enum Align {
|
|
|
|
|
CENTER,
|
|
|
|
|
LEFT,
|
|
|
|
|
RIGHT,
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
public void setStrokeCap(Cap cap) {}
|
2023-01-14 14:32:37 +01:00
|
|
|
|
|
|
|
|
public void setStrokeJoin(Join join) {}
|
2023-09-12 19:30:20 +02:00
|
|
|
|
2023-09-19 23:22:21 +02:00
|
|
|
public Typeface getTypeface() {
|
|
|
|
|
return new Typeface();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-29 23:56:28 +01:00
|
|
|
public void setTextAlign(Align align) {}
|
|
|
|
|
|
|
|
|
|
public Shader getShader() {
|
|
|
|
|
return new Shader();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-12 19:30:20 +02:00
|
|
|
private native long native_constructor();
|
|
|
|
|
private native void native_set_color(long skia_paint, int color);
|
|
|
|
|
private native int native_get_color(long skia_paint);
|
|
|
|
|
private static native long native_create_font();
|
|
|
|
|
private static native float native_ascent(long skia_font);
|
|
|
|
|
private static native void native_set_typeface(long skia_font, long skia_typeface);
|
|
|
|
|
private static native void native_set_text_size(long skia_font, float size);
|
|
|
|
|
private static native float native_measure_text(long skia_font, CharSequence text, int start, int end, long skia_paint);
|
2024-04-08 23:15:05 +02:00
|
|
|
private static native void native_set_stroke_width(long skia_font, float width);
|
|
|
|
|
private static native void native_set_style(long skia_paint, int style);
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|