# GH_Viewport class

Namespace: [Grasshopper.GUI.Canvas](https://developer.rhino3d.com/api/gh1/namespace/grasshopper.gui.canvas.md) · Assembly: [Grasshopper](https://developer.rhino3d.com/api/gh1/assembly/grasshopper.md)

```cs
public sealed class GH_Viewport
```

Provides functionality for panning and zooming in a GH_Canvas environment.

## Constructors

- [GH_Viewport](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/ctor.md): (4 overloads)

## Fields

- [ZoomDefault](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/zoomdefault.md): (static)
- [ZoomDefaultLower](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/zoomdefaultlower.md): (static)
- [ZoomDefaultUpper](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/zoomdefaultupper.md): (static)
- [ZoomMaximum](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/zoommaximum.md): (static)
- [ZoomMinimum](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/zoomminimum.md): (static)

## Properties

- [ControlMidPoint](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/controlmidpoint.md): Gets the point in the exact center of the viewport in control coordinates.
- [Diagonal](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/diagonal.md): Gets the length of the diagonal of the viewport in canvas coordinates.
- [Height](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/height.md): Gets or sets the height of the viewport. Typically this is tied to the dimensions of the canvas. Height is not allowed to go below 5 pixels.
- [MidPoint](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/midpoint.md): Gets or sets the canvas coordinate that is directly underneath the center of the viewport.
- [ScreenPort](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/screenport.md): Gets the dimensions of the viewport in control coordinates.
- [Size](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/size.md): Gets or sets the size of the viewport. The size is typically tied to the dimensions of the Canvas.
- [Target](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/target.md): Gets or sets the location of the target pixel. The target represents where the canvas origin is drawn.
- [TargetRatio](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/targetratio.md): Gets or sets the target ratio with respect to the viewport dimensions. This is a useful tool to prevent weird view changes during a canvas resize.
- [Tx](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/tx.md): Gets or sets the x-component of the target pixel. The target represents where the canvas origin is drawn.
- [Ty](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/ty.md): Gets or sets the y-component of the target pixel. The target represents where the canvas origin is drawn.
- [VisibleRegion](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/visibleregion.md): Gets the rectangle in canvas coordinates that is visible in the control.
- [Width](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/width.md): Gets or sets the width of the viewport. Typically this is tied to the dimensions of the canvas. Width is not allowed to go below 5 pixels.
- [Zoom](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/zoom.md): (2 overloads) Gets or sets the Zoom factor of the viewport. Please assign only sensible values.
- [ZoomInverse](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/zoominverse.md): Gets the inverse of the zoom.

## Methods

- [ApplyProjection](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/applyprojection.md): Apply the current display transformation to a Graphics object.
- [ComputeProjection](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/computeprojection.md): Forces a recomputation of all cached data.
- [DollyZoom](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/dollyzoom.md): Advanced interface function for mouse 'dolly' zooming.
- [Duplicate](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/duplicate.md)
- [Focus](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/focus.md): (4 overloads) Look at a specific object.
- [IsVisible](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/isvisible.md): (2 overloads) Test visibility of a point.
- [LimitUnit](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/limitunit.md): Utility function for calculating pixel dimensions in a zoom-aware environment. The desired value is put through the zoom projection and if the resulting size (as displayed on the screen) exceeds the visual limits it is clipped. This function can be used for example to make sure that a certain penwidth never exceeds visual limits (i.e. it doesn't get too thin or too thick on the screen).
- [Project](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/project.md): Transform a point from canvas into control coordinate space.
- [ProjectPoint](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/projectpoint.md): Project a point from canvas coordinates into control coordinates.
- [ProjectRectangle](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/projectrectangle.md): Project a rectangle from canvas coordinates into control coordinates.
- [ProjectX](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/projectx.md): Project a value along constant X from canvas coordinates into control coordinates.
- [ProjectY](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/projecty.md): Project a value along constant Y from canvas coordinates into control coordinates.
- [Set](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/set.md)
- [SolveUnit](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/solveunit.md): Utility function for calculating graphics dimensions in a zoom-aware environment. This function can be used for example to compute the linewidth of a pen which always needs to appear as 3 pixels thick on the screen regardless of zoom values.
- [Unproject](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/unproject.md): Transform a point from control into canvas coordinate space.
- [UnprojectPoint](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/unprojectpoint.md): Project a point from control coordinates into canvas coordinates.
- [UnprojectRectangle](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/unprojectrectangle.md): Project a rectangle from control coordinates into canvas coordinates.
- [UnprojectX](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/unprojectx.md): Project a value along constant X from control coordinates into canvas coordinates.
- [UnprojectY](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/unprojecty.md): Project a value along constant Y from control coordinates into canvas coordinates.
- [XFormMatrix](https://developer.rhino3d.com/api/gh1/type/grasshopper.gui.canvas.gh-viewport/xformmatrix.md): Gets the display transformation cached by this viewport.
