                 
                 guard let start = _start else { continue }
                 
-                segment.offset(-0.5 * last_width, -0.5 * width) { _, segment in
+                segment.offset(-last.radius, -0.5 * width) { _, segment in
                     _reverse_start = segment.p3
                     segments2.append(.cubic(segment.p2, segment.p1, segment.p0))
                 }

                guard let reverse_start = _reverse_start else { continue }
                
                result.append(Shape.Component(start: start, closed: true, segments: segments1 + [.line(reverse_start)] + segments2.reversed()))
                
                last = p3
                last_width = width
            }
        }
        
        if isClosed && !start.almostEqual(last) {
            
            let width = abs(widths[0])
            let segment = LineSegment(last, start)
            
            guard let s0 = segment.offset(0.5 * last_width, 0.5 * width) else { return result }
            guard let s1 = segment.offset(-0.5 * last_width, -0.5 * width) else { return result }
            
            result.append(Shape.Component(start: s0.p0, closed: true, segments: [.line(s0.p1), .line(s1.p1), .line(s1.p0)]))
        }
        
        return result
    }


extension Shape.Component {
    
    private struct Circle {
        
        var center: Point
        var radius: Double
        
        init(center: Point, width: Double) {
            self.center = center
            self.radius = 0.5 * abs(width)
        }
        
        var shape: Shape.Component {
            return Shape.Component(ellipseIn: Rect(x: center.x - radius, y: center.y - radius, width: 2 * radius, height: 2 * radius))
        }
    }
    
    public func variableRoundStroke(widths: [Double]) -> [Shape.Component] {
        
        precondition(widths.count == self.count + 1, "invalid count of widths.")
        
        var last = Circle(center: self.start, width: widths[0])
        var last_max = last
        var result: [Shape.Component] = []
        
        for (width, segment) in zip(widths.dropFirst(), self) {
            
