View
The Application's view object. The view displays the active document's canvas, and can be used to move or zoom the visible canvas area.
Positioning
Zooming
Drawing
centerPoint
returns CGPoint; settable
Get / Set the center point of the visible canvas area.
Example: center the view on the selected objects
var view = [app view]
var selection = [[app activeDocument] selection]
if([[selection shapes] count] > 0)
{
var bounds = [selection bounds]
view.centerPoint = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds))
}
redraw
Refreshes the entire canvas area.
resetZoom
Resets the zoom level to 100% and re-centers the canvas.
Example: set the current document's canvas size and center the view
[app activeDocument].canvasSize = CGSizeMake(640, 480)
[[app view] resetZoom]
visibleBounds
returns CGRect
Get the bounds of the visible canvas area. Although this property cannot be set, since it is dependent on the user's set window size, the visible area of the canvas can be adjusted using the centerPoint property.
Example: display an alert showing the currently visible bounds of the canvas
var view = [app view]
var bounds = [view visibleBounds]
[app showAlert:NSStringFromCGRect(bounds)]
zoom
returns Float; settable
Get / Set the current zoom level. Values are in percentages, where 100 is equal to 100% zoom.
Min = 10, Max = 6400.
Example: set the current zoom level to 10%
var view = [app view]
view.zoom = 10
