Origin Translation and Rotation

script ClockAppDelegate
	property parent : class "NSObject"
	
	property varwinhour : missing value
	
	on subrotate_(sender)
		varwinhour's setFrameRotation_((varwinhour's frameRotation()) + 90)
	end subrotate_
	
	on applicationWillFinishLaunching_(aNotification)
		varwinhour's translateOriginToPoint_({x:15, y:15})
		-- Insert code here to initialize your application before any files are opened 
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits 
		return current application's NSTerminateNow
	end applicationShouldTerminate_
	
end script

I rotating my image alone rotates it around its origin as it says in the docs but that doesn’t look like a clock hand moves, I remembered reading about an origin translation method so I put it in as you can see but nothing changed, no errors.

You’re probably going to have to do the sums and move it yourself each time.

:frowning: this will be pi and a lot of trigonometry, oh well.

You have to remember that you’re operating at a much lower level than, say, a scriptable drawing program.

You may get some ideas if you study my example ASOC app located here:

http://www.theaford.co.uk/Site/ApplescriptObjC_files/ASOCImageViewer.zip

in additon you should study very carefully this section of Apple’s documentation:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaViewsGuide/Introduction/Introduction.html

All the best

Terry

I’m not reading that code! :lol: The docs were interesting but didn’t really help.

If you do not learn how to use NSAffineTransform then you will end up doing a lot of mathematics.

I have been there and done it when trying to rotate images.

Rotating the frame may not be the answer as it is not as efficient as drawing with coordinate system rotated.

Good Luck with the math.

–Terry

Hi,

I cannot be sure what you are working on but it seems to be some sort of clock.

There is an example here (in Cocoa) that may interest you.

http://homepage.mac.com/mmalc/CocoaExamples/ClockControl2a.zip

Good Luck

–Terry