1515from mathics .builtin .image .base import Image
1616from mathics .core .atoms import Integer , MachineReal , Rational , Real
1717from mathics .core .convert .expression import to_expression , to_mathics_list
18+ from mathics .core .evaluation import Evaluation
1819from mathics .core .expression import Expression
1920from mathics .core .list import ListExpression
2021from mathics .core .symbols import Symbol
2829
2930class Blend (Builtin ):
3031 """
31- <url>:WMA link:https://reference.wolfram.com/language/ref/Blend.html</url>
32+ <url>:WMA link:
33+ https://reference.wolfram.com/language/ref/Blend.html</url>
3234
3335 <dl>
3436 <dt>'Blend[{$c1$, $c2$}]'
@@ -99,7 +101,7 @@ def do_blend(self, colors, values):
99101 result = [r + p for r , p in zip (result , part )]
100102 return type (components = result )
101103
102- def eval (self , colors , u , evaluation ):
104+ def eval (self , colors , u , evaluation : Evaluation ):
103105 "Blend[{colors___}, u_]"
104106
105107 colors_orig = colors
@@ -171,7 +173,7 @@ class ColorConvert(Builtin):
171173 }
172174 summary_text = "convert between color models"
173175
174- def eval (self , input , colorspace , evaluation ):
176+ def eval (self , input , colorspace , evaluation : Evaluation ):
175177 "ColorConvert[input_, colorspace_String]"
176178
177179 if isinstance (input , Image ):
@@ -201,26 +203,32 @@ def eval(self, input, colorspace, evaluation):
201203
202204class ColorNegate (Builtin ):
203205 """
204- <url>
205- :WMA link :
206- https://reference.wolfram.com/language/ref/ColorNegate.html</url>
206+ Color Inversion ( <url>
207+ :WMA:
208+ https://reference.wolfram.com/language/ref/ColorNegate.html</url>)
207209
208210 <dl>
209- <dt>'ColorNegate[$image$]'
210- <dd>returns the negative of $image$ in which colors have been negated.
211-
212211 <dt>'ColorNegate[$color$]'
213- <dd>returns the negative of a color.
212+ <dd>returns the negative of a color, that is, the RGB color \
213+ subtracted from white.
214214
215- Yellow is RGBColor[1.0, 1.0, 0.0]
216- >> ColorNegate[Yellow]
217- = RGBColor[0., 0., 1.]
215+ <dt>'ColorNegate[$image$]'
216+ <dd>returns an image where each pixel has its color negated.
218217 </dl>
218+
219+ Yellow is 'RGBColor[1.0, 1.0, 0.0]' So when inverted or subtracted \
220+ from 'White', we get blue:
221+
222+ >> ColorNegate[Yellow] == Blue
223+ = True
224+
225+ >> ColorNegate[Import["ExampleData/sunflowers.jpg"]]
226+ = -Image-
219227 """
220228
221- summary_text = "the negative color of a given color"
229+ summary_text = "perform color inversion on a color or image "
222230
223- def eval_for_color (self , color , evaluation ):
231+ def eval_for_color (self , color , evaluation : Evaluation ):
224232 "ColorNegate[color_RGBColor]"
225233 # Get components
226234 r , g , b = [element .to_python () for element in color .elements ]
@@ -229,7 +237,7 @@ def eval_for_color(self, color, evaluation):
229237 # Reconstitute
230238 return Expression (SymbolRGBColor , Real (r ), Real (g ), Real (b ))
231239
232- def eval_for_image (self , image , evaluation ):
240+ def eval_for_image (self , image , evaluation : Evaluation ):
233241 "ColorNegate[image_Image]"
234242 return image .filter (lambda im : PIL .ImageOps .invert (im ))
235243
0 commit comments