1 /* 2 * Copyright 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.compose.ui.graphics 18 19 import androidx.compose.runtime.Immutable 20 21 /** Defines how a list of points is interpreted when drawing a set of points. */ 22 // ignore: deprecated_member_use 23 /** Used by [Canvas.drawPoints]. */ 24 // These enum values must be kept in sync with SkCanvas::PointMode. 25 @Immutable 26 @kotlin.jvm.JvmInline 27 value class PointMode internal constructor(@Suppress("unused") private val value: Int) { 28 companion object { 29 /** 30 * Draw each point separately. 31 * 32 * If the [Paint.strokeCap] is [StrokeCap.Round], then each point is drawn as a circle with 33 * the diameter of the [Paint.strokeWidth], filled as described by the [Paint] (ignoring 34 * [Paint.style]). 35 * 36 * Otherwise, each point is drawn as an axis-aligned square with sides of length 37 * [Paint.strokeWidth], filled as described by the [Paint] (ignoring [Paint.style]). 38 */ 39 val Points = PointMode(0) 40 41 /** 42 * Draw each sequence of two points as a line segment. 43 * 44 * If the number of points is odd, then the last point is ignored. 45 * 46 * The lines are stroked as described by the [Paint] (ignoring [Paint.style]). 47 */ 48 val Lines = PointMode(1) 49 50 /** 51 * Draw the entire sequence of point as one line. 52 * 53 * The lines are stroked as described by the [Paint] (ignoring [Paint.style]). 54 */ 55 val Polygon = PointMode(2) 56 } 57 toStringnull58 override fun toString() = 59 when (this) { 60 Points -> "Points" 61 Lines -> "Lines" 62 Polygon -> "Polygon" 63 else -> "Unknown" 64 } 65 } 66