-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加插入图片 \includegraphics 命令支持,需要在哪些地方补充代码才能实现 #149
Comments
这个项目的初衷是展示公式,展示图片应该由用户程序来完成,也建议用户程序只用这个项目来展示公式(比如通过富文本的方式将公式绘制代理到这个库),所以 \includegraphics 一直没实现。但是如果一定要实现,可以通过以下步骤来完成:
/** `imagePath` 为图片的路径,options 为绘制图片的选项(大小、颜色 filter 等) */
drawImage(const std::string& imagePath, ImageDrawOptions options);
class ImageBox : public Box {
...
// 在 draw 方法中调用 `drawImage`
void draw(Graphics2D& g2, float x, float y) override;
}
class ImageAtom : public Atom {
...
// 在这个方法中创建 `ImageBox`
void createBox(Env& env) override;
}
macro(includegraphics) {
....
return ImageAtom(...);
}
|
这里要注意到,image 可能未被下载或 decode,所以在绘制时可能需要先进行准备工作,等这些工作完成之后再通过回调重新绘制。 |
To my knowledge, MicroTeX doesn't currently support "drawing" in TeX with something like tikz/pgf at all, so you'd need to use images for everything. |
感谢感谢! |
另外建议使用 |
主要应用场景是化学和物理试卷中,有些实验图不能完全用纯代码绘制,麻烦大佬提供下思路,提前感谢。
The text was updated successfully, but these errors were encountered: