package svg
import "github.com/d2lang/mathjax-go/internal/layout"
func (w *wrapper ) computeSemanticsBBox (bbox *layout .BBox ) {
if len (w .children ) == 0 {
return
}
child := w .children [0 ].getBBox ()
bbox .W , bbox .H , bbox .D = child .W , child .H , child .D
}
func (w *wrapper ) semanticsToSVG (parent *Element ) {
element := w .standardSVG (parent )
if len (w .children ) != 0 {
w .children [0 ].toSVG (element )
}
}
func (w *wrapper ) computeAnnotationBBox (bbox *layout .BBox ) {
bbox .W , bbox .H , bbox .D = 0 , 0 , 0
}
func (w *wrapper ) annotationToSVG (parent *Element ) {
element := w .standardSVG (parent )
w .addChildren (element )
}
func (w *wrapper ) computeAnnotationXMLBBox (bbox *layout .BBox ) {
w .computeChildrenBBox (bbox )
}
func (w *wrapper ) annotationXMLToSVG (parent *Element ) {
element := w .standardSVG (parent )
x := 0.0
for _ , child := range w .children {
if child .node .Kind == "XML" || child .node .Kind == "xml" {
child .xmlToSVG (element )
} else {
child .toSVG (element )
}
bbox := child .outerBBox ()
child .place (x +bbox .L *bbox .RScale , 0 )
x += (bbox .L + bbox .W + bbox .R ) * bbox .RScale
}
}
func (w *wrapper ) computeXMLBBox (bbox *layout .BBox ) {
bbox .W , bbox .H , bbox .D = 0 , 0 , 0
}
func (w *wrapper ) xmlToSVG (parent *Element ) {
bbox := w .getBBox ()
em := w .renderer .options .Em
element := NewElement ("foreignObject" ).
SetAttr ("data-mjx-xml" , "true" ).
SetAttr ("y" , jsFixed (-bbox .H *em , 1 )+"px" ).
SetAttr ("width" , jsFixed (bbox .W *em , 1 )+"px" ).
SetAttr ("height" , jsFixed ((bbox .H +bbox .D )*em , 1 )+"px" ).
SetAttr ("transform" , "scale(" +fixed (1 /em )+") matrix(1 0 0 -1 0 0)" )
w .element = element
parent .Append (element )
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .