Paint研究

本文介绍了Paint类的基本使用,包括获取和设置各种文本样式标志的方法,如线性文本、删除线、子像素渲染及下划线等,并解释了如何定义Paint实例的透明度、抗锯齿效果及颜色。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Class Overview


The Paint class holds the style and color information about how to draw geometries, text and bitmaps.

这个类拥有如何绘制集合、文本、位图的style和color的信息。


这个类的方法都比较简单。主要由:

                                                             1.getXxx某些信息的函数

                                                             2. isXxx...判断某些标识值的函数

                                                             3.setXxx  定义某些属性的函数

    Paint类的函数主要由这三类函数组成。各个函数还是比较容易看懂的。具体来看几个。

public final boolean isLinearText ()

Helper for getFlags(), returning true if LINEAR_TEXT_FLAG bit is set  要查看LINEAR_TEXT_FLAG这个位的值

Returns
  • true if the lineartext bit is set in the paint's flags
public final boolean isStrikeThruText ()

Helper for getFlags(), returning true if STRIKE_THRU_TEXT_FLAG bit is set   要查看STRIKE_THRU_TEXT_FLAG这个位的值

Returns
  • true if the strikeThruText bit is set in the paint's flags.
public final boolean isSubpixelText ()

Helper for getFlags(), returning true if SUBPIXEL_TEXT_FLAG bit is set      要查看SUBPIXEL_TEXT_FLAG这个位的值

Returns
  • true if the subpixel bit is set in the paint's flags
public final boolean isUnderlineText ()

Helper for getFlags(), returning true if UNDERLINE_TEXT_FLAG bit is set    要查看UNDERLINE_TEXT_FLAG这个位的值

Returns
  • true if the underlineText bit is set in the paint's flags

这四个方法都是用来检查一些bit值是true or false。



再列举几个set某些属性的函数来结束本文。。。有空了再详细整理一下这个类

public void setAlpha (int a)  定义Paint一个实例的透明度

Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values unchanged. Results are undefined if the alpha value is outside of the range [0..255]

Parameters
a set the alpha component [0..255] of the paint's color.
public void setAntiAlias (boolean aa) 定义Paint实例是否antialias(true or false)

Helper for setFlags(), setting or clearing the ANTI_ALIAS_FLAG bit AntiAliasing smooths out the edges of what is being drawn, but is has no impact on the interior of the shape. See setDither() and setFilterBitmap() to affect how colors are treated.

Parameters
aa true to set the antialias bit in the flags, false to clear it
public void setColor (int color) 定义Paint实例的颜色,注意这里颜色的表示方法

Set the paint's color. Note that the color is an int containing alpha as well as r,g,b. This 32bit value is not premultiplied, meaning that its alpha can be any value, regardless of the values of r,g,b. See the Color class for more details.

Parameters
color The new color (including alpha) to set in the paint.


总之,不要有畏难心理,一上来就应该查看开发者帮助文档,没那么困难。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值