I have an arc that starts at 270 and sweeps for 200 degrees. trying to figure out how to do a 3 color gradient.. was trying to use example from Erel's circular progress bar but not working for me.
trying to have green on left, yellow in middle top and red on right. see attached.
B4X:
Dim startAngle = 170, sweepAngle = Value / GraphMaxValue * 201 As Float
Dim cColor As Int = xui.PaintOrColorToColor(CarrotColor)
bc.DrawArc2(cx, cy, radius, fullBrush, False, stroke, startAngle, 200)
If ShowScale = True Then
Dim sColor As Int = xui.PaintOrColorToColor(ScaleColor)
bc.DrawArc(cx, cy, radius - stroke, sColor, False, 8dip, 10 - 2, 2)
bc.DrawArc(cx, cy, radius - stroke, sColor, False, 8dip, 320 - 1, 2)
bc.DrawArc(cx, cy, radius - stroke, sColor, False, 8dip, 270 - 1 , 2)
bc.DrawArc(cx, cy, radius - stroke, sColor, False, 8dip, 220 - 1 , 2)
bc.DrawArc(cx, cy, radius - stroke, sColor, False, 8dip, 170, 2)
End If
bc.DrawArc(cx, cy, radius + 5, cColor, False, stroke + CarrotLength, startAngle - (CarrotWidth / 2) + sweepAngle , CarrotWidth)
If ShowCarrotGoal = True Then
Dim GoalsweepAngle = CarrotGoalValue / GraphMaxValue * 201 As Float
Dim cGColor As Int = xui.PaintOrColorToColor(CarrotGoalColor)
bc.DrawArc(cx, cy, radius + 5, cGColor, False, stroke + 5, startAngle - (CarrotGoalWidth / 2) + GoalsweepAngle , CarrotGoalWidth)
End If
B4X:
bc.Initialize(iv.Width, iv.Width)
Dim g As BitmapCreator
g.Initialize(bc.mWidth, bc.mHeight)
Dim r As B4XRect
r.Initialize(0, 0, bc.mWidth, 2) 'ignore
bc.FillGradient(Array As Int(clr1, clr2, clr3), r, "LEFT_RIGHT")
For y = 0 To g.mHeight - 1
For x = 0 To g.mWidth - 1
Dim angle As Float = ATan2D(y - cy, x - cx) + 190.5
Log("Angle: " & angle)
If angle < 0 Then angle = angle + 360
g.CopyPixel(bc, bc.mWidth * angle / 360, 0, x, y)
Next
Next
fullBrush = bc.CreateBrushFromBitmapCreator(g)
trying to have green on left, yellow in middle top and red on right. see attached.