如何将公式字符串转换为图像 [英] How can I convert a string of formula to an image

查看:146
本文介绍了如何将公式字符串转换为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将公式字符串(例如a/b + c * sqrt d)转换为图像
就像以下网页一样.

I want to convert a string of formula (such as a/b+c* sqrt d)to an image
Like what the following webpage does.

http://www.wolframalpha.com/input/?i=3%2F2%2B%285*%286%2F%284%2F%283%2F%282%2F1%29%29%29%29%29%2F4[^]

somebody provide an example or sth? thanks


(Is this a clear description?why no replys???)

推荐答案

以这种方式转换任何内容都需要事先进行一些思考.您需要分析要转换的信息,并弄清楚它的高度和宽度.例如,显示除法运算,例如:
Converting anything in this way requires a little thinking in advance. You need to analyse the information you are converting and figure out how high and wide it might be. For example, showing a division operation such as:
    23
a = --
    10


首先需要两个行",每行必须足够高以包含所选字体中的字符.其次,一条线"高到足以包含分隔符.表达式"a ="的开头应位于分隔线的中心.实际的计算将基于您希望显示的图像的大小以及用于字符的字体的大小,因此,假设字体高10像素,宽8像素,我们将得到以下内容:


requires first, two ''lines'', each of which needs to be high enough to contain characters in the selected font. Secondly a ''line'' high enough to contain a separator. The start of the expression "a = " should be positioned centred on the dividing line. The actual calculations would be based on the size of the image you wish to display and the size of the font being used for the characters, so assuming a font 10 px high by 8 px wide we would have something like:

moveto(32, 0) // position X, Y
write("23")
moveto(0, 6)
write("a = ")
moveto(32, 12)
lineto(48, 12)
moveto(32, 14)
write("10")


这篇关于如何将公式字符串转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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