Skip to content

Commit

Permalink
Avoid perfect lines to ensure they render correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed May 29, 2022
1 parent 7777b24 commit 9258cb8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions indigo/indigo/src/main/scala/indigo/shared/scenegraph/Shape.scala
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,12 @@ object Shape:
}

case s: Shape.Line =>
// A terrible fix, but it works. In cases where we have a perfect aspect
// division, like 1.0 to 0.5, the resulting SDF is a jagged line. So by
// crudly adding a very small number, we avoid perfect divisions and get
// nice straight edges...
val avoidPerfection = 0.00001f

// Relative to bounds
val ss = s.start - bounds.position + (s.stroke.width / 2)
val ee = s.end - bounds.position + (s.stroke.width / 2)
Expand All @@ -745,10 +751,10 @@ object Shape:
s.stroke.color.g.toFloat,
s.stroke.color.b.toFloat,
s.stroke.color.a.toFloat,
ss.x.toFloat,
ss.y.toFloat,
ee.x.toFloat,
ee.y.toFloat
ss.x.toFloat + avoidPerfection,
ss.y.toFloat + avoidPerfection,
ee.x.toFloat + avoidPerfection,
ee.y.toFloat + avoidPerfection
)
)
)
Expand Down

0 comments on commit 9258cb8

Please sign in to comment.