• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Rotation in CAAnimation layers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rotation in CAAnimation layers


  • Subject: Re: Rotation in CAAnimation layers
  • From: douglas welton <email@hidden>
  • Date: Sat, 25 Oct 2008 13:45:58 -0400

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 (email@hidden)

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:
This email sent to email@hidden


References: 
 >Rotation in CAAnimation layers (From: DKJ <email@hidden>)
 >Re: Rotation in CAAnimation layers (From: douglas welton <email@hidden>)
 >Re: Rotation in CAAnimation layers (From: DKJ <email@hidden>)

  • Prev by Date: Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)
  • Next by Date: How to exit a thread help...
  • Previous by thread: Re: Rotation in CAAnimation layers
  • Next by thread: Can someone point me a Core Animation layer compositing example?
  • Index(es):
    • Date
    • Thread