Introduction to Paint class parameters in android

Paint is a brush, which is used to set graphics color, style and other drawing information when drawing text and graphics.

1. Graphic drawing  

 

setARGB(int a,int r,int g,int b);  

Set the color of the drawing, a represents the transparency, r, g, b represent the color value.  

 

setAlpha(int a);  

Sets the transparency for drawing graphics.      

 

setColor(int color);  

Sets the color to be drawn, expressed as a color value, which includes transparency and RGB color.  

 

setAntiAlias(boolean aa);  

Setting whether to use the anti-aliasing function will consume a lot of resources and the drawing speed will be slower.  

 

setDither(boolean dither);  

Setting whether to use image dithering will make the color of the drawn picture smoother and fuller, and the image will be clearer  

 

setFilterBitmap(boolean filter);  

If this item is set to true, the image will filter out the optimization operation of the Bitmap image during the animation, speeding up the display  

Speed, this setting item depends on the settings of dither and xfermode      

 

setMaskFilter(MaskFilter maskfilter);  

Set MaskFilter, you can use different MaskFilter to achieve filter effects, such as filtering, stereo, etc.      

 

setColorFilter(ColorFilter colorfilter);  

Set the color filter, you can achieve the transformation effect without color when drawing the color    

 

setPathEffect(PathEffect effect);  

Set the effect of drawing paths, such as stippling lines, etc.       

 

setShader (Shader shader);  

Set image effects, use Shader to draw various gradient effects  

 

setShadowLayer(float radius ,float dx,float dy,int color);  

Set a shadow layer below the graphics to produce a shadow effect, radius is the angle of the shadow, dx and dy are the distances of the shadow on the x-axis and y-axis, and color is the color of the shadow       

 

setStyle(Paint.Style style);  

设置画笔的样式,为FILL,FILL_OR_STROKE,或STROKE  

 

setStrokeCap(Paint.Cap cap);  

当画笔样式为STROKE或FILL_OR_STROKE时,设置笔刷的图形样式,如圆形样式  

Cap.ROUND,或方形样式Cap.SQUARE  

 

setSrokeJoin(Paint.Join join);  

设置绘制时各图形的结合方式,如平滑效果等    

 

setStrokeWidth(float width);  

当画笔样式为STROKE或FILL_OR_STROKE时,设置笔刷的粗细度       

 

setXfermode(Xfermode xfermode);  

设置图形重叠时的处理方式,如合并,取交集或并集,经常用来制作橡皮的擦除效果  

 

2.文本绘制  

 

setFakeBoldText(boolean fakeBoldText);  

模拟实现粗体文字,设置在小字体上效果会非常差     

 

setSubpixelText(boolean subpixelText);  

设置该项为true,将有助于文本在LCD屏幕上的显示效果       

 

setTextAlign(Paint.Align align);  

设置绘制文字的对齐方向  

 

setTextScaleX(float scaleX);  

设置绘制文字x轴的缩放比例,可以实现文字的拉伸的效果  

 

setTextSize(float textSize);  

设置绘制文字的字号大小  

 

setTextSkewX(float skewX);  

设置斜体文字,skewX为倾斜弧度  

 

setTypeface(Typeface typeface);  

设置Typeface对象,即字体风格,包括粗体,斜体以及衬线体,非衬线体等      

 

setUnderlineText(boolean underlineText);  

设置带有下划线的文字效果       

 

setStrikeThruText(boolean strikeThruText);  

设置带有删除线的效果


3.标志

Paint.FILTER_BITMAP_FLAG是使位图过滤的位掩码标志
Paint.ANTI_ALIAS_FLAG是使位图抗锯齿的标志
Paint.DITHER_FLAG是使位图进行有利的抖动的位掩码标志


4.操作模式

p.setXfermode(new PorterDuffXfermode(Mode.DST_IN));


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324926292&siteId=291194637