使用 Quartz 2d 绘制公式

Drawing formulas with Quartz 2d(使用 Quartz 2d 绘制公式)

本文介绍了使用 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,因为默认情况下 CALayer 不渲染为矢量元素.有关此渲染如何在我的应用程序中工作的示例,请参阅开源 Core Plot项目,它在其基础级别做同样的事情.

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,一旦你将它们解析为分层数据结构,这非常简单,但将它们从 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 绘制公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用 Quartz 2d 绘制公式

基础教程推荐