[Drawkit] DKDrawableObject angle

Michael Caron michael.r.caron at gmail.com
Thu Apr 23 04:36:28 PDT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I see now. So the angle property of a DKArcPath is not the arc angle,  
rather the rotation angle with respect to the layer (in my case it  
seems). Thanks for taking time to explain, Graham.

Cheers,
Mike


On Apr 23, 2009, at 12:45 AM, Graham Cox wrote:

>
> On 23/04/2009, at 11:16 AM, Michael Caron wrote:
>
>> What is the meaning of the angle property of a DKDrawableObject? I  
>> see it being used when computing the bounds of the object. The  
>> inline comments say that it's the angle of the object with respect  
>> to the container. Is the container the same as the View? Does this  
>> property show if the object has been rotated or not? As in, if the  
>> object is not rotated, it's got an angle of 0 rad. But if it's  
>> rotated, then it's non-zero?
>
>
> The container of an object is the object that contains it.  
> Containers include layers and groups.
>
> The angle is the angle relative to its container. Layers can't be  
> rotated, so this is equivalent to the absolute angle relative to the  
> view. But groups can be rotated, so the angle is the angle within  
> the group. The absolute angle will be the group angle + the object  
> angle (though as groups can be nested you'd have to sum up all  
> possible container angles to arrive at an absolute value, if you  
> ever needed it).
>
> All drawable objects have an angle property, but many of them just  
> return 0. Mostly it's shapes and their derivatives that allow this  
> to readily vary. The property allows you to tell if the object has  
> been rotated relative to its container, but doesn't tell you if it  
> is aligned in the view (for example, an object could be in a group  
> such that the group's rotation and the object's rotation cancel out,  
> showing the object aligned exactly to the view, but the angle  
> property would be non-zero).
>
> The reason that the angle affects the bounds is because the bounds  
> is always container-aligned. Thus a rotated rectangle's bounds will  
> have a width and height that is different from the size reported by  
> the -size property, which is the true size of the object, regardless  
> of rotation (i.e. a side length x is always x even when rotated).
>
>> Maybe I'm missing something really basic here, but DKArcPath states  
>> in the inline comments for the angle method that:
>>
>> the overall angle is considered to be halfway between the start and  
>> end points around the arc
>>
>> I don't follow this, unless you're simply stating that this is so.  
>> Consider an arc with starting angle of 0 and ending angle of pi/2 .  
>> I would assume that the angle of the arc is pi/2, not pi/4. Or does  
>> this have something to do with the question that I asked earlier  
>> about the angle being something to do with rotation?
>>
>
> Because all drawables define an angle property, for an arc the angle  
> is defined to be halfway between the arc ends. You can see this when  
> rotating an arc - you get a highlight line at the halfway mark. I  
> forget precisely why I chose to do it that way now, but I recall  
> that it did simplify a bunch of stuff.
>
> --Graham
>
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net

Michael
- ------------------------------------------------
michael.r.caron at gmail.com
http://techrad.wordpress.com
http://mrcaron.wordpress.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iD8DBQFJ8FK85CEAr1NK/dQRAskmAJ45MvdFgLKwtmuqqPFJF3Ui+9CpSgCfampq
L3qghDLk7DOe5jLdtFySOhc=
=Tls1
-----END PGP SIGNATURE-----


More information about the Drawkit mailing list