From 4cd46028dc67211b28cc13c3a482d322688372b5 Mon Sep 17 00:00:00 2001 From: liujing Date: Wed, 1 Jun 2022 18:20:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81,=E6=B7=BB=E5=8A=A0=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmi/ui/widget/CircularProgressView.kt | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt index 0fcf706bb7..214cd5e923 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CircularProgressView.kt @@ -59,7 +59,6 @@ class CircularProgressView @JvmOverloads constructor( mProgPaint.isDither = true // 设置抖动 mProgPaint.strokeWidth = typedArray.getDimension(R.styleable.CircularProgressView_progWidth, 10.0f) mProgPaint.color = typedArray.getColor(R.styleable.CircularProgressView_progColor, Color.BLUE) -// mProgPaint.setPathEffect() // 初始化进度圆环渐变色 val startColor = typedArray.getColor(R.styleable.CircularProgressView_progStartColor, -1) val firstColor = typedArray.getColor(R.styleable.CircularProgressView_progFirstColor, -1) @@ -81,19 +80,17 @@ class CircularProgressView @JvmOverloads constructor( val mRectT = getPaddingTop() + (viewHigh - mRectLength) / 2 mRectF = RectF(mRectL.toFloat(), mRectT.toFloat(), (mRectL + mRectLength).toFloat(), (mRectT + mRectLength).toFloat()) -// // 设置进度圆环渐变色 -// mColorArray?.let { -//// mProgPaint.shader = LinearGradient( -//// 0f, 0f, 0f, -//// measuredWidth.toFloat(), mColorArray!![0], mColorArray!![1], Shader.TileMode.MIRROR) -// sweepGradient() -// } - Log.d(TAG, mRectL.toString() + "," + mRectT.toString()) - Log.d(TAG, mRectF.toString() + "," + "width:" + measuredWidth.toString() + "," + "PaddingLeft:" + getPaddingLeft().toString()) + Log.d(TAG, "onMeasure:" + mRectF.toString() + "," + "width:" + measuredWidth.toString() + "," + "PaddingLeft:" + getPaddingLeft().toString()) } - //渐变色 + /** + * 渐变色执行方法 + * sweepGradient扫描渐变,前两个参数为中心坐标 + * mConvertColorsArray:渐变色数组 + * position:与渐变数组个数对应的渐变点 + * Matrix:改变开始渐变的角度,默认3点方向,改为12点方向 + * */ fun sweepGradient() { if (mConvertColorsArray == null) { return @@ -101,8 +98,7 @@ class CircularProgressView @JvmOverloads constructor( val position = FloatArray(2) position[0] = 0.0f; position[1] = mProgress.toFloat() * 0.01f - Log.d(TAG, "mProgress" + mProgress.toString()) - val sweepGradient = SweepGradient((measuredWidth / 2).toFloat(), (measuredHeight/ 2).toFloat(), mConvertColorsArray!!, position) + val sweepGradient = SweepGradient((measuredWidth / 2).toFloat(), (measuredHeight / 2).toFloat(), mConvertColorsArray!!, position) val matrix = Matrix() matrix.setRotate(-90F, (measuredWidth / 2).toFloat(), (measuredHeight / 2).toFloat()) sweepGradient.setLocalMatrix(matrix); @@ -216,17 +212,8 @@ class CircularProgressView @JvmOverloads constructor( } - fun setProgColor(startColor: Int, endColor: Int) { mConvertColorsArray = intArrayOf(ContextCompat.getColor(context, startColor), ContextCompat.getColor(context, endColor)) -// mColorArray?.let { -// if (mRectF != null) { -//// mProgPaint.shader = LinearGradient(0f, 0f, 0f, -//// getMeasuredWidth().toFloat(), mColorArray!![0], mColorArray!![1], Shader.TileMode.MIRROR) -// Log.d(TAG, "setProgColor:" + getMeasuredWidth().toString() + "mProgress:" + mProgress.toString()) -// sweepGradient() -// } -// } } fun setProgColor(colorArray: IntArray) {