7 lines
5.3 KiB
Text
7 lines
5.3 KiB
Text
{
|
|
"version": 3,
|
|
"sources": ["src/constants.ts", "src/mobject/geometry.ts", "src/renderer/index.ts", "src/scene/index.ts", "src/utils/tex.ts", "src/index.ts"],
|
|
"sourcesContent": ["export const PI = Math.PI;\nexport const TAU = 2 * PI;\n\nexport const DEFAULT_DOT_RADIUS = 0.08;\n", "import { DEFAULT_DOT_RADIUS, TAU } from \"../constants\";\n\nexport class Arc {\n constructor(public radius: number, public startAngle: number, public angle: number) {}\n}\n\nexport class Circle extends Arc {\n constructor(radius: number) {\n super(radius, 0, TAU);\n }\n}\n\nexport class Dot extends Circle {\n constructor(radius?: number) {\n super(radius ?? DEFAULT_DOT_RADIUS);\n }\n}\n", "import { Mobject } from \"../mobject\";\nimport { Scene } from \"../scene\";\n\nexport class Canvas2DRenderer {\n context: CanvasRenderingContext2D;\n\n skipAnimations: boolean;\n animationStartTime: Date;\n animationElapsedTime: number;\n\n constructor(context: CanvasRenderingContext2D) {\n this.context = context;\n\n this.skipAnimations = false;\n this.animationStartTime = new Date();\n this.animationElapsedTime = 0;\n }\n\n init_scene(scene: Scene) {}\n\n public render(scene: Scene) {\n this.updateFrame(scene);\n if (this.skipAnimations) return;\n\n for (let mobject of scene.mobjects) {\n if (!mobject.shouldRender) continue;\n this.renderMobject(mobject);\n }\n }\n\n renderMobject(mobject: Mobject) {\n // for (let shaderWrapper of mobject.getShaderWrapperList()) {\n // let mesh = new Mesh();\n // }\n }\n\n updateFrame(scene: Scene) {\n for (let mobject of scene.mobjects) {\n if (!mobject.shouldRender) continue;\n this.renderMobject(mobject);\n }\n\n this.animationElapsedTime = +new Date() - +this.animationStartTime;\n }\n}\n", "import { Animation } from \"../animation\";\nimport { Mobject } from \"../mobject\";\n\nexport class Scene {\n animations: Animation[];\n mobjects: Mobject[];\n\n constructor() {\n this.animations = [];\n this.mobjects = [];\n }\n\n public construct() {}\n\n /**\n * Add Mobjects to this scene, from background to foreground in the order\n * they're added.\n */\n public add(...mobjects: Mobject[]) {\n this.mobjects.push(...mobjects);\n }\n}\n", "declare namespace MathJax {\n function tex2svg(expression: string): HTMLElement;\n};\n\n/**\n * Convert TeX expression to an SVG string.\n */\nexport function texToSvg(expression: string): string {\n let el = <HTMLElement>MathJax.tex2svg(expression);\n let child = <SVGElement>el.children[0];\n return child.innerHTML;\n}\n", "import { Dot } from \"./mobject/geometry\";\nimport { Canvas2DRenderer } from \"./renderer\";\nimport { Scene } from \"./scene\";\nimport { texToSvg } from \"./utils/tex\";\n\nexport function init(scene: Scene, el: HTMLElement) {\n let canvasEl = document.createElement(\"canvas\");\n canvasEl.width = 640;\n canvasEl.height = 480;\n\n let contextOrNull = canvasEl.getContext(\"2d\");\n if (contextOrNull == null) return;\n let context = contextOrNull;\n\n let renderer = new Canvas2DRenderer(context);\n\n let lastTime: DOMHighResTimeStamp | null;\n let step = function (time: DOMHighResTimeStamp): void {\n let timeDelta = time - (lastTime ?? 0);\n renderer.render(scene);\n requestAnimationFrame(step);\n lastTime = time;\n };\n requestAnimationFrame(step);\n\n el.appendChild(canvasEl);\n}\n\nclass ExampleScene extends Scene {\n override construct() {\n let dot = new Dot([-2, -1, 0]);\n let dot2 = new Dot([2, 1, 0]);\n let line = new Line(dot.getCenter(), dot2.getCenter());\n let b1 = new Brace(line);\n this.add(line, dot, dot2);\n }\n}\n\ntexToSvg(\"x + 1\");\n\nlet el = document.getElementById(\"manim\");\nif (el) init(new ExampleScene(), el);\n"],
|
|
"mappings": ";;AAAO,MAAM,KAAK,KAAK;AAChB,MAAM,MAAM,IAAI;AAEhB,MAAM,qBAAqB;;;ACD3B,kBAAU;AAAA,IACf,YAAmB,QAAuB,YAA2B,OAAe;AAAjE;AAAuB;AAA2B;AAAA;AAAA;AAGhE,6BAAqB,IAAI;AAAA,IAC9B,YAAY,QAAgB;AAC1B,YAAM,QAAQ,GAAG;AAAA;AAAA;AAId,0BAAkB,OAAO;AAAA,IAC9B,YAAY,QAAiB;AAC3B,YAAM,0B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