Git Product home page Git Product logo

hencoderpractice02's Introduction

HenCoder 绘制 2 练习项目

这是什么?

这不是一个独立使用的项目,它是 HenCoder Android 开发进阶:UI 1-2 Paint 详解 的配套练习项目。

怎么用?

项目是一个可以直接运行的 Android App 项目,项目运行后,在手机上打开是这样的:

工程下有一个 /practice 目录:

你要做的是就是,在 /practice 下的每一个 PracticeXxxView.java 文件中写代码,绘制出和页面上半部分相同的效果。例如写 PracticeLinearGradientView.java 以绘制出用线性渐变来绘制颜色的圆形。就像这样:

当然,没必要做得和示例一毛一样。这是一个练习,而不是一个超级模仿秀,关键是把技能掌握。

如果做不出来,可以参考 /sample 目录下的代码:

练习做完,绘制第二期(Paint 详解)的内容也就掌握得差不多了。

关于有些方法无效

现在的 Android 默认是开启了硬件加速的,而 Canvas 和 Paint 有一些方法是不支持硬件加速的,你需要把它手动关闭才行。硬件加速的支持情况和手动关闭硬件加速的方法你可以看一下这个 Android 的官方文档

以后我会专门用一节来讲硬件加速和图像的离屏缓冲(off-screen buffer),现在先不多说了。


练习2中的setXfermode第三幅图设置后没有效果。setPathEffect的第四个图形由于不擅长新编一个三角path,没有添加。

hencoderpractice02's People

Contributors

hunter-chan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.