Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Replace alignment-baseline with dominant-baseline #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/elements/graph/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class Node extends Group {

this.nodeName = new Text(cx, cy, text);
this.nodeName.style.textAnchor = "middle";
this.nodeName.root.setAttribute("alignment-baseline", "middle");
this.nodeName.root.setAttribute('dominant-baseline', 'central');
this.nodeEllipse = new Ellipse(cx, cy, rx, ry);
this.nodeEllipse.fill = '#f8f8f8';
this.children = [];
Expand Down
2 changes: 1 addition & 1 deletion source/elements/input/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class Button extends Input {

// Create a text element
this.label = new Text( 0, 1, str);
this.label.root.setAttribute('alignment-baseline','middle');
this.label.root.setAttribute('dominant-baseline', 'middle');
this.label.root.style.textAnchor = 'middle';

// TODO: why is this.text.root.textLength returning zero?
Expand Down
2 changes: 1 addition & 1 deletion source/elements/input/check-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class CheckBox extends Input {
this.box = new Rectangle( -6.5, -6.5, 13, 13);
this.box.root.setAttribute('rx', '2px');
this.label = new Text( 18, 1, text);
this.label.root.setAttribute('alignment-baseline','middle');
this.label.root.setAttribute('dominant-baseline', 'middle');
this.root.appendChild(this.box.root);
this.root.appendChild(this.label.root);

Expand Down
6 changes: 3 additions & 3 deletions source/elements/input/dropdown-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class DropdownControl extends Input {
this.currSelection.root.classList.add('dropdown-control-curr-selection-box');

this.currSelectionText = new Text(0, 1, this.optionLabels[this.currentIndex]);
this.currSelectionText.root.setAttribute('alignment-baseline','middle');
this.currSelectionText.root.setAttribute('dominant-baseline', 'middle');
this.currSelectionText.style.textAnchor = 'middle';

this.currSelectionBox = new Rectangle(0, -16, this.textWidth*3+16, 32);
Expand Down Expand Up @@ -112,7 +112,7 @@ export default class DropdownControl extends Input {
currSelection.root.classList.add('dropdown-control-menu-option');

let currSelectionText = new Text(0, 1, this.optionLabels[this.currentIndex]);
currSelectionText.root.setAttribute('alignment-baseline','middle');
currSelectionText.root.setAttribute('dominant-baseline', 'middle');
currSelectionText.style.textAnchor = 'middle';

let currSelectionBox = new Rectangle(0, -16, this.textWidth*3+16, 32);
Expand All @@ -133,7 +133,7 @@ export default class DropdownControl extends Input {
menuOption.root.classList.add('dropdown-control-menu-option');

let optionText = new Text(0, 1 + rectY, label);
optionText.root.setAttribute('alignment-baseline','middle');
optionText.root.setAttribute('dominant-baseline', 'middle');
optionText.style.textAnchor = 'middle';

let optionBox = new Rectangle(0, -16 + rectY, this.textWidth*3+16, 32);
Expand Down
2 changes: 1 addition & 1 deletion source/elements/input/hover-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class HoverBox extends Input {
super();
// Create a text element
this.label = new Text(0, 1, str);
this.label.root.setAttribute('alignment-baseline','middle');
this.label.root.setAttribute('dominant-baseline', 'middle');
this.label.root.style.textAnchor = 'middle';

this.box = this.rectangle( 0, -16, this.label.length*2 + 16, 32);
Expand Down
6 changes: 3 additions & 3 deletions source/elements/math/plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,21 +406,21 @@ export default class Plot extends SVG {
} else {
title = group.text( this.width/2, 25, config.title);
}
title.setAttribute('alignment-baseline', 'middle');
title.setAttribute('dominant-baseline', 'middle');
title.setAttribute('text-anchor', 'middle');

let xPoints = this.getXLabelPoints();
let yPoints = this.getYLabelPoints();
for( let p of xPoints) {
let point = this.internalToAbsolute(p);
let text = group.text( point.x + config.margin, config.margin + this._height + config.margin/2, `${p.x.toFixed(1)}`);
text.setAttribute('alignment-baseline', 'middle');
text.setAttribute('dominant-baseline', 'middle');
text.setAttribute('text-anchor', 'middle');
}
for( let p of yPoints) {
let point = this.internalToAbsolute(p);
let text = group.text( point.x + config.margin/2, point.y + config.margin, `${p.y.toFixed(1)}`);
text.setAttribute('alignment-baseline', 'middle');
text.setAttribute('dominant-baseline', 'middle');
text.setAttribute('text-anchor', 'middle');
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/elements/svg/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Typography } from './content-model.js';
/**
* These attributes control the text position.
*/
export type TextAttributes = 'baseline-shift' | 'text-anchor' | 'alignment-baseline';
export type TextAttributes = 'baseline-shift' | 'text-anchor' | 'dominant-baseline';

/**
* Text is a basic element containing string contents
Expand Down
2 changes: 1 addition & 1 deletion source/examples/interaction/key-board-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ for( let i = 0; i < 5; i++ ) {
let rectangle = interactive.rectangle( x, y, 64, 64);
rectangle.root.setAttribute('rx', '3px');12341
let text = interactive.text( x + 32, y + 32, (i + 1).toString());
text.root.setAttribute('alignment-baseline','middle');
text.root.setAttribute('dominant-baseline', 'middle');
text.root.setAttribute('text-anchor','middle');

keys.push(rectangle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function main(id:string) {
yAxis.setAttribute('marker-start', `url(#${marker.id})`);

let xAxisLabel = interactive.text( xAxis.x2 + 16, xAxis.y2, 'x');
xAxisLabel.setAttribute('alignment-baseline','middle');
xAxisLabel.setAttribute('dominant-baseline', 'middle');
let yAxisLabel = interactive.text( yAxis.x1, yAxis.y1 - 16, 'y');
yAxisLabel.setAttribute('text-anchor','middle');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ xAxis.setAttribute('marker-end', `url(#${marker.id})`);
yAxis.setAttribute('marker-end', `url(#${marker.id})`);

let xAxisLabel = interactive.text( xAxis.x2 + 16, xAxis.y2, 'x');
xAxisLabel.setAttribute('alignment-baseline','middle');
xAxisLabel.setAttribute('dominant-baseline', 'middle');
let yAxisLabel = interactive.text( yAxis.x1, yAxis.y2 - 16, 'y');
yAxisLabel.setAttribute('text-anchor','middle');

Expand Down
2 changes: 1 addition & 1 deletion source/examples/math/cartesian-coordinate-system-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ xAxis.setAttribute('marker-end', `url(#${marker.id})`);
yAxis.setAttribute('marker-end', `url(#${marker.id})`);

let xAxisLabel = interactive.text( xAxis.x2 + 16, xAxis.y2, 'x');
xAxisLabel.setAttribute('alignment-baseline','middle');
xAxisLabel.setAttribute('dominant-baseline', 'middle');
let yAxisLabel = interactive.text( yAxis.x1, yAxis.y2 - 16, 'y');
yAxisLabel.setAttribute('text-anchor','middle');

Expand Down
2 changes: 1 addition & 1 deletion source/examples/math/cartesian-coordinate-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function main(id:string) {
yAxis.setAttribute('marker-start', `url(#${marker.id})`);

let xAxisLabel = interactive.text( xAxis.x2 + 16, xAxis.y2, 'x');
xAxisLabel.setAttribute('alignment-baseline','middle');
xAxisLabel.setAttribute('dominant-baseline', 'middle');
let yAxisLabel = interactive.text( yAxis.x1, yAxis.y1 - 16, 'y');
yAxisLabel.setAttribute('text-anchor','middle');

Expand Down
1 change: 1 addition & 0 deletions source/examples/math/modular-arithmetic-wheel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import {Interactive, Path, Text, Group, isPrime} from '../../index.js';
import {TAU} from '../../util/constants.js';
// @ts-ignore
import katex from '/katex/katex.module.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion source/examples/math/number-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ xAxis.setAttribute('marker-end', `url(#${marker.id})`);
xAxis.setAttribute('marker-start', `url(#${marker.id})`);

let xAxisLabel = interactive.text( xAxis.x2 + 16, xAxis.y2, 'x');
xAxisLabel.setAttribute('alignment-baseline','middle');
xAxisLabel.setAttribute('dominant-baseline', 'middle');

let xPosition = interactive.line( 0, 0, 0, 0);
xPosition.style.stroke = 'cornflowerblue';
Expand Down
4 changes: 2 additions & 2 deletions source/examples/math/polar-coordinate-system-pi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ yAxis.setAttribute('marker-end', `url(#${marker.id})`);
yAxis.setAttribute('marker-start', `url(#${marker.id})`);

let right = interactive.text( xAxis.x2 + 16, xAxis.y2, '0, 2π');
right.setAttribute('alignment-baseline','middle');
right.setAttribute('dominant-baseline', 'middle');
let top = interactive.text( yAxis.x1, yAxis.y1 - 16, 'π/2');
top.setAttribute('text-anchor','middle');
let left = interactive.text( xAxis.x1 - 20, xAxis.y2, 'π');
left.setAttribute('alignment-baseline','middle');
left.setAttribute('dominant-baseline', 'middle');
let bottom = interactive.text( yAxis.x1, yAxis.y2 + 32, '3π/2');
bottom.setAttribute('text-anchor','middle');

Expand Down
4 changes: 2 additions & 2 deletions source/examples/math/polar-coordinate-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export default function main( id:string ) {
yAxis.setAttribute('marker-start', `url(#${marker.id})`);

let right = interactive.text( xAxis.x2 + 16, xAxis.y2, '0, τ');
right.setAttribute('alignment-baseline','middle');
right.setAttribute('dominant-baseline', 'middle');
let top = interactive.text( yAxis.x1, yAxis.y1 - 16, 'τ/4');
top.setAttribute('text-anchor','middle');
let left = interactive.text( xAxis.x1 - 32, xAxis.y2, 'τ/2');
left.setAttribute('alignment-baseline','middle');
left.setAttribute('dominant-baseline', 'middle');
let bottom = interactive.text( yAxis.x1, yAxis.y2 + 32, '3/4τ');
bottom.setAttribute('text-anchor','middle');

Expand Down
1 change: 1 addition & 0 deletions source/examples/math/unit-circle-angle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import {Interactive} from '../../index.js';
// @ts-ignore
import katex from '/katex/katex.module.js';

export default function main(id:string) {
Expand Down
1 change: 1 addition & 0 deletions source/examples/math/unit-circle-cosine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {Interactive} from '../../index.js';
import Group from '../../elements/svg/group.js';
import Point from '../../elements/math/point.js';
import Line from '../../elements/svg/line.js';
// @ts-ignore
import katex from '/katex/katex.module.js';

export default function main(id:string) {
Expand Down
3 changes: 2 additions & 1 deletion source/examples/math/unit-circle-right-triangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import {Interactive} from '../../index.js';
// @ts-ignore
import katex from '/katex/katex.module.js';

export default function main(id) {
Expand Down Expand Up @@ -39,7 +40,7 @@ export default function main(id) {
yAxis.setAttribute('marker-start', `url(#${marker.id})`);

let xAxisLabel = interactive.text( xAxis.x2 + margin/3, xAxis.y2, 'x');
xAxisLabel.setAttribute('alignment-baseline','middle');
xAxisLabel.setAttribute('dominant-baseline', 'middle');
xAxisLabel.style.fontFamily = 'KaTeX_Math';
xAxisLabel.style.fontSize = '22px';
let yAxisLabel = interactive.text( yAxis.x1, yAxis.y1 - margin/2, 'y');
Expand Down
1 change: 1 addition & 0 deletions source/examples/math/unit-circle-sine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {Interactive} from '../../index.js';
import Group from '../../elements/svg/group.js';
import Point from '../../elements/math/point.js';
import Line from '../../elements/svg/line.js';
// @ts-ignore
import katex from '/katex/katex.module.js';

export default function main(id:string) {
Expand Down
2 changes: 1 addition & 1 deletion source/examples/math/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ yAxis.setAttribute('marker-end', `url(#${marker.id})`);
yAxis.setAttribute('marker-start', `url(#${marker.id})`);

let xAxisLabel = interactive.text( xAxis.x2 + 16, xAxis.y2, 'x');
xAxisLabel.setAttribute('alignment-baseline','middle');
xAxisLabel.setAttribute('dominant-baseline', 'middle');
let yAxisLabel = interactive.text( yAxis.x1, yAxis.y1 - 16, 'y');
yAxisLabel.setAttribute('text-anchor','middle');

Expand Down
2 changes: 1 addition & 1 deletion source/examples/svg/svg-rotate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ rotateText.addDependency(control);
rotateText.update = function() {
rotateText.contents = `rotate(${getAngle()})`;
};
rotateText.root.setAttribute('alignment-baseline', 'middle');
rotateText.root.setAttribute('dominant-baseline', 'middle');
rotateText.root.setAttribute('text-anchor', 'middle');
rotateText.update();

Expand Down
2 changes: 1 addition & 1 deletion source/examples/svg/svg-scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ scaleText.update = function() {
let scaleY = control.y/(2*w);
scaleText.contents = `scale(${scaleX.toFixed(2)}, ${scaleY.toFixed(2)})`;
};
scaleText.root.setAttribute('alignment-baseline', 'middle');
scaleText.root.setAttribute('dominant-baseline', 'middle');
scaleText.root.setAttribute('text-anchor', 'middle');
scaleText.update();

Expand Down
2 changes: 1 addition & 1 deletion source/examples/svg/svg-transform-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ scale.update = function() {
// transformText.contents += `rotate(${getAngle()}) `;
//
// };
// transformText.root.setAttribute('alignment-baseline', 'middle');
// transformText.root.setAttribute('dominant-baseline', 'middle');
// transformText.root.setAttribute('text-anchor', 'middle');
// transformText.update();

Expand Down
2 changes: 1 addition & 1 deletion source/examples/svg/svg-translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ translateText.addDependency(control);
translateText.update = function() {
translateText.contents = `translate(${control.x}, ${control.y})`;
};
translateText.root.setAttribute('alignment-baseline', 'middle');
translateText.root.setAttribute('dominant-baseline', 'middle');
translateText.root.setAttribute('text-anchor', 'middle');
translateText.update();

Expand Down
2 changes: 1 addition & 1 deletion source/tests/elements/geometry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('Geometry', function () {
});
it('text vertically centered', function() {
let text = interactive.text(0,0, 'Typography');
text.setAttribute('alignment-baseline', 'middle');
text.setAttribute('dominant-baseline', 'middle');
element = text;
});
it('group', function() {
Expand Down
4 changes: 2 additions & 2 deletions source/tests/elements/math/plot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ describe('Plot', function () {
let title = new Text(interactive.width/2, 25, 'sin(');
let span = title.tspan('x');
span.setAttribute('text-anchor', 'middle');
span.setAttribute('alignment-baseline', 'middle');
span.setAttribute('dominant-baseline', 'middle');
span.style.fontFamily = 'KaTeX_Math';
title.contents += ')';
title.setAttribute('alignment-baseline', 'middle');
title.setAttribute('dominant-baseline', 'middle');
title.setAttribute('text-anchor', 'middle');

plot = interactive.plot(Math.sin, {
Expand Down