Skip to content

Commit

Permalink
Remove absolute() and relative() for now
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasf committed Oct 19, 2024
1 parent faa45ae commit cbeecb4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ extension BezierPath {
public struct Component {
private enum Contents {
case points ([OptionalVector<V>])
case subcomponents ([Component], positioning: BezierPath.Positioning?)
case subcomponents ([Component])
}
private let contents: Contents

internal init(_ points: [OptionalVector<V>]) {
contents = .points(points)
}

internal init(group: [Component], positioning: BezierPath.Positioning? = nil) {
contents = .subcomponents(group, positioning: positioning)
internal init(group: [Component]) {
contents = .subcomponents(group)
}

internal func bezierCurves(start: inout V, positioning: BezierPath<V>.Positioning) -> [BezierCurve<V>] {
Expand All @@ -22,16 +22,10 @@ extension BezierPath {
start = controlPoints.last!
return [BezierCurve(controlPoints: controlPoints)]

case .subcomponents (let components, let override):
if let override {
return components.flatMap {
$0.bezierCurves(start: &start, positioning: override)
}
} else {
var localStart = start
return components.flatMap {
$0.bezierCurves(start: &localStart, positioning: positioning)
}
case .subcomponents (let components):
var localStart = start
return components.flatMap {
$0.bezierCurves(start: &localStart, positioning: positioning)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@ public func curve<V: Vector>(_ controlPoints: [V]) -> BezierPath<V>.Component {
// MARK: - Groups

public func group<V: Vector>(@BezierPath<V>.Builder builder: () -> [BezierPath<V>.Component]) -> BezierPath<V>.Component {
.init(group: builder(), positioning: nil)
}

public func relative<V: Vector>(@BezierPath<V>.Builder builder: () -> [BezierPath<V>.Component]) -> BezierPath<V>.Component {
.init(group: builder(), positioning: .relative)
}

public func absolute<V: Vector>(@BezierPath<V>.Builder builder: () -> [BezierPath<V>.Component]) -> BezierPath<V>.Component {
.init(group: builder(), positioning: .absolute)
.init(group: builder())
}


Expand Down
3 changes: 2 additions & 1 deletion Sources/SwiftSCAD/Values/Edge Profiles/Fillet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ extension Fillet: EdgeProfileShape {
EnvironmentReader3D { environment in
let facetsPerRev = environment.facets.facetCount(circleRadius: max(width, height))
let facetCount = max(Int(ceil(Double(facetsPerRev) / 4.0)), 1)
let angleIncrement = 90° / Double(facetCount)

return (0...facetCount).map { f in
let angle = (Double(f) / Double(facetCount)) * 90°
let angle = Double(f) * angleIncrement
let inset = (cos(angle) - 1) * width
let zOffset = sin(angle) * height
return shape.offset(amount: inset, style: .round)
Expand Down

0 comments on commit cbeecb4

Please sign in to comment.