inverting colors of athens(cairo)canvas
Is it possible to invert the colors of a Athens Canvas? After some digging I found paintMode and paintTransform; however the former doesn't support such method (maybe some combination of xor and over?); and the former is only for some specific colors. I also tried changing Color>>asAthensPaintOn: ^ (Color white - self) alpha: (self alpha) "invert the color" and while this works nicely for most cases, it is overriding a library and _doesn't_ work for bitmaps (for obvious reasons). So is there some way how to invert it? Effectively a mask over the canvas. (Doing it at Morphic level should also be a viable option, provided it is possible there). Thanks, Peter
Hi Peter, at the morphic level you might eventually look at ColorMappingCanvas and make a subclass. werner
2015-05-01 17:50 GMT+02:00 Werner Kassens <wkassens@libello.com>:
Hi Peter, at the morphic level you might eventually look at ColorMappingCanvas and make a subclass. werner
Inverting the color of a form: Display reverse:(0@0 extent:600@300). Inverting colors of an athens drawing: Paint a white rectangle with paint mode "difference" |view paint | view := AthensSceneView new. paint := nil. view scene:[:canvas | paint ifNil:[paint := (Form fromDisplay:(0@0 extent:600@300) )asAthensPaintOn: canvas]. canvas surface clear:Color white. canvas setPaint: paint. canvas drawShape:(0@0 extent:600@300). canvas paintMode restoreAfter:[ canvas setPaint: Color white. canvas paintMode difference. canvas drawShape:(0@0 extent:600@300). ]. ]. view openInWindow.
Thanks Nicolai! I should've tried all the paint modes before asking. -_- Peter On Fri, May 1, 2015 at 8:32 PM, Nicolai Hess <nicolaihess@web.de> wrote:
2015-05-01 17:50 GMT+02:00 Werner Kassens <wkassens@libello.com>:
Hi Peter, at the morphic level you might eventually look at ColorMappingCanvas and make a subclass. werner
Inverting the color of a form:
Display reverse:(0@0 extent:600@300).
Inverting colors of an athens drawing: Paint a white rectangle with paint mode "difference"
|view paint | view := AthensSceneView new. paint := nil. view scene:[:canvas | paint ifNil:[paint := (Form fromDisplay:(0@0 extent:600@300) )asAthensPaintOn: canvas]. canvas surface clear:Color white. canvas setPaint: paint. canvas drawShape:(0@0 extent:600@300). canvas paintMode restoreAfter:[ canvas setPaint: Color white. canvas paintMode difference. canvas drawShape:(0@0 extent:600@300). ]. ]. view openInWindow.
participants (3)
-
Nicolai Hess -
Peter Uhnák -
Werner Kassens