/************************************************************* * * Copyright (c) 2018 The MathJax Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @fileoverview Implements the SVGmsqrt wrapper for the MmlMsqrt object * * @author dpvc@mathjax.org (Davide Cervone) */ import {SVGWrapper, SVGConstructor} from '../Wrapper.js'; import {CommonMsqrt, CommonMsqrtMixin} from '../../common/Wrappers/msqrt.js'; import {SVGmo} from './mo.js'; import {BBox} from '../BBox.js'; import {MmlMsqrt} from '../../../core/MmlTree/MmlNodes/msqrt.js'; import {StyleList} from '../../common/CssStyles.js'; /*****************************************************************/ /** * The SVGmsqrt wrapper for the MmlMsqrt object * * @template N The HTMLElement node class * @template T The Text node class * @template D The Document class */ export class SVGmsqrt extends CommonMsqrtMixin>(SVGWrapper) { public static kind = MmlMsqrt.prototype.kind; public dx: number = 0; // indent due to root /** * @override */ public toSVG(parent: N) { const surd = this.childNodes[this.surd]; const base = this.childNodes[this.base]; const root = (this.root ? this.childNodes[this.root] : null); // // Get the parameters for the spacing of the parts // const rbox = this.getBBox(); const sbox = surd.getBBox(); const bbox = base.getBBox(); const t = this.font.params.rule_thickness * this.bbox.scale; // // Create the SVG structure for the root // const SVG = this.standardSVGnode(parent); const BASE = this.adaptor.append(SVG, this.svg('g')); // // Place the children // this.addRoot(SVG, root, sbox); surd.toSVG(SVG); surd.place(this.dx, rbox.h - sbox.h - t); base.toSVG(BASE); base.place(this.dx + sbox.w, 0); const RULE = this.adaptor.append(SVG, this.svg('rect', { width: this.fixed(bbox.w), height: this.fixed(t), x: this.fixed(this.dx + sbox.w), y: this.fixed(rbox.h - 2 * t) })); } /** * Add root HTML (overridden in mroot) * * @param {N} ROOT The container for the root * @param {SVGWrapper} root The wrapped MML root content * @param {BBox} sbox The bounding box of the surd */ protected addRoot(ROOT: N, root: SVGWrapper, sbox: BBox) { } }