[orx-shapes] Add linear operator and contour conversion to bezierpatch
This commit is contained in:
@@ -138,8 +138,26 @@ class BezierPatch(val points: List<List<Vector2>>) {
|
||||
|
||||
return bezierPatch(d0, d1, d2, d3).transposed
|
||||
}
|
||||
|
||||
val contour: ShapeContour = ShapeContour(
|
||||
listOf(
|
||||
Segment(points[0][0], points[0][1], points[0][2], points[0][3]),
|
||||
Segment(points[0][3], points[1][3], points[2][3], points[3][3]),
|
||||
Segment(points[3][3], points[3][2], points[3][1], points[3][0]),
|
||||
Segment(points[3][0], points[2][0], points[1][0], points[0][0]),
|
||||
), true)
|
||||
|
||||
operator fun times(scale: Double) = BezierPatch(points.map { j -> j.map { i -> i * scale } })
|
||||
operator fun div(scale: Double) = BezierPatch(points.map { j -> j.map { i -> i / scale } })
|
||||
operator fun plus(right: BezierPatch) =
|
||||
BezierPatch(List(4) { j -> List(4) { i -> points[j][i] + right.points[j][i] } })
|
||||
|
||||
operator fun minus(right: BezierPatch) =
|
||||
BezierPatch(List(4) { j -> List(4) { i -> points[j][i] - right.points[j][i] } })
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a cubic bezier patch from 4 segments. The control points of the segments are used in row-wise fashion
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user