Fix text offset calculation
This commit is contained in:
@@ -94,9 +94,9 @@ svgTextID idMaybe text { x: x, y: y } angle style dimension =
|
||||
XMLFragment $ "<text " <> idText <> " xml:space=\"preserve\" style=\"font-size:" <> (toString style.sizePx) <> "px;line-height:131%;font-family:'" <> style.typeface <> "';fill:#000000;stroke:#000000;stroke-width:0.0999998;stroke-linecap:round;stop-color:#000000;fill-opacity:1\" "
|
||||
<> "transform=\"translate(" <> (toString centerX) <> ", " <> (toString centerY) <> ") rotate(" <> (toString (angle * 180.0 / pi)) <> ")\">" <> text <> "</text>"
|
||||
where
|
||||
offset = rotate angle {x: dimension.widthPx, y: dimension.heightPx}
|
||||
centerX = x - offset.x / 4.0
|
||||
centerY = y - offset.y / 4.0
|
||||
offset = rotate angle {x: dimension.widthPx / 4.0, y: -dimension.heightPx / 8.0}
|
||||
centerX = x - offset.x
|
||||
centerY = y - offset.y
|
||||
idText = case idMaybe of
|
||||
Maybe.Nothing -> ""
|
||||
Maybe.Just id -> "id=\"" <> id <> "\""
|
||||
|
||||
Reference in New Issue
Block a user