pinhole

3D Wireframe Drawing Library for Go

  • 所有者: tidwall/pinhole
  • 平台:
  • 许可证: ISC License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

pinhole

3D Wireframe Drawing Library for Go

demo


Why does this exist?

I needed a CPU based 3D rendering library with a very simple API for visualizing data structures. No bells or whistles, just clean lines and solid colors.

Getting Started

Installing

To start using pinhole, install Go and run go get:

$ go get -u github.com/tidwall/pinhole

This will retrieve the library.

Using

The coordinate space has a locked origin of 0,0,0 with the min/max boundaries of -1,-1,-1 to +1,+1,+1.
The Z coordinate extends from -1 (nearest) to +1 (farthest).

There are four types of shapes; line, cube, circle, and dot.
These can be transformed with the Scale, Rotate, and Translate functions.
Multiple shapes can be transformed by nesting in a Begin/End block.

A simple cube:

p := pinhole.New()
p.DrawCube(-0.3, -0.3, -0.3, 0.3, 0.3, 0.3)
p.SavePNG("cube.png", 500, 500, nil)

Rotate the cube:

p := pinhole.New()
p.DrawCube(-0.3, -0.3, -0.3, 0.3, 0.3, 0.3)
p.Rotate(math.Pi/3, math.Pi/6, 0)
p.SavePNG("cube.png", 500, 500, nil)

Add, rotate, and transform a circle:

p := pinhole.New()
p.DrawCube(-0.3, -0.3, -0.3, 0.3, 0.3, 0.3)
p.Rotate(math.Pi/3, math.Pi/6, 0)

p.Begin()
p.DrawCircle(0, 0, 0, 0.2)
p.Rotate(0, math.Pi/2, 0)
p.Translate(-0.6, -0.4, 0)
p.Colorize(color.RGBA{255, 0, 0, 255})
p.End()

p.SavePNG("cube.png", 500, 500, nil)

Contact

Josh Baker @tidwall

License

pinhole source code is available under the ISC License.

主要指标

概览
名称与所有者tidwall/pinhole
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证ISC License
所有者活动
创建于2017-05-19 04:58:06
推送于2021-01-30 16:25:08
最后一次提交2021-01-30 09:25:07
发布数0
用户参与
星数575
关注者数9
派生数21
提交数20
已启用问题?
问题数1
打开的问题数0
拉请求数0
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?