Skip to content

Commit

Permalink
Simplify ApplyColor
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasf committed Jul 28, 2024
1 parent 78180d3 commit c893a3c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Sources/SwiftSCAD/Development/ApplyColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ struct ApplyColor3D: WrappedGeometry3D {
var invocation: Invocation? { color.invocation }
}

extension Geometry2D {
public func colored(_ color: Color) -> any Geometry2D {
public extension Geometry2D {
func colored(_ color: Color) -> any Geometry2D {
ApplyColor2D(color: color, body: self)
}

public func colored(_ color: Color, alpha: Double) -> any Geometry2D {
func colored(_ color: Color, alpha: Double) -> any Geometry2D {
ApplyColor2D(color: color.withAlphaComponent(alpha), body: self)
}

Expand All @@ -28,17 +28,17 @@ extension Geometry2D {
/// - blue: The blue component, in the range 0.0 to 1.0.
/// - alpha: The alpha component, in the range 0.0 to 1.0.
/// - Returns: A colored geometry
public func colored(red: Double, green: Double, blue: Double, alpha: Double = 1) -> any Geometry2D {
func colored(red: Double, green: Double, blue: Double, alpha: Double = 1) -> any Geometry2D {
ApplyColor2D(color: .init(red: red, green: green, blue: blue, alpha: alpha), body: self)
}
}

extension Geometry3D {
public func colored(_ color: Color) -> any Geometry3D {
public extension Geometry3D {
func colored(_ color: Color) -> any Geometry3D {
ApplyColor3D(color: color, body: self)
}

public func colored(_ color: Color, alpha: Double) -> any Geometry3D {
func colored(_ color: Color, alpha: Double) -> any Geometry3D {
ApplyColor3D(color: color.withAlphaComponent(alpha), body: self)
}

Expand All @@ -49,7 +49,7 @@ extension Geometry3D {
/// - blue: The blue component, in the range 0.0 to 1.0.
/// - alpha: The alpha component, in the range 0.0 to 1.0.
/// - Returns: A colored geometry
public func colored(red: Double, green: Double, blue: Double, alpha: Double = 1) -> any Geometry3D {
func colored(red: Double, green: Double, blue: Double, alpha: Double = 1) -> any Geometry3D {
ApplyColor3D(color: .init(red: red, green: green, blue: blue, alpha: alpha), body: self)
}
}

0 comments on commit c893a3c

Please sign in to comment.