[Cuis-dev] #isCloserThan:toPoint: on circle

Juan Vuletich juan at jvuletich.org
Tue Aug 17 12:49:28 PDT 2021


On 8/15/2021 5:49 PM, Juan Vuletich via Cuis-dev wrote:
> Hi Hilaire,
>
> On 8/15/2021 7:14 AM, Hilaire Fernandes via Cuis-dev wrote:
>>
>> Hi Juan,
>>
>> I have noted that with a drawn circle[1], so not filled contrary to a 
>> disc, the detection method in subject respond true when the point is 
>> on any position *inside* the circle. It should be true only when the 
>> circle is filled (disc).
>>
>
> Well, we can detect with pixel precision only one morph, the visible 
> one. I think you had asked about detecting all the (possibly 
> overlapping) morphs that are at some point (or close to it). Adding a 
> stack of morphID at each pixel is extremely memory intensive. We could 
> easily need half a gigabyte of memory for a 4k display. Then I came up 
> with the contour idea, that only requires a maximum of 16 kBytes per 
> morph (i.e. most likely never more than a couple of megabytes). But 
> contours record, for each display y(i.e. for each line) the leftmost 
> and rightmost affected pixels. It is a kind of "convex hull".
>
> I don't know a general, all-morphs solution that doesn't require a ton 
> of RAM. If you can live with detecting only the top morph, then 
> #containsGlobalPoint: (or a new method that also takes into account a 
> distance), is a possible solution.
>
> If you absolutely need detecting all morphs, but not at "transparent" 
> inner points, and, it is only for instances of a few classes, like 
> line and circle, then implementing a specific method in those classes 
> is an alternative. It would be quite complicated if you also need, for 
> example, Beziers.
>
> I'm sorry I don't know a better solution.
>
>> Btw, when I insert an halt in the draw method, it freezes the image. 
>> You fixed this issue previously, may be it is a regression or 
>> something else.
>>
>
> Right now, #drawOn: is protected against Error, but not against Halt. 
> Just played a bit with an improvement. Will push it later.
>
>> Best
>>
>> Hilaire
>>
>> [1] Draw as:
>>
>> DrGCircleMorph>>drawCircleOn: aCanvas
>>     | center r |
>>     center _ self drawable worldToMorph: mathItem center.
>>     r _ self drawable worldToPixel: mathItem radius.
>>     style isFilled
>>         ifTrue: [
>>             aCanvas strokeWidth: style borderWidth color: borderColor 
>> fillColor: color do: [
>>                 aCanvas circleCenter: center radius: r]            ]
>>         ifFalse: [
>>             aCanvas strokeWidth: style borderWidth color: borderColor 
>> do: [
>>                 aCanvas circleCenter: center  radius: r] ]
>>
>> -- 
>> GNU Dr. Geo
>> http://drgeo.eu
>> http://blog.drgeo.eu
>
> Cheers,
> -- 
> Juan Vuletich
> www.cuis-smalltalk.org
> https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
> https://github.com/jvuletich
> https://www.linkedin.com/in/juan-vuletich-75611b3
> @JuanVuletich

Just pushed to GitHub a new approach to tackle this issue. Please check 
#shadow, senders, and all methods in M3Exp01Morph.

I added a #shadow method that answers a 1bpp form telling affected 
pixels, even if Morph not partially visible. As this is expensive, it is 
computed on demand and cached.

Cheers,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210817/73c06230/attachment.htm>


More information about the Cuis-dev mailing list