Skip to content

Commit

Permalink
feat: add anti-aliasing for outer corner arcs
Browse files Browse the repository at this point in the history
  • Loading branch information
atennert committed Apr 12, 2021
1 parent 7b40e14 commit 5964c95
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ class RootWindowDrawer(
private val fontProvider: FontProvider
) : UIDrawing {
private val barEndOpacities = getOuterArcOpacities(BAR_HEIGHT / 2)
private val bigOuterCornerOpacities = getOuterArcOpacities(OUTER_CORNER_RADIUS_BIG)
private val smallOuterCornerOpacities = getOuterArcOpacities(OUTER_CORNER_RADIUS_SMALL)

private val barEndLeftColors = getArcAntialiasing(COLOR_BAR_ENDS, barEndOpacities, BAR_HEIGHT / 2, 2, 3)
private val barEndRightColors = getArcAntialiasing(COLOR_BAR_ENDS, barEndOpacities, BAR_HEIGHT / 2, 1, 4)
private val corner1OuterColors = getArcAntialiasing(COLOR_NORMAL_CORNER_1, bigOuterCornerOpacities, OUTER_CORNER_RADIUS_BIG, 2)
private val corner4OuterColors = getArcAntialiasing(COLOR_NORMAL_CORNER_4, bigOuterCornerOpacities, OUTER_CORNER_RADIUS_BIG, 3)
private val corner2OuterColors = getArcAntialiasing(COLOR_NORMAL_CORNER_2, smallOuterCornerOpacities, OUTER_CORNER_RADIUS_SMALL, 3)
private val corner3OuterColors = getArcAntialiasing(COLOR_NORMAL_CORNER_3, smallOuterCornerOpacities, OUTER_CORNER_RADIUS_SMALL, 2)

private fun getArcAntialiasing(
baseColor: Color,
Expand Down Expand Up @@ -486,8 +492,32 @@ class RootWindowDrawer(
for ((x, y, color) in barEndRightColors) {
val gc = getGC(color)
drawApi.drawPoint(pixmap, gc, monitor.x + monitor.width - 40 + x, monitor.y + y)
drawApi.drawPoint(pixmap, gc, monitor.x + monitor.width - 40 + x, monitor.y + monitor.height - BAR_HEIGHT + y)
drawApi.drawPoint(pixmap, gc, monitor.x + monitor.width - 40 + x, monitor.y + BAR_HEIGHT + 2 * INNER_CORNER_RADIUS + 2 * BAR_GAP_SIZE + DATA_BAR_HEIGHT + y)
drawApi.drawPoint(pixmap, gc, monitor.x + monitor.width - 40 + x, monitor.y + monitor.height - BAR_HEIGHT + y)
}

// corner 1 outer anti-aliasing
for ((x, y, color) in corner1OuterColors) {
val gc = getGC(color)
drawApi.drawPoint(pixmap, gc, monitor.x + x, monitor.y + y)
}

// corner 2 outer anti-aliasing
for ((x, y, color) in corner2OuterColors) {
val gc = getGC(color)
drawApi.drawPoint(pixmap, gc, monitor.x + x, monitor.y + BAR_HEIGHT + INNER_CORNER_RADIUS + 2 * BAR_GAP_SIZE + DATA_BAR_HEIGHT + y)
}

// corner 3 outer anti-aliasing
for ((x, y, color) in corner3OuterColors) {
val gc = getGC(color)
drawApi.drawPoint(pixmap, gc, monitor.x + x, monitor.y + BAR_HEIGHT + 2 * INNER_CORNER_RADIUS + 3 * BAR_GAP_SIZE + DATA_BAR_HEIGHT + BAR_HEIGHT_SMALL + y)
}

// corner 4 outer anti-aliasing
for ((x, y, color) in corner4OuterColors) {
val gc = getGC(color)
drawApi.drawPoint(pixmap, gc, monitor.x + x, monitor.y + monitor.height - OUTER_CORNER_RADIUS_BIG * 2 + y)
}

if (logoImage != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/nativeTest/kotlin/ShutdownTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ class ShutdownTest {

private fun checkFreeingOfGraphicsContexts(functionCalls: MutableList<FunctionCall>) {
println("gcs: ${functionCalls.sumOf { (if (it.name == "freeGC") 1 else 0) as Int }}")
repeat(20) {
repeat(54) {
assertEquals(
"freeGC",
functionCalls.removeAt(0).name,
Expand Down

1 comment on commit 5964c95

@atennert
Copy link
Member Author

Choose a reason for hiding this comment

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

prepares for #8

Please sign in to comment.