# 3D Wireframe Drawing Library for Go

### Related tags

Data Visualization graphics

# `pinhole`

3D Wireframe Drawing Library for Go

## 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

`pinhole` source code is available under the ISC License.

##### Canvas is a Go drawing library based on OpenGL or using software rendering that is very similar to the HTML5 canvas API

Go canvas Canvas is a pure Go library that provides drawing functionality as similar as possible to the HTML5 canvas API. It has nothing to do with HT

##### A PDF document generator with high level support for text, drawing and images

GoFPDF document generator Package gofpdf implements a PDF document generator with high level support for text, drawing and images. Features UTF-8 supp

##### A Go package for drawing basic graphics in a terminal

Tgraph Tgraph is a Go package for drawing basic graphics in a terminal. It was inspired by termgraph. Graph types supported: Bar Graphs Multi-variable

##### A PDF document generator with high level support for text, drawing and images

GoFPDF document generator Package go-pdf/fpdf implements a PDF document generator with high level support for text, drawing and images. Features UTF-8

##### Gamespictionary - Scribble.rs is an alternative to the web-based drawing game skribbl.io

Scribble.rs Scribble.rs is an alternative to the web-based drawing game skribbl.

##### golang feature toggle library - a library to help make golang feature toggling clean and easy

toggle supports env_variable backed toggling. It can also be updated via a pubsub interface (tested w/ redis) 2 engines for toggle backing are include

##### sqlx is a library which provides a set of extensions on go's standard database/sql library

sqlx is a library which provides a set of extensions on go's standard database/sql library. The sqlx versions of sql.DB, sql.TX, sql.Stmt, et al. all leave the underlying interfaces untouched, so that their interfaces are a superset on the standard ones. This makes it relatively painless to integrate existing codebases using database/sql with sqlx.

##### This library generate a new tlsconfig usable within go standard library configured with a self-signed certificate generated on the fly

sslcert This library generate a new tlsconfig usable within go standard library configured with a self-signed certificate generated on the fly. Exampl

##### Library to work with MimeHeaders and another mime types. Library support wildcards and parameters.

Mime header Motivation This library created to help people to parse media type data, like headers, and store and match it. The main features of the li

##### Library for working with golang telegram client + bot based on tdlib. This library was taken from the user Arman92 and changed for the current version of tdlib.

go-tdlib Golang Telegram TdLib JSON bindings Install To install, you need to run inside a docker container (it is given below) go get -u github.com/ka

##### A library for the MIGP (Might I Get Pwned) protocolA library for the MIGP (Might I Get Pwned) protocol

MIGP library This contains a library for the MIGP (Might I Get Pwned) protocol. MIGP can be used to build privacy-preserving compromised credential ch

##### A Go Template Library. A bunch of utils and collections that are not part of the Golang standard library.

gotl A Go Template Library. A bunch of utils and collections that are not part of the Golang standard library. Prerequisites This library is using ext

##### Redisx: a library of Go utilities built on the redigo redis client library

redisx redisx is a library of Go utilities built on the redigo redis client libr

##### This library aims to make it easier to interact with Ethereum through de Go programming language by adding a layer of abstraction through a new client on top of the go-ethereum library.

Simple ethereum client Simple ethereum client aims to make it easier for the developers to interact with Ethereum through a new layer of abstraction t

##### This library is a complementary library for Gorm (v2) which resolves the first available pool passed to it.

This library is a complementary library for Gorm (v2) which resolves the first available pool passed to it.

##### Courier Golang client library provides an opinionated wrapper over paho MQTT library to add features on top of it

Courier Golang Client Library Introduction Courier Golang client library provides an opinionated wrapper over paho MQTT library to add features on top

##### ? ID3 decoding and encoding library for Go

id3v2 Supported ID3 versions: 2.3, 2.4 Installation go get -u github.com/bogem/id3v2 Usage example package main import ( "fmt" "log" "github.com

###### go chart is a basic charting library in native golang.

Package chart is a very simple golang native charting library that supports timeseries and continuous line charts.

3.6k Nov 27, 2022
###### 🎨 The adorable charts library for Golang

go-echarts ?? The adorable charts library for Golang. If a language can be used to build web scrapers, it definitely needs to provide a graceful data

5k Nov 28, 2022
###### go-echarts 🎨 The adorable charts library for Golang

go-echarts ?? The adorable charts library for Golang. If a language can be used to build web scrapers, it definitely needs to provide a graceful data

5k Nov 22, 2022
###### Ltree Visualizer - A golang library to visualize postgres ltree type data using DOT language and Graphviz

Ltree Visualizer A golang library to visualize postgres ltree type data using DOT language and Graphviz What is Ltree? Ltree is a data type which is u

8 Jun 12, 2022
###### HSM package provides a simple state chart library written in Go.

UML HSM HSM package provides a simple state chart library written in Go. Supported UML State Chart Features Feature Implemented Test case Simple state

1 Apr 14, 2022
###### fswatch, this library could help watching filesystem changes, like macOS fswatch

fswatch go library for simple UNIX file system watching fswatch provides simple UNIX file system watching in Go. It is based around the Watcher struct

0 Jan 7, 2022
###### A charts library for Golang

go-charts go-charts基于go-chart生成数据图表，无其它模块的依赖纯golang的实现，支持svg与png的输出，Apache ECharts在前端开发中得到众多开发者的认可，go-charts兼容Apache ECharts的配置参数，简单快捷的生成相似的图表(svg或png

95 Nov 24, 2022
###### Gfx - Golang file system extension library

gfx Golang文件操作扩展库，包含工作和生活中关于文件操作的各种有用的使用方法，包括 更友好的API 文件创建 文件删除 文件复制 一切皆可配置 文件名

0 Mar 10, 2022
###### Globe wireframe visualizations in Golang

globe Globe wireframe visualizations in Golang backed by pinhole. Getting Started Install globe with \$ go get -u github.com/mmcloughlin/globe Start wi

1.6k Nov 10, 2022
###### Library to use HTML5 Canvas from Go-WASM, with all drawing within go code

go-canvas go-canvas is a pure go+webassembly Library for efficiently drawing on a html5 canvas element within the browser from go without requiring ca

179 Oct 30, 2022