# MetalRenderer

Artifact: [androidx.ink:ink-rendering](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/rendering/metal/MetalRenderer.ios.kt+class:androidx.ink.rendering.metal.MetalRenderer) Native/C/iOS
- N

  ```
  class MetalRenderer
  ```

*** ** * ** ***

Ink renderer for iOS, using Metal.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/rendering/metal/MetalRenderer#MetalRenderer(platform.Metal.MTLDeviceProtocol,kotlin.ULong,kotlin.ULong,kotlin.Int,androidx.ink.brush.TextureImageStore)( device: platform.Metal.MTLDeviceProtocol, colorPixelFormat: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-u-long/index.html, stencilPixelFormat: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-u-long/index.html, sampleCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html?, textureImageStore: https://developer.android.com/reference/kotlin/androidx/ink/brush/TextureImageStore? )` | N |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/rendering/metal/MetalRenderer#draw(platform.Metal.MTLRenderCommandEncoderProtocol,androidx.ink.strokes.InProgressStroke,kotlin.Double,kotlin.Double,androidx.ink.geometry.AffineTransform)( renderEncoder: platform.Metal.MTLRenderCommandEncoderProtocol, inProgressStroke: https://developer.android.com/reference/kotlin/androidx/ink/strokes/InProgressStroke, textureWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html, textureHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html, strokeToScreenTransform: https://developer.android.com/reference/kotlin/androidx/ink/geometry/AffineTransform )` Draws an in-progress stroke using the given render encoder. | N |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/rendering/metal/MetalRenderer#draw(platform.Metal.MTLRenderCommandEncoderProtocol,androidx.ink.strokes.Stroke,kotlin.Double,kotlin.Double,androidx.ink.geometry.AffineTransform)( renderEncoder: platform.Metal.MTLRenderCommandEncoderProtocol, stroke: https://developer.android.com/reference/kotlin/androidx/ink/strokes/Stroke, textureWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html, textureHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html, strokeToScreenTransform: https://developer.android.com/reference/kotlin/androidx/ink/geometry/AffineTransform )` Draws a completed stroke using the given render encoder. | N |

## Public constructors

### MetalRenderer

N

```
MetalRenderer(
    device: platform.Metal.MTLDeviceProtocol,
    colorPixelFormat: ULong,
    stencilPixelFormat: ULong,
    sampleCount: Int? = null,
    textureImageStore: TextureImageStore? = null
)
```

| Parameters |
|---|---|
| `device: platform.Metal.MTLDeviceProtocol` | `MTLDevice` to use for rendering. |
| `colorPixelFormat: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-u-long/index.html` | Format of the color texture being rendered. |
| `stencilPixelFormat: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-u-long/index.html` | Format of the stencil texture being rendered. If a stencil texture is not being used, this should be `MTLPixelFormatInvalid`. |
| `sampleCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html? = null` | The number of samples per pixel for MSAA. If unset or null, shader-based antialiasing will be used instead. |
| `textureImageStore: https://developer.android.com/reference/kotlin/androidx/ink/brush/TextureImageStore? = null` | An optional callback for retrieving texture images by ID. |

## Public functions

### draw

N

```
fun draw(
    renderEncoder: platform.Metal.MTLRenderCommandEncoderProtocol,
    inProgressStroke: InProgressStroke,
    textureWidth: Double,
    textureHeight: Double,
    strokeToScreenTransform: AffineTransform
): Unit
```

Draws an in-progress stroke using the given render encoder.

| Parameters |
|---|---|
| `renderEncoder: platform.Metal.MTLRenderCommandEncoderProtocol` | `MTLRenderCommandEncoder` to draw with. |
| `inProgressStroke: https://developer.android.com/reference/kotlin/androidx/ink/strokes/InProgressStroke` | The in-progress stroke to draw. |
| `textureWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | Width of the texture `https://developer.android.com/reference/kotlin/androidx/ink/rendering/metal/MetalRenderer#draw(platform.Metal.MTLRenderCommandEncoderProtocol,androidx.ink.strokes.InProgressStroke,kotlin.Double,kotlin.Double,androidx.ink.geometry.AffineTransform)` is drawing to, used to compute the projection transform. |
| `textureHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | Height of the texture `https://developer.android.com/reference/kotlin/androidx/ink/rendering/metal/MetalRenderer#draw(platform.Metal.MTLRenderCommandEncoderProtocol,androidx.ink.strokes.InProgressStroke,kotlin.Double,kotlin.Double,androidx.ink.geometry.AffineTransform)` is drawing to, used to compute the projection transform. |
| `strokeToScreenTransform: https://developer.android.com/reference/kotlin/androidx/ink/geometry/AffineTransform` | Affine transform from stroke coordinates to view coordinates. |

### draw

N

```
fun draw(
    renderEncoder: platform.Metal.MTLRenderCommandEncoderProtocol,
    stroke: Stroke,
    textureWidth: Double,
    textureHeight: Double,
    strokeToScreenTransform: AffineTransform
): Unit
```

Draws a completed stroke using the given render encoder.

| Parameters |
|---|---|
| `renderEncoder: platform.Metal.MTLRenderCommandEncoderProtocol` | `MTLRenderCommandEncoder` to draw with. |
| `stroke: https://developer.android.com/reference/kotlin/androidx/ink/strokes/Stroke` | The stroke to draw. |
| `textureWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | Width of the texture `https://developer.android.com/reference/kotlin/androidx/ink/rendering/metal/MetalRenderer#draw(platform.Metal.MTLRenderCommandEncoderProtocol,androidx.ink.strokes.Stroke,kotlin.Double,kotlin.Double,androidx.ink.geometry.AffineTransform)` is drawing to, used to compute the projection transform. |
| `textureHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | Height of the texture `https://developer.android.com/reference/kotlin/androidx/ink/rendering/metal/MetalRenderer#draw(platform.Metal.MTLRenderCommandEncoderProtocol,androidx.ink.strokes.Stroke,kotlin.Double,kotlin.Double,androidx.ink.geometry.AffineTransform)` is drawing to, used to compute the projection transform. |
| `strokeToScreenTransform: https://developer.android.com/reference/kotlin/androidx/ink/geometry/AffineTransform` | Affine transform from stroke coordinates to view coordinates. |