Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
commonMain.org.openrndr.internal.QualityLineDrawer.kt Maven / Gradle / Ivy
package org.openrndr.internal
import org.openrndr.draw.DrawContext
import org.openrndr.draw.DrawStyle
import org.openrndr.math.Vector2
class QualityLineDrawer {
private val expansionDrawer = ExpansionDrawer()
fun drawLineStrips(drawContext: DrawContext,
drawStyle: DrawStyle,
strips: List>,
corners: List>,
fringeWidth: Double) {
val fw = if (drawStyle.smooth) fringeWidth else 0.0
if (drawStyle.stroke != null && drawStyle.strokeWeight > 0.0) {
val expansions = strips.mapIndexed { index, it ->
val path = Path.fromLineStrip(it, corners[index], false)
path.expandStroke(
fw,
drawStyle.strokeWeight / 2.0,
drawStyle.lineCap,
drawStyle.lineJoin,
drawStyle.miterLimit
)
}
expansionDrawer.renderStrokes(drawContext, drawStyle, expansions, fw)
}
}
fun drawLineStrips(drawContext: DrawContext,
drawStyle: DrawStyle,
strips: List>,
corners: List>,
weights: List,
fringeWidth: Double) {
val fw = if (drawStyle.smooth) fringeWidth else 0.0
if (drawStyle.stroke != null && drawStyle.strokeWeight > 0.0) {
val expansions = strips.mapIndexed { index, it ->
val path = Path.fromLineStrip(it, corners[index], false)
path.expandStroke(fw, weights[index] / 2.0, drawStyle.lineCap, drawStyle.lineJoin, drawStyle.miterLimit)
}
expansionDrawer.renderStrokes(drawContext, drawStyle, expansions, fw)
}
}
fun drawLineLoops(drawContext: DrawContext,
drawStyle: DrawStyle,
strips: List>,
corners: List>,
fringeWidth: Double = 1.0) {
val effectiveFringeWidth = if (drawStyle.smooth) fringeWidth else 0.0
if (drawStyle.stroke != null && drawStyle.strokeWeight > 0) {
val expansions = strips.mapIndexed { index, it ->
val path = Path.fromLineStrip(it, corners[index], true)
path.expandStroke(
effectiveFringeWidth,
drawStyle.strokeWeight / 2.0,
drawStyle.lineCap,
drawStyle.lineJoin,
drawStyle.miterLimit
)
}
expansionDrawer.renderStrokes(drawContext, drawStyle, expansions, effectiveFringeWidth)
}
}
fun drawLineLoops(drawContext: DrawContext,
drawStyle: DrawStyle,
strips: List>,
corners: List>,
weights: List, fringeWidth: Double = 1.0) {
val fw = if (drawStyle.smooth) fringeWidth else 0.0
if (drawStyle.stroke != null && drawStyle.strokeWeight > 0.0) {
val expansions = strips.mapIndexed { index, it ->
val path = Path.fromLineStrip(it, corners[index], true)
path.expandStroke(fw, weights[index] / 2.0, drawStyle.lineCap, drawStyle.lineJoin, drawStyle.miterLimit)
}
expansionDrawer.renderStrokes(drawContext, drawStyle, expansions, fw)
}
}
}