Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make line width equal to point's stroke width #798

Merged
merged 9 commits into from
Jun 28, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object AesScaling {

fun lineWidth(p: DataPointAesthetics): Double {
// aes Units -> px
return p.linewidth()!! * 2.0
return p.linewidth()!! * UNIT_SHAPE_SIZE / 2.0
}

fun circleDiameter(p: DataPointAesthetics): Double {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ open class AestheticsDefaults(geomTheme: GeomTheme) {
put(Aes.ALPHA, geomTheme.alpha())
put(Aes.SIZE, geomTheme.size())
put(Aes.LINEWIDTH, geomTheme.lineWidth())
put(Aes.STROKE, geomTheme.lineWidth())
}
private val myDefaultsInLegend = TypedKeyHashMap()

Expand Down Expand Up @@ -96,7 +97,6 @@ open class AestheticsDefaults(geomTheme: GeomTheme) {
private fun lollipop(geomTheme: GeomTheme): AestheticsDefaults {
return point(geomTheme)
.update(Aes.SHAPE, NamedShape.STICK_CIRCLE)
.update(Aes.STROKE, 1.0)
}

private fun base(geomTheme: GeomTheme): AestheticsDefaults {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,11 @@ object AestheticsUtil {
// else, override with color's alpha
}

fun strokeWidth(p: DataPointAesthetics): Double {
// aes Units -> px
return p.size()!! * 2.0
}
fun strokeWidth(p: DataPointAesthetics) = AesScaling.strokeWidth(p)

fun pointStrokeWidth(p: DataPointAesthetics): Double {
// aes Units -> px
return p.stroke()!! * AesScaling.UNIT_SHAPE_SIZE / 2.0
}
//
// fun circleDiameter(p: DataPointAesthetics): Double {
// // aes Units -> px
// return p.size()!! * 2.2
// }
//
// fun circleDiameterSmaller(p: DataPointAesthetics): Double {
// // aes Units -> px
// return p.size()!! * 1.5
// }
//
// fun sizeFromCircleDiameter(diameter: Double): Double {
// // px -> aes Units
// return diameter / 2.2
// }
//
fun textSize(p: DataPointAesthetics): Double {
// aes Units -> px
return p.size()!! * 2
}
fun pointStrokeWidth(p: DataPointAesthetics) = AesScaling.pointStrokeWidth(p)
alshan marked this conversation as resolved.
Show resolved Hide resolved

fun textSize(p: DataPointAesthetics) = AesScaling.textSize(p)

fun updateStroke(shape: SvgShape, p: DataPointAesthetics, applyAlpha: Boolean) {
shape.strokeColor().set(p.color())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal class DefaultGeomTheme private constructor(
var fill = BASE.fill
alshan marked this conversation as resolved.
Show resolved Hide resolved
var alpha = BASE.alpha
var size = BASE.size
val lineWidth = BASE.lineWidth
var lineWidth = BASE.lineWidth

when (geomKind) {
GeomKind.PATH,
Expand Down Expand Up @@ -108,19 +108,26 @@ internal class DefaultGeomTheme private constructor(
size = 0.2
}

GeomKind.POINT,
GeomKind.JITTER,
GeomKind.Q_Q,
GeomKind.Q_Q_2 -> {
color = inheritedColors.lineColor()
fill = Colors.withOpacity(inheritedColors.lineColor(), 0.1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to use colors with opacity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to fill = background color

size = 2.0
}

GeomKind.POINT_RANGE -> {
color = inheritedColors.lineColor()
fill = Colors.withOpacity(inheritedColors.lineColor(), 0.1)
lineWidth = 1.0 // line width and stroke for point
}

GeomKind.POINT,
GeomKind.JITTER,
GeomKind.Q_Q,
GeomKind.Q_Q_2,
GeomKind.LOLLIPOP -> {
color = inheritedColors.lineColor()
fill = Colors.withOpacity(inheritedColors.lineColor(), 0.1)
size = 2.0
lineWidth = 1.0 // line width and stroke for point
}

GeomKind.SMOOTH -> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bad: alpha = 1.5


                GeomKind.SMOOTH -> {
                    color = Color.MAGENTA

We don't want to use constant values no longer. Should be a field in BASE (but still get rid of the BASE).

Expand Down