expgraphy

command module
v0.0.0-...-a9d73b1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

README

Expgraphy

Expgraphy 解析一个数学表达式,输出复合数学规范的表达式图片

用法

example

var input = flag.String("exp", "", "math expression")
var output = flag.String("out", "./out.png", "output file")
var fontSize = flag.Float64("font", 36.0, "font size in float64")

func main() {
	flag.Parse()

	...

	expr, err := exp.Parse(*input) //解析表达式
	...
	gra := expr.GetGraphy() //获取绘图工具
	size := gra.Measure(*fontSize) //测量表达式尺寸
	img := image.NewRGBA(image.Rect(0,0, 300, 200))
	startPoint := fixed.Point26_6{X:size.X/2, Y:size.Y*3/2}  //绘图起点在左下角
	gra.Draw(img, startPoint) //绘制
}

效果

输入expgraphy -exp "(x+y)*(x-y)/(y+1)" -out out1.png -font 30

输出

geometry

输入expgraphy -exp "pow(x+y,x)" -out out2.png -font 30

输出

geometry

输入expgraphy -exp "sqrt(x*x+y*y)" -out out3.png -font 30

输出

geometry

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL