static.dart
1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import 'package:flutter/widgets.dart';
import '../../ast/options.dart';
import '../../ast/size.dart';
import '../layout/reset_baseline.dart';
import 'svg_geomertry.dart';
import 'svg_string.dart';
const svgData = {
// path, width, height
'vec': [0.471, 0.714], // values from the font glyph
'oiintSize1': [0.957, 0.499], // oval to overlay the integrand
'oiintSize2': [1.472, 0.659],
'oiiintSize1': [1.304, 0.499],
'oiiintSize2': [1.98, 0.659],
};
Widget staticSvg(String name, MathOptions options,
{bool needBaseline = false}) {
final dimen = svgData[name];
if (dimen == null) {
throw ArgumentError.value(name, 'name', 'Invalid static svg name');
}
final width = dimen[0];
final height = dimen[1];
final viewPortWidth = width.cssEm.toLpUnder(options);
final viewPortHeight = height.cssEm.toLpUnder(options);
final svgWidget = svgWidgetFromPath(
svgPaths[name]!,
Size(viewPortWidth, viewPortHeight),
Rect.fromLTWH(0, 0, 1000 * width, 1000 * height),
options.color,
);
if (needBaseline) {
return ResetBaseline(
height: viewPortHeight,
child: svgWidget,
);
}
return svgWidget;
}