Skip to content

Commit 0ff5aea

Browse files
committed
stripes fix
bug fix: the stripes are not drawn on the entire area
1 parent dd1158d commit 0ff5aea

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Sources/ComponentsKit/ProgressBar/Models/ProgressBarVM.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,31 +111,35 @@ extension ProgressBarVM {
111111
return self.size != oldModel.size
112112
}
113113

114-
public func stripesPath(in rect: CGRect) -> Path {
115-
var path = Path()
114+
private func stripesCGPath(in rect: CGRect) -> CGMutablePath {
115+
let stripeWidth: CGFloat = 2
116+
let stripeSpacing: CGFloat = 4
117+
let stripeAngle: Angle = .degrees(135)
118+
119+
let path = CGMutablePath()
116120
let step = stripeWidth + stripeSpacing
117121
let radians = stripeAngle.radians
118122
let dx = rect.height * tan(radians)
119-
120-
for x in stride(from: dx - step, through: rect.width + step, by: step) {
123+
for x in stride(from: dx, through: rect.width + rect.height, by: step) {
121124
let topLeft = CGPoint(x: x, y: 0)
122125
let topRight = CGPoint(x: x + stripeWidth, y: 0)
123126
let bottomLeft = CGPoint(x: x + dx, y: rect.height)
124127
let bottomRight = CGPoint(x: x + stripeWidth + dx, y: rect.height)
125-
126128
path.move(to: topLeft)
127129
path.addLine(to: topRight)
128130
path.addLine(to: bottomRight)
129131
path.addLine(to: bottomLeft)
130132
path.closeSubpath()
131133
}
132-
133134
return path
134135
}
135136

137+
public func stripesPath(in rect: CGRect) -> Path {
138+
return Path(self.stripesCGPath(in: rect))
139+
}
140+
136141
public func stripesBezierPath(in rect: CGRect) -> UIBezierPath {
137-
let swiftUIPath = stripesPath(in: rect)
138-
return UIBezierPath(cgPath: swiftUIPath.cgPath)
142+
return UIBezierPath(cgPath: self.stripesCGPath(in: rect))
139143
}
140144
}
141145

Sources/ComponentsKit/ProgressBar/SUProgressBar.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public struct SUProgressBar: View {
7979

8080
StripesShape(model: self.model)
8181
.foregroundStyle(self.model.color.main.color)
82-
.scaleEffect(1.2)
8382
.cornerRadius(self.model.computedCornerRadius)
8483
.clipped()
8584
}

0 commit comments

Comments
 (0)