Add arc builders to scheme
This commit is contained in:
parent
409d749054
commit
354cd8c9a2
@ -5,6 +5,7 @@ import space.kscience.gradle.KScienceVersions.JVM_TARGET
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
id("org.jetbrains.compose")
|
id("org.jetbrains.compose")
|
||||||
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
@ -11,7 +11,14 @@ data class SchemeCoordinates(val x: Float, val y: Float)
|
|||||||
data class SchemeRectangle(
|
data class SchemeRectangle(
|
||||||
val a: SchemeCoordinates,
|
val a: SchemeCoordinates,
|
||||||
val b: SchemeCoordinates,
|
val b: SchemeCoordinates,
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
fun square(center: SchemeCoordinates, height: Float, width: Float): SchemeRectangle = SchemeRectangle(
|
||||||
|
SchemeCoordinates(center.x - width / 2, center.y - height / 2),
|
||||||
|
SchemeCoordinates(center.x + width / 2, center.y + height / 2),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val SchemeRectangle.top get() = max(a.y, b.y)
|
val SchemeRectangle.top get() = max(a.y, b.y)
|
||||||
val SchemeRectangle.bottom get() = min(a.y, b.y)
|
val SchemeRectangle.bottom get() = min(a.y, b.y)
|
||||||
|
@ -129,6 +129,37 @@ fun SchemeFeaturesState.line(
|
|||||||
id: FeatureId? = null,
|
id: FeatureId? = null,
|
||||||
) = addFeature(id, SchemeLineFeature(aCoordinates.toCoordinates(), bCoordinates.toCoordinates(), scaleRange, color))
|
) = addFeature(id, SchemeLineFeature(aCoordinates.toCoordinates(), bCoordinates.toCoordinates(), scaleRange, color))
|
||||||
|
|
||||||
|
public fun SchemeFeaturesState.arc(
|
||||||
|
oval: SchemeRectangle,
|
||||||
|
startAngle: Float,
|
||||||
|
arcLength: Float,
|
||||||
|
scaleRange: FloatRange = defaultScaleRange,
|
||||||
|
color: Color = Color.Red,
|
||||||
|
id: FeatureId? = null,
|
||||||
|
): FeatureId = addFeature(
|
||||||
|
id,
|
||||||
|
SchemeArcFeature(oval, startAngle, arcLength, scaleRange, color)
|
||||||
|
)
|
||||||
|
|
||||||
|
public fun SchemeFeaturesState.arc(
|
||||||
|
center: Pair<Double, Double>,
|
||||||
|
radius: Float,
|
||||||
|
startAngle: Float,
|
||||||
|
arcLength: Float,
|
||||||
|
scaleRange: FloatRange = defaultScaleRange,
|
||||||
|
color: Color = Color.Red,
|
||||||
|
id: FeatureId? = null,
|
||||||
|
): FeatureId = addFeature(
|
||||||
|
id,
|
||||||
|
SchemeArcFeature(
|
||||||
|
oval = SchemeRectangle.square(center.toCoordinates(), radius, radius),
|
||||||
|
startAngle = startAngle,
|
||||||
|
arcLength = arcLength,
|
||||||
|
scaleRange = scaleRange,
|
||||||
|
color = color
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
fun SchemeFeaturesState.text(
|
fun SchemeFeaturesState.text(
|
||||||
position: SchemeCoordinates,
|
position: SchemeCoordinates,
|
||||||
text: String,
|
text: String,
|
Loading…
Reference in New Issue
Block a user