Skip to content

Commit 1609f15

Browse files
committed
Thicker hatching
1 parent 73a3c78 commit 1609f15

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

  • chartLib/src/main/kotlin/info/appdev/charting/charts

chartLib/src/main/kotlin/info/appdev/charting/charts/GanttChart.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class GanttChart : View {
4343
isAntiAlias = true
4444
}
4545
hatchPaint = Paint().apply {
46-
color = 0x7DFFFFFF // more transparent (0x7D ≈ 66 % opacity vs previous 0x55 ≈ 33 %)
47-
strokeWidth = 20f // thicker lines (was 2f)
46+
color = 0xAAFFFFFF.toInt() // ~67 % opaque white – clearly visible over any bar colour
4847
isAntiAlias = true
4948
style = Paint.Style.STROKE
49+
// strokeWidth is set dynamically in drawTasks to stay proportional to bar height
5050
}
5151
gridPaint = Paint().apply {
5252
color = -0x333334
@@ -189,9 +189,16 @@ class GanttChart : View {
189189
canvas.drawRect(rect, taskPaint!!)
190190

191191
if (task.hatched) {
192+
// Scale both stroke width and spacing to the bar height so the
193+
// pattern is always clearly visible regardless of how many tasks
194+
// are shown. Rule: spacing must be > strokeWidth or lines overlap.
195+
// strokeWidth ≈ 20 % of bar height
196+
// hatchSpacing ≈ 40 % of bar height (2× the stroke → clear gap)
197+
hatchPaint!!.strokeWidth = taskHeight * 0.20f
198+
val hatchSpacing = taskHeight * 0.40f
199+
192200
// Hatch lines (45° diagonal, bottom-left → top-right)
193201
canvas.withClip(rect) {
194-
val hatchSpacing = 10f
195202
var hx = startX - taskHeight
196203
while (hx < endX + taskHeight) {
197204
drawLine(hx, taskY + taskHeight, hx + taskHeight, taskY, hatchPaint!!)

0 commit comments

Comments
 (0)