Mantis - Squeak
Viewing Issue Advanced Details
4481 Morphic minor always 08-11-06 10:11 08-11-06 10:15
wiz  
 
normal  
new 3.9  
open  
none    
none  
0004481: When polygons, bitmapfills and rounded corners do not mix.
Demonstrating this one took some doing in a workspace
evaluate:rect := (RectangleMorph new cornerStyle: #rounded) openCenteredInWorld .

(poly := PolygonMorph vertices: rect bounds corners
                color: Color orange
                borderWidth: 0
                borderColor: Color black)
                fillStyle:( (BitmapFillStyle fromForm: rect imageForm) origin: rect position) ;
                openInWorld ;
                position: poly position + 50 asPoint .
                
rect := (RectangleMorph new cornerStyle: #squared) openCenteredInWorld color: Color cyan .

(poly := PolygonMorph vertices: rect bounds corners
                color: Color orange
                borderWidth: 0
                borderColor: Color black)
                fillStyle:( (BitmapFillStyle fromForm: rect imageForm) origin: rect position) ;
                openInWorld ;
                position: poly position + 50 asPoint .


Try picking up the morphs from their center. Three of them will lift.

The one that won't pay any attention to the hand is the polygon with the fill of the rounded rectangle.
Polygons will not contain points when they are transparent.
Bitmapfills answer asColor with the color at the topLeft pixel.
The image form of a morph with rounded corners has...

... (yes you guessed it) a transparent pixel at its top left corner.

You can pick up the polygon by lifting at the edges. You can even pick it up by moving the corner over the invisible transparent pixels in its rounded corners. You can not pick it up from the middle . indeed you can not interact with it in the middle.


There seems to me to be more than one bug or sad implementation here.

The largest bug belongs to polygon contains point. And I think it must bear the responsibility of finding a better way to do its job.

There is a sad implementation in BitMapFillStyle asColor. Since samplng a corner will in general not be representative of the color.
Better might be to sample the center of its form. Or just use the forms dominant color. This will give a better guess.

I have uploaded the BitmapFillStyle>>asColor method changed to use the forms dominant color. This actually solved the problem in the application I was trying to make work..

Yours in service, --Jerome Peace

 BitmapFillStyle.wiz.1.cs [^] (214 bytes) 08-11-06 10:11
 IntegrationBug.text [^] (714 bytes) 08-11-06 10:12

Notes
(0006488)
wiz   
08-11-06 10:15   
IntegrationBug.text is a copy of the problem description doit saved from the workspace I used for testing.
Yours in Service, -- Jerome Peace