do the following:

grab your polaroid camera (I'm old school). go outside. find a sundial. take a picture. note the direction/appearance of the "real" shadow. turn the photograph upside down.*

shadows belong to the layer, so if you rotate the layer, you also rotate the shadow - you do not change the position of the light source. The shape of your drawing in the layer is not relevant!

If you want the shadow to simulate your light source staying in the same place, then animate the shadow offset at the same time as you rotate the layer.

something like this might work:

        targetLayer.shadowOffset = normalOffset;
        targetLayer.affineTransform = normalAffineTransform;
        ...
        [CATransaction begin];

                targetLayer.shadowOffset = newOffsetBy180Degrees;
                targetLayer.affineTransform = 
newAffineTransformRotatedBy180Degrees;

        [CATransactioncommit];

Note:  typed in e-mail... ymmv

regards,

douglas

*sell camera on ebay for $20. sell upside-down polaroid at Christie's for millions and retire ;^}

                        
On Oct 25, 2008, at 9:31 AM, DKJ wrote:

I do this with a CAAnimation layer myLayer:

        myLayer.shadowOffset = CGSizeMake( 5.0, 5.0 );

and get a shadow on the upper and right edges. But when I rotate the layer 180 degrees, the shadow then appears on the lower and left edges. Real shadows don't do that.

If the object were circular, I'd just put another stationary layer underneath and attach the shadow to it. But with other shapes this won't work.

So finally, my question: Is there an easy way of calculating the position and appearance of the shadow for non-circular shapes? (By "easy" I mean one that I can just copy from somewhere.) If not I'll try to figure it out myself; but I don't want to re-invent the wheel.

dkj



On 24 Oct, 2008, at 18:11, douglas welton wrote:

On Oct 24, 2008, at 6:50 PM, DKJ wrote:

Is there an easy way to provide a realistic shadow for a (non- circular) layer rotating round the z-axis? (I know layer.rotateShadow = YES is too much to hope for.)

To get a "realistic" answer, it might help if you provide a little more specific information about 1) what you are trying to do, 2) what is not working and 3) what you have tried. (consult: <http://www.catb.org/~esr/faqs/smart-questions.html >)

regards,

douglas



============================
Hatzic Intellectual Software
Victoria BC, Canada
www.hatzicware.com


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to