<!--
{
  "availability" : [
    "macOS: 10.6.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSImage/draw(in:from:operation:fraction:respectFlipped:hints:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSImage(im)drawInRect:fromRect:operation:fraction:respectFlipped:hints:"
  },
  "title" : "draw(in:from:operation:fraction:respectFlipped:hints:)"
}
-->

# draw(in:from:operation:fraction:respectFlipped:hints:)

Draws all or part of the image in the specified rectangle respecting the hints and the orientation of the current coordinate system.

```
func draw(in dstSpacePortionRect: NSRect, from srcSpacePortionRect: NSRect, operation op: NSCompositingOperation, fraction requestedAlpha: CGFloat, respectFlipped respectContextIsFlipped: Bool, hints: [NSImageRep.HintKey : Any]?)
```

## Parameters

`dstSpacePortionRect`

The rectangle in which to draw the image, specified in the current coordinate system.

`srcSpacePortionRect`

The source rectangle specifying the portion of the image you want to draw. The coordinates of this rectangle must be specified using the image’s own coordinate system. If you pass in `NSZeroRect`, the entire image is drawn.

`op`

The compositing operation to use when drawing the image. See the [`NSCompositingOperation`](/documentation/AppKit/NSCompositingOperation) constants.

`requestedAlpha`

The alpha of the image, specified as a value from 0.0 to 1.0. Specifying a value of 0.0 draws the image as fully transparent while a value of 1.0 draws the image as fully opaque. Values greater than 1.0 are interpreted as 1.0.

`respectContextIsFlipped`

<doc://com.apple.documentation/documentation/Swift/true> if the drawing should respect the context flipped state, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

`hints`

An optional dictionary of hints that provide more context for selecting or generating the image. See `Image Hint Dictionary Keys` for a summary of the possible key-value pairs.

## Discussion

If the `srcSpacePortionRect` and `dstSpacePortionRect` rectangles have different sizes, the source portion of the image is scaled to fit the specified destination rectangle.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)