Canvas 绘制方法过一遍
发布日期:2021-05-10 05:21:53 浏览次数:25 分类:精选文章

本文共 5123 字,大约阅读时间需要 17 分钟。

Canvas ���������������������

Canvas.save() ������������������������ Canvas ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� X ��� Y ���������������������������������������������������������������������

Canvas.restore() ������������������ save() ������������������������������������������������������save() ���������������������������������������������������������������������������������������������������������������������������������������������������

Canvas.enableZ() ��� Canvas.disableZ() ������������������ Canvas ��� z ������������������������������������ z ������������������������������������������������������������������������������������������������������������������������

���������������������������

1. drawARGB ������������������

void drawARGB(int a, int r, int g, int b)

  • ��� ARGB ���������������������������
  • ������ a������������������������������ 0���255���
  • ������ r��������������������������������� 0���255���
  • ������ g��������������������������������� 0���255���
  • ������ b��������������������������������� 0���255���

2. drawRGB ������������������

void drawRGB(int r, int g, int b)

  • ��� RGB ���������������������������
  • ������ r��������������������������������� 0���255���
  • ������ g��������������������������������� 0���255���
  • ������ b��������������������������������� 0���255���

3. ������������

void drawText(@NonNull char[] text, int index, int count, float x, float y, @NonNull Paint paint)

  • ��������� char[] ������������ index ��������������������������� count ������������������ (x, y) ������
  • ������ text���������������������������������������������������
  • ������ index��������������������� 0 ���������
  • ������ count���������������������������
  • ������ x������������������ x ���������
  • ������ y������������������ y ���������
  • ������ paint������������

void drawText(@NonNull String text, float x, float y, @NonNull Paint paint)

  • ������������������������������������������������ (x, y) ������
  • ������ text���������������������
  • ������ x��������� x ���������
  • ������ y��������� y ���������
  • ������ paint������������

4. drawTextOnPath ������������������������

void drawTextOnPath(@NonNull char[] text, int index, int count, @NonNull Path path, float hOffset, float vOffset, @NonNull Paint paint)

  • ���������������������������
  • ������ text������������������
  • ������ index������������������
  • ������ count������������������
  • ������ path������������������
  • ������ hOffset������ X ������������������
  • ������ vOffset������ Y ������������������
  • ������ paint������������

5. drawPoint ���������

void drawPoint(float x, float y, @NonNull Paint paint)

  • ��������� (x, y) ���������������������
  • ������ x��������� X ���������
  • ������ y��������� Y ���������
  • ������ paint������������

6. drawLine ������

void drawLine(float startX, float startY, float stopX, float stopY, @NonNull Paint paint)

  • ��������� (startX, startY) ��� (stopX, stopY) ������������
  • ������ startX��������� x ���������
  • ������ startY��������� y ���������
  • ������ stopX��������� x ���������
  • ������ stopY��������� y ���������
  • ������ paint������������

7. drawCircle ������������������

void drawCircle(float cx, float cy, float radius, @NonNull Paint paint)

  • ���������������������������������������
  • ������ cx������������ X ���������
  • ������ cy������������ Y ���������
  • ������ radius������������
  • ������ paint������������

void drawOval(float left, float top, float right, float bottom, @NonNull Paint paint)

  • ���������������������
  • ������ left��������������� X ���������
  • ������ top��������������� Y ���������
  • ������ right��������������� X ���������
  • ������ bottom��������������� Y ���������
  • ������ paint������������

8. drawRect ������������

void drawRect(@NonNull RectF rect, @NonNull Paint paint)

  • ���������������������������������

void drawRect(float left, float top, float right, float bottom, @NonNull Paint paint)

  • ������������������ left, top, right, bottom ������������������
  • ������ left������������������ X ���������
  • ������ top������������������ Y ���������
  • ������ right������������������ X ���������
  • ������ bottom������������������ Y ���������
  • ������ paint������������

9. drawZoomCtrl ������������������������

void drawZoomCtrl(@NonNull Paint paint)

  • ���������������������������������������������������������������������������

10. drawColor ������������������

void drawColor(@ColorInt int color)

  • ������������������������������������������
  • ������ color���AARRGGBB ���������������������

11. drawPicture ���������������

void drawPicture(@NonNull Picture picture)

  • ��� Picture ���������������������������
  • ���������������������������������������������������

void drawPicture(@NonNull Picture picture, @NonNull RectF dst)

  • ��� Picture ������������������������������

12. drawRenderNode ������������

void drawRenderNode(@NonNull RenderNode renderNode)

  • ������ RenderNode ���������������������������

void drawVertices ���������������������

  • ���������������������������������

������������������������ Canvas ������ API ������������������������������������������������������

上一篇:Gradle 版本对应关系
下一篇:因为混淆的问题生成Release版本失败

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2025年04月26日 17时07分17秒