---
title: "drawOutline"
description: "Draws the [Outline] on a [DrawScope]."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun DrawScope.drawOutline(
    outline: Outline,
    color: Color,
    @FloatRange(from = 0.0, to = 1.0) alpha: Float = 1.0f,
    style: DrawStyle = Fill,
    colorFilter: ColorFilter? = null,
    blendMode: BlendMode = DrawScope.DefaultBlendMode,
) =
    drawOutlineHelper(
        outline,
        { rect ->
            drawRect(color, rect.topLeft(), rect.size(), alpha, style, colorFilter, blendMode)
        },
        { rrect ->
            val radius = rrect.bottomLeftCornerRadius.x
            drawRoundRect(
                color = color,
                topLeft = rrect.topLeft(),
                size = rrect.size(),
                cornerRadius = CornerRadius(radius),
                alpha = alpha,
                style = style,
                colorFilter = colorFilter,
                blendMode = blendMode,
            )
        },
        { path -> drawPath(path, color, alpha, style, colorFilter, blendMode) },
    )
```


Draws the `Outline` on a `DrawScope`.

#### Parameters

| | |
| --- | --- |
| outline | the outline to draw. |
| color | Color applied to the outline when it is drawn |
| alpha | Opacity to be applied to outline from 0.0f to 1.0f representing fully transparent to fully opaque respectively |
| style | Specifies whether the outline is stroked or filled in |
| colorFilter: | ColorFilter to apply to the `color` when drawn into the destination |
| blendMode: | Blending algorithm to be applied to the outline |




<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun DrawScope.drawOutline(
    outline: Outline,
    brush: Brush,
    @FloatRange(from = 0.0, to = 1.0) alpha: Float = 1.0f,
    style: DrawStyle = Fill,
    colorFilter: ColorFilter? = null,
    blendMode: BlendMode = DrawScope.DefaultBlendMode,
) =
    drawOutlineHelper(
        outline,
        { rect ->
            drawRect(brush, rect.topLeft(), rect.size(), alpha, style, colorFilter, blendMode)
        },
        { rrect ->
            val radius = rrect.bottomLeftCornerRadius.x
            drawRoundRect(
                brush = brush,
                topLeft = rrect.topLeft(),
                size = rrect.size(),
                cornerRadius = CornerRadius(radius),
                alpha = alpha,
                style = style,
                colorFilter = colorFilter,
                blendMode = blendMode,
            )
        },
        { path -> drawPath(path, brush, alpha, style, colorFilter, blendMode) },
    )
```


Draws the `Outline` on a `DrawScope`.

#### Parameters

| | |
| --- | --- |
| outline | the outline to draw. |
| brush | Brush applied to the outline when it is drawn |
| alpha | Opacity to be applied to outline from 0.0f to 1.0f representing fully transparent to fully opaque respectively |
| style | Specifies whether the outline is stroked or filled in |
| colorFilter: | ColorFilter to apply to the `Brush` when drawn into the destination |
| blendMode: | Blending algorithm to be applied to the outline |




<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun Canvas.drawOutline(outline: Outline, paint: Paint) =
    when (outline) {
        is Outline.Rectangle -> drawRect(outline.rect, paint)
        is Outline.Rounded -> {
            val path = outline.roundRectPath
            if (path != null) {
                drawPath(path, paint)
            } else {
                drawRoundRect(
                    left = outline.roundRect.left,
                    top = outline.roundRect.top,
                    right = outline.roundRect.right,
                    bottom = outline.roundRect.bottom,
                    radiusX = outline.roundRect.bottomLeftCornerRadius.x,
                    radiusY = outline.roundRect.bottomLeftCornerRadius.y,
                    paint = paint,
                )
            }
        }
        is Outline.Generic -> drawPath(outline.path, paint)
    }
```


Draws the `Outline` on a `Canvas`.

#### Parameters

| | |
| --- | --- |
| outline | the outline to draw. |
| paint | the paint used for the drawing. |




