当前位置: 首页 > news >正文

云浮新兴哪有做网站的google play谷歌商店

云浮新兴哪有做网站的,google play谷歌商店,承德百度网站建设,东莞网络诈骗最新消息MaskFilter 作用对象:MaskFilter 主要用于Paint的外观效果,给用Paint绘制的内容添加模糊或者浮雕效果应用效果: MaskFilter 处理位图的遮罩效果,影响绘制的边缘或整体形状主要用于模糊处理、浮雕效果等,通过影响绘制对…

MaskFilter

  • 作用对象:MaskFilter 主要用于Paint的外观效果,给用Paint绘制的内容添加模糊或者浮雕效果
  • 应用效果:
    • MaskFilter 处理位图的遮罩效果,影响绘制的边缘或整体形状
    • 主要用于模糊处理、浮雕效果等,通过影响绘制对象的边缘来实现
  • 常用子类:
    BlurMaskFilter:实现模糊效果,可以设置不同的模糊样式(NORMAL、SOLID、OUTER、INNER)
    EmbossMaskFilter:创建浮雕效果,通过设置光源方向、环境光强度等来实现

BlurMaskFilter模糊遮罩滤镜

  • Java源码
public class BlurMaskFilter extends MaskFilter {public enum Blur {/*** Blur inside and outside the original border.*/NORMAL(0),/*** Draw solid inside the border, blur outside.*/SOLID(1),/*** Draw nothing inside the border, blur outside.*/OUTER(2),/*** Blur inside the border, draw nothing outside.*/INNER(3);Blur(int value) {native_int = value;}final int native_int;}/*** Create a blur maskfilter.** @param radius The radius to extend the blur from the original mask. Must be > 0.* @param style  The Blur to use* @return       The new blur maskfilter*/public BlurMaskFilter(float radius, Blur style) {native_instance = nativeConstructor(radius, style.native_int);}private static native long nativeConstructor(float radius, int style);
}
  • 构造函数详解
    • radius(模糊半径)
      • 类型:float
      • 作用:指定模糊的强度。值越大,模糊效果越明显。
      • 描述:模糊半径决定了模糊的范围,单位通常是像素。较小的值会产生轻微的模糊,而较大的值会导致显著的模糊效果。
    • style(模糊样式):
      • 类型:BlurMaskFilter.Blur
      • 作用:决定模糊的应用方式,即模糊效果的样式。
      • 可用值:
        • Blur.NORMAL
        • 描述:模糊内外边框+绘制内容。适用于需要整体柔和模糊效果的场景
        • Blur.SOLID
        • 描述:模糊内外边框+不模糊绘制内容。适用于增强物体的边缘
        • Blur.OUTER
        • 描述:只模糊外边框+不模糊内边框+内边框内的绘制内容透明显示。适用于突出物体本身
        • Blur.INNER
        • 描述:只模糊内边框+不模糊外边框+外边框外的绘制内容透明显示。适用于创建内嵌阴影或凹陷效果
  • XML文件
<?xml version="1.0" encoding="utf-8"?>
<com.example.myapplication.MyViewxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent" />
  • 自定义View代码
class MyView @JvmOverloads constructor(context: Context,attrs: AttributeSet? = null,defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {private val mDrawPaint: Paint = Paint().apply {isDither = trueisAntiAlias = trueisFilterBitmap = truecolor = Color.BLUE}private val radius = 100fprivate val spacing = 500foverride fun onDraw(canvas: Canvas) {super.onDraw(canvas)// Draw circle with NORMAL blurmDrawPaint.maskFilter = BlurMaskFilter(20f, BlurMaskFilter.Blur.NORMAL)canvas.drawCircle(spacing, spacing, radius, mDrawPaint)// Draw circle with SOLID blurmDrawPaint.maskFilter = BlurMaskFilter(20f, BlurMaskFilter.Blur.SOLID)canvas.drawCircle(spacing , spacing * 2, radius, mDrawPaint)// Draw circle with OUTER blurmDrawPaint.maskFilter = BlurMaskFilter(20f, BlurMaskFilter.Blur.OUTER)canvas.drawCircle(spacing , spacing * 3, radius, mDrawPaint)// Draw circle with INNER blurmDrawPaint.maskFilter = BlurMaskFilter(20f, BlurMaskFilter.Blur.INNER)canvas.drawCircle(spacing , spacing * 4, radius, mDrawPaint)}
}
  • 效果图
    在这里插入图片描述

EmbossMaskFilter浮雕遮罩滤镜

  • Java源码
public class EmbossMaskFilter extends MaskFilter {/*** Create an emboss maskfilter** @deprecated This subclass is not supported and should not be instantiated.** @param direction  array of 3 scalars [x, y, z] specifying the direction of the light source* @param ambient    0...1 amount of ambient light* @param specular   coefficient for specular highlights (e.g. 8)* @param blurRadius amount to blur before applying lighting (e.g. 3)* @return           the emboss maskfilter*/@Deprecatedpublic EmbossMaskFilter(float[] direction, float ambient, float specular, float blurRadius) {if (direction.length < 3) {throw new ArrayIndexOutOfBoundsException();}native_instance = nativeConstructor(direction, ambient, specular, blurRadius);}private static native long nativeConstructor(float[] direction, float ambient, float specular, float blurRadius);
}
  • 构造函数详解
    • direction(光源方向):
      • 类型:float[]
      • 作用:指定光源的方向。
      • 描述:这是一个长度为 3 的数组,分别表示光源在 x、y、z 轴上的方向分量。正常情况下,这些值不需要是单位向量,但它们定义了光源的相对方向。根据光源的方向,浮雕的阴影和高光效果会有所不同
    • ambient(环境光):
      • 类型:float
      • 作用:定义环境光的强度
      • 范围:通常在 01 之间
      • 描述:环境光影响整个浮雕效果的亮度。值越大,整体效果越亮,越小则越暗
    • specular(高光反射系数):
      • 类型:float
      • 作用:定义高光的反射强度
      • 描述:高光反射系数影响浮雕效果中高光部分的亮度。较高的值会使高光更明显,较低的值则使高光不明显
    • blurRadius(模糊半径):
      • 类型:float
      • 作用:定义浮雕效果的模糊半径
      • 描述:模糊半径决定了浮雕边缘的模糊程度。较小的值会使浮雕边缘更锐利,而较大的值会使边缘更加柔和
  • XML文件
<?xml version="1.0" encoding="utf-8"?>
<com.example.myapplication.MyViewxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent" />
  • 自定义View代码
class MyView @JvmOverloads constructor(context: Context,attrs: AttributeSet? = null,defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {private var mPaint: Paint = Paint().apply {isAntiAlias = truecolor = Color.RED  // 用红色以更好地展示浮雕效果}private var embossFilter: EmbossMaskFilter? = nullinit {// 设置浮雕效果的参数val direction = floatArrayOf(1f, 0f, 0f) // 从上方垂直照射光源val ambient = 0.6f                       // 较低的环境光val specular = 5f                        // 较高的高光反射val blurRadius = 50f                      // 适中的模糊半径embossFilter = EmbossMaskFilter(direction, ambient, specular, blurRadius)mPaint.maskFilter = embossFiltersetLayerType(LAYER_TYPE_SOFTWARE, mPaint)}override fun onDraw(canvas: Canvas) {super.onDraw(canvas)canvas.drawColor(Color.DKGRAY) // 设置深灰色背景以增加对比度// 设置椭圆的矩形边界val left = 100fval top = 100fval right = width - 100fval bottom = height - 100f// 绘制椭圆canvas.drawOval(left, top, right, bottom, mPaint)}
}
  • 效果图
    -在这里插入图片描述
http://www.hkea.cn/news/528934/

相关文章:

  • 用wps网站栏目做树形结构图网页设计代码案例
  • 多媒体网站设计开发是指什么每日关键词搜索排行
  • 网站 seo正规网络公司关键词排名优化
  • 建立网站赚多少钱seo收录排名
  • 怎么做app网站seo学习网站
  • 广西建设职业技术学院官网免费的seo优化
  • 凡科网电脑版怎么做网站百度知道官网手机版
  • 贵卅省住房和城乡建设厅网站周口seo推广
  • 搭建flv视频网站seo工具查询
  • 企业展示网站 数据库设计模板自助建站
  • 房地产设计师上海seo网络优化
  • wordpress迁移打不开百度seo泛解析代发排名
  • 网站兼容性测试怎么做微信营销软件群发
  • wordpress如何设置内容页seo营销优化
  • 高端大气的网站制作南宁百度seo软件
  • 沙井营销型网站建设成人培训机构
  • 网站没有被百度收录搜索引擎排名优化公司
  • 手机网站转换小程序晋江怎么交换友情链接
  • 专业做网站的公司疫情放开最新消息今天
  • 不用写代码做网站软件长沙优化网站
  • o2o商城网站建设方案广告策划案优秀案例
  • 日照做网站的那家做的好百度网页链接
  • 建设云个人证件查询系统上海seo培训
  • 网站流量提供商杭州seo排名
  • 做装饰工程的在什么网站投标自建站
  • 地球人--一家只做信誉的网站帮忙推广的平台
  • 网站建设外包协议天津网站排名提升
  • 邯郸教育行业网站建设百度推广代理商查询
  • 政府网站有哪些网站seo最新优化方法
  • 做广告牌子seo外链工具