[Snippets/statShape] Handle empty shapes
This commit is contained in:
parent
1500e35b1c
commit
d5a08b3b96
@ -57,30 +57,31 @@ with cairo.SVGSurface("example.svg", hhea.advanceWidthMax, hhea.ascent-hhea.desc
|
||||
|
||||
ellipse_area = math.sqrt(lambda1) * math.sqrt(lambda2) * math.pi/4 * mult * mult
|
||||
|
||||
context.save()
|
||||
context.set_line_cap(cairo.LINE_CAP_ROUND)
|
||||
context.transform(transform)
|
||||
context.move_to(0, 0)
|
||||
context.line_to(0, 0)
|
||||
context.set_line_width(1)
|
||||
context.set_source_rgba(1, 0, 0, abs(stats.area / ellipse_area))
|
||||
context.stroke()
|
||||
context.restore()
|
||||
if stats.area:
|
||||
context.save()
|
||||
context.set_line_cap(cairo.LINE_CAP_ROUND)
|
||||
context.transform(transform)
|
||||
context.move_to(0, 0)
|
||||
context.line_to(0, 0)
|
||||
context.set_line_width(1)
|
||||
context.set_source_rgba(1, 0, 0, abs(stats.area / ellipse_area))
|
||||
context.stroke()
|
||||
context.restore()
|
||||
|
||||
context.save()
|
||||
context.set_line_cap(cairo.LINE_CAP_ROUND)
|
||||
context.set_source_rgb(.8, 0, 0)
|
||||
context.translate(stats.meanX, stats.meanY)
|
||||
context.save()
|
||||
context.set_line_cap(cairo.LINE_CAP_ROUND)
|
||||
context.set_source_rgb(.8, 0, 0)
|
||||
context.translate(stats.meanX, stats.meanY)
|
||||
|
||||
context.move_to(0, 0)
|
||||
context.line_to(0, 0)
|
||||
context.set_line_width(15)
|
||||
context.stroke()
|
||||
context.move_to(0, 0)
|
||||
context.line_to(0, 0)
|
||||
context.set_line_width(15)
|
||||
context.stroke()
|
||||
|
||||
context.transform(cairo.Matrix(1, 0, stats.slant, 1, 0, 0))
|
||||
context.move_to(0, -stats.meanY + font['hhea'].ascent)
|
||||
context.line_to(0, -stats.meanY + font['hhea'].descent)
|
||||
context.set_line_width(5)
|
||||
context.stroke()
|
||||
context.transform(cairo.Matrix(1, 0, stats.slant, 1, 0, 0))
|
||||
context.move_to(0, -stats.meanY + font['hhea'].ascent)
|
||||
context.line_to(0, -stats.meanY + font['hhea'].descent)
|
||||
context.set_line_width(5)
|
||||
context.stroke()
|
||||
|
||||
context.restore()
|
||||
context.restore()
|
||||
|
Loading…
x
Reference in New Issue
Block a user