使用Quartz 2D绘制公式 [英] Drawing formulas with Quartz 2d

查看:172
本文介绍了使用Quartz 2D绘制公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程序中,我想画几个公式。我怎么能管理石英2d?有没有办法来构建公式,例如在乳胶?还是有现有的框架?感谢。

In my iPhone App I'd like to draw a few formulas. How can I manage that with quartz 2d? Is there a way to build formulas like for example in latex? Or are there any existing frameworks? Thanks.

推荐答案

作为一个iPhone应用程序,只是那样,相信我,当我说排版方程不是一个微不足道的承诺。在我的情况下,我使用Core Animation图层来构造解析方程的子元素。等式是分层构造的,并且构成它们的操作是这样布置的。每个操作都包含在其父操作的层中,并根据该特定操作的规则进行布局。

As the developer of an iPhone application which does just that, trust me when I say typesetting equations is not a trivial undertaking. In my case, I used Core Animation layers to construct the sub-elements of a parsed equation. The equations are constructed hierarchically, and the operations that compose them are laid out as such. Each operation is contained within its parent operation's layer, and laid out following the rules of that particular operation.

为了渲染方程中的操作的可视元素,我使用Quartz绘制线条,符号等,但是大多数绘图只是使用NSString文本绘图扩展在CALayer中绘制的文本。

For rendering the visual elements of the operations within an equation, I used Quartz to draw lines, symbols, etc., but most of the drawing was simply text drawn within a CALayer using the NSString text drawing extensions.

我覆盖了标准CALayer渲染架构,用于根据这些方程生成PDF,因为默认情况下CALayers不显示为向量元素。有关此应用在我的应用中如何工作的示例,请参阅开源核心图P

I did override the standard CALayer rendering architecture for the generation of PDFs from these equations, because CALayers don't render as vector elements by default. For an example of how this rendering works in my application, see the open source Core Plot project, which does the same thing at its base level.

我会从方程式输出到LaTeX,这很简单,一旦你把它们解析成层次结构

I do output to LaTeX from the equations, which is pretty simple once you've parsed them into a hierarchical data structure, but parsing them from LaTeX into that structure is proving a little trickier.

对于简单的文本方程输入和求值,你可能会发现Graham Cox的 GCMathParser 使用。

For simple text equation input and evaluation, you might find Graham Cox's GCMathParser to be of use.

这篇关于使用Quartz 2D绘制公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆