mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
widget/material: use stroked path to draw loader widget
Signed-off-by: Sebastien Binet <s@sbinet.org>
This commit is contained in:
committed by
Elias Naur
parent
33c5fb63db
commit
8e4940e6a8
@@ -59,32 +59,23 @@ func clipLoader(ops *op.Ops, startAngle, endAngle, radius float64) {
|
|||||||
const thickness = .25
|
const thickness = .25
|
||||||
|
|
||||||
var (
|
var (
|
||||||
outer = float32(radius)
|
width = float32(radius * thickness)
|
||||||
delta = float32(endAngle - startAngle)
|
delta = float32(endAngle - startAngle)
|
||||||
|
|
||||||
vy, vx = math.Sincos(startAngle)
|
vy, vx = math.Sincos(startAngle)
|
||||||
|
|
||||||
pen = f32.Pt(float32(vx), float32(vy)).Mul(outer)
|
pen = f32.Pt(float32(vx), float32(vy)).Mul(float32(radius))
|
||||||
center = f32.Pt(0, 0).Sub(pen)
|
center = f32.Pt(0, 0).Sub(pen)
|
||||||
|
|
||||||
|
style = clip.StrokeStyle{
|
||||||
|
Cap: clip.FlatCap,
|
||||||
|
}
|
||||||
|
|
||||||
p clip.Path
|
p clip.Path
|
||||||
)
|
)
|
||||||
|
|
||||||
p.Begin(ops)
|
p.Begin(ops)
|
||||||
p.Move(pen)
|
p.Move(pen)
|
||||||
|
|
||||||
// Outer arc.
|
|
||||||
p.Arc(center, center, delta)
|
p.Arc(center, center, delta)
|
||||||
|
p.Stroke(width, style).Add(ops)
|
||||||
// Arc cap.
|
|
||||||
pen = p.Pos()
|
|
||||||
cap := pen.Mul(1 - thickness)
|
|
||||||
p.Line(cap.Sub(pen))
|
|
||||||
|
|
||||||
// Inner arc.
|
|
||||||
center = f32.Pt(0, 0).Sub(p.Pos())
|
|
||||||
p.Arc(center, center, -delta)
|
|
||||||
|
|
||||||
// Second arc cap automatically completed by Outline.
|
|
||||||
p.Outline().Add(ops)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user