inverting colors of athens(cairo)canvas

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

inverting colors of athens(cairo)canvas

Peter Uhnak
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
Reply | Threaded
Open this post in threaded view
|

Re: inverting colors of athens(cairo)canvas

wernerk
Hi Peter,
at the morphic level you might eventually look at ColorMappingCanvas and
make a subclass.
werner


Reply | Threaded
Open this post in threaded view
|

Re: inverting colors of athens(cairo)canvas

Nicolai Hess


2015-05-01 17:50 GMT+02:00 Werner Kassens <[hidden email]>:
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.



 

Reply | Threaded
Open this post in threaded view
|

Re: inverting colors of athens(cairo)canvas

Peter Uhnak
Thanks Nicolai!

I should've tried all the paint modes before asking. -_-

Peter

On Fri, May 1, 2015 at 8:32 PM, Nicolai Hess <[hidden email]> wrote:


2015-05-01 17:50 GMT+02:00 Werner Kassens <[hidden email]>:
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.