@@ -112,6 +112,7 @@ public final class DrawingLibrary: NativeLibrary {
112
112
// Parameter objects
113
113
self . define ( " current-drawing " , as: self . drawingParam)
114
114
self . define ( " current-shape " , as: self . shapeParam)
115
+
115
116
// Drawings
116
117
self . define ( Procedure ( " drawing? " , isDrawing) )
117
118
self . define ( Procedure ( " make-drawing " , makeDrawing) )
@@ -125,6 +126,7 @@ public final class DrawingLibrary: NativeLibrary {
125
126
self . define ( Procedure ( " draw " , draw) )
126
127
self . define ( Procedure ( " draw-dashed " , drawDashed) )
127
128
self . define ( Procedure ( " fill " , fill) )
129
+ self . define ( Procedure ( " fill-gradient " , fillGradient) )
128
130
self . define ( Procedure ( " draw-text " , drawText) )
129
131
self . define ( Procedure ( " draw-image " , drawImage) )
130
132
self . define ( Procedure ( " draw-drawing " , drawDrawing) )
@@ -164,15 +166,14 @@ public final class DrawingLibrary: NativeLibrary {
164
166
165
167
// Transformations
166
168
self . define ( Procedure ( " transformation? " , isTransformation) )
167
- self . define ( Procedure ( " make- transformation" , makeTransformation ) )
169
+ self . define ( Procedure ( " transformation " , transformation ) )
168
170
self . define ( Procedure ( " invert " , invert) )
169
171
self . define ( Procedure ( " translate " , translate) )
170
172
self . define ( Procedure ( " scale " , scale) )
171
173
self . define ( Procedure ( " rotate " , rotate) )
172
174
173
175
// Colors
174
176
self . define ( Procedure ( " color? " , isColor) )
175
- self . define ( Procedure ( " make-color " , makeColor) )
176
177
self . define ( Procedure ( " color " , color) )
177
178
self . define ( Procedure ( " color-red " , colorRed) )
178
179
self . define ( Procedure ( " color-green " , colorGreen) )
@@ -203,13 +204,13 @@ public final class DrawingLibrary: NativeLibrary {
203
204
204
205
// Define constants
205
206
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)) " )
213
214
214
215
// Syntax definitions
215
216
self . define ( " drawing " , via: """
@@ -339,12 +340,12 @@ public final class DrawingLibrary: NativeLibrary {
339
340
}
340
341
341
342
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) ) )
343
344
return . void
344
345
}
345
346
346
347
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) ) )
348
349
return . void
349
350
}
350
351
@@ -831,7 +832,7 @@ public final class DrawingLibrary: NativeLibrary {
831
832
832
833
private func transformShape( shape: Expr , transformation: Expr ) throws -> Expr {
833
834
return . object( Shape ( . transformed( try self . shape ( from: shape) ,
834
- try self . transformation ( from: transformation) ) ) )
835
+ try self . tformation ( from: transformation) ) ) )
835
836
}
836
837
837
838
private func flipShape( shape: Expr , box: Expr ? , orientation: Expr ? ) throws -> Expr {
@@ -1016,7 +1017,7 @@ public final class DrawingLibrary: NativeLibrary {
1016
1017
return . false
1017
1018
}
1018
1019
1019
- private func makeTransformation ( args: Arguments ) throws -> Expr {
1020
+ private func transformation ( args: Arguments ) throws -> Expr {
1020
1021
var transform = AffineTransform ( )
1021
1022
for arg in args {
1022
1023
transform. append ( try self . affineTransform ( arg) )
@@ -1053,7 +1054,7 @@ public final class DrawingLibrary: NativeLibrary {
1053
1054
return . object( Transformation ( transform) )
1054
1055
}
1055
1056
1056
- private func transformation ( from expr: Expr ) throws -> Transformation {
1057
+ private func tformation ( from expr: Expr ) throws -> Transformation {
1057
1058
guard case . object( let obj) = expr, let transform = obj as? Transformation else {
1058
1059
throw RuntimeError . type ( expr, expected: [ . transformationType] )
1059
1060
}
@@ -1079,20 +1080,13 @@ public final class DrawingLibrary: NativeLibrary {
1079
1080
return . false
1080
1081
}
1081
1082
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 {
1083
1084
return . object( ImmutableBox ( Color ( red: try red. asDouble ( coerce: true ) ,
1084
1085
green: try green. asDouble ( coerce: true ) ,
1085
1086
blue: try blue. asDouble ( coerce: true ) ,
1086
1087
alpha: try ( alpha ?? . flonum( 1.0 ) ) . asDouble ( coerce: true ) ) ) )
1087
1088
}
1088
1089
1089
- private func color( _ expr: Expr ) -> Expr {
1090
- if case . char( _) = expr {
1091
- return . true
1092
- }
1093
- return . false
1094
- }
1095
-
1096
1090
private func colorRed( _ expr: Expr ) throws -> Expr {
1097
1091
guard case . object( let obj) = expr, let colorRef = obj as? ImmutableBox < Color > else {
1098
1092
throw RuntimeError . type ( expr, expected: [ . colorType] )
0 commit comments