@@ -112,6 +112,7 @@ public final class DrawingLibrary: NativeLibrary {
112112 // Parameter objects
113113 self . define ( " current-drawing " , as: self . drawingParam)
114114 self . define ( " current-shape " , as: self . shapeParam)
115+
115116 // Drawings
116117 self . define ( Procedure ( " drawing? " , isDrawing) )
117118 self . define ( Procedure ( " make-drawing " , makeDrawing) )
@@ -125,6 +126,7 @@ public final class DrawingLibrary: NativeLibrary {
125126 self . define ( Procedure ( " draw " , draw) )
126127 self . define ( Procedure ( " draw-dashed " , drawDashed) )
127128 self . define ( Procedure ( " fill " , fill) )
129+ self . define ( Procedure ( " fill-gradient " , fillGradient) )
128130 self . define ( Procedure ( " draw-text " , drawText) )
129131 self . define ( Procedure ( " draw-image " , drawImage) )
130132 self . define ( Procedure ( " draw-drawing " , drawDrawing) )
@@ -164,15 +166,14 @@ public final class DrawingLibrary: NativeLibrary {
164166
165167 // Transformations
166168 self . define ( Procedure ( " transformation? " , isTransformation) )
167- self . define ( Procedure ( " make- transformation" , makeTransformation ) )
169+ self . define ( Procedure ( " transformation " , transformation ) )
168170 self . define ( Procedure ( " invert " , invert) )
169171 self . define ( Procedure ( " translate " , translate) )
170172 self . define ( Procedure ( " scale " , scale) )
171173 self . define ( Procedure ( " rotate " , rotate) )
172174
173175 // Colors
174176 self . define ( Procedure ( " color? " , isColor) )
175- self . define ( Procedure ( " make-color " , makeColor) )
176177 self . define ( Procedure ( " color " , color) )
177178 self . define ( Procedure ( " color-red " , colorRed) )
178179 self . define ( Procedure ( " color-green " , colorGreen) )
@@ -203,13 +204,13 @@ public final class DrawingLibrary: NativeLibrary {
203204
204205 // Define constants
205206 self . define ( " zero-point " , via: " (define zero-point (point 0 0)) " )
206- self . define ( " black " , via: " (define black (make- color 0 0 0)) " )
207- self . define ( " gray " , via: " (define gray (make- color 0.5 0.5 0.5)) " )
208- self . define ( " white " , via: " (define white (make- color 1 1 1)) " )
209- self . define ( " red " , via: " (define red (make- color 1 0 0)) " )
210- self . define ( " green " , via: " (define green (make- color 0 1 0)) " )
211- self . define ( " blue " , via: " (define blue (make- color 0 0 1)) " )
212- self . define ( " yellow " , via: " (define yellow (make- color 1 1 0)) " )
207+ self . define ( " black " , via: " (define black (color 0 0 0)) " )
208+ self . define ( " gray " , via: " (define gray (color 0.5 0.5 0.5)) " )
209+ self . define ( " white " , via: " (define white (color 1 1 1)) " )
210+ self . define ( " red " , via: " (define red (color 1 0 0)) " )
211+ self . define ( " green " , via: " (define green (color 0 1 0)) " )
212+ self . define ( " blue " , via: " (define blue (color 0 0 1)) " )
213+ self . define ( " yellow " , via: " (define yellow (color 1 1 0)) " )
213214
214215 // Syntax definitions
215216 self . define ( " drawing " , via: """
@@ -339,12 +340,12 @@ public final class DrawingLibrary: NativeLibrary {
339340 }
340341
341342 private func enableTransformation( tf: Expr , drawing: Expr ? ) throws -> Expr {
342- try self . drawing ( from: drawing) . append ( . concatTransformation( try self . transformation ( from: tf) ) )
343+ try self . drawing ( from: drawing) . append ( . concatTransformation( try self . tformation ( from: tf) ) )
343344 return . void
344345 }
345346
346347 private func disableTransformation( tf: Expr , drawing: Expr ? ) throws -> Expr {
347- try self . drawing ( from: drawing) . append ( . undoTransformation( try self . transformation ( from: tf) ) )
348+ try self . drawing ( from: drawing) . append ( . undoTransformation( try self . tformation ( from: tf) ) )
348349 return . void
349350 }
350351
@@ -831,7 +832,7 @@ public final class DrawingLibrary: NativeLibrary {
831832
832833 private func transformShape( shape: Expr , transformation: Expr ) throws -> Expr {
833834 return . object( Shape ( . transformed( try self . shape ( from: shape) ,
834- try self . transformation ( from: transformation) ) ) )
835+ try self . tformation ( from: transformation) ) ) )
835836 }
836837
837838 private func flipShape( shape: Expr , box: Expr ? , orientation: Expr ? ) throws -> Expr {
@@ -1016,7 +1017,7 @@ public final class DrawingLibrary: NativeLibrary {
10161017 return . false
10171018 }
10181019
1019- private func makeTransformation ( args: Arguments ) throws -> Expr {
1020+ private func transformation ( args: Arguments ) throws -> Expr {
10201021 var transform = AffineTransform ( )
10211022 for arg in args {
10221023 transform. append ( try self . affineTransform ( arg) )
@@ -1053,7 +1054,7 @@ public final class DrawingLibrary: NativeLibrary {
10531054 return . object( Transformation ( transform) )
10541055 }
10551056
1056- private func transformation ( from expr: Expr ) throws -> Transformation {
1057+ private func tformation ( from expr: Expr ) throws -> Transformation {
10571058 guard case . object( let obj) = expr, let transform = obj as? Transformation else {
10581059 throw RuntimeError . type ( expr, expected: [ . transformationType] )
10591060 }
@@ -1079,20 +1080,13 @@ public final class DrawingLibrary: NativeLibrary {
10791080 return . false
10801081 }
10811082
1082- private func makeColor ( red: Expr , green: Expr , blue: Expr , alpha: Expr ? ) throws -> Expr {
1083+ private func color ( red: Expr , green: Expr , blue: Expr , alpha: Expr ? ) throws -> Expr {
10831084 return . object( ImmutableBox ( Color ( red: try red. asDouble ( coerce: true ) ,
10841085 green: try green. asDouble ( coerce: true ) ,
10851086 blue: try blue. asDouble ( coerce: true ) ,
10861087 alpha: try ( alpha ?? . flonum( 1.0 ) ) . asDouble ( coerce: true ) ) ) )
10871088 }
10881089
1089- private func color( _ expr: Expr ) -> Expr {
1090- if case . char( _) = expr {
1091- return . true
1092- }
1093- return . false
1094- }
1095-
10961090 private func colorRed( _ expr: Expr ) throws -> Expr {
10971091 guard case . object( let obj) = expr, let colorRef = obj as? ImmutableBox < Color > else {
10981092 throw RuntimeError . type ( expr, expected: [ . colorType] )
0 commit comments