Skip to content

Instantly share code, notes, and snippets.

Avatar

Anthony Starks ajstarks

View GitHub Profile
View 2dtest.go
package main
import (
"flag"
"fmt"
"image"
"image/color"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
View 2dapi.md

Notes on a general 2D API

Introduction and Motivation

There is a need for a high-level Go API for developers and designers to think in terms of high level objects that make up a visual display. The objects will be familiar to anyone using a modern illustration program (text, images, lines, arcs, circles, curves, etc). The API should facilitate the artful arrangement of these elements on a scalable 2D canvas.

The principle is to keep the number of methods small and consistent, using a common set of arguments for location (x, y), and dimentions (w, h).

View gg.go
// Go Gestalt
// make a series of pages visualizing the layout of Go code
package main
import (
"bufio"
"flag"
"fmt"
"os"
"regexp"
View settings.json
// Place your settings in this file to overwrite the default settings
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "keyword",
"settings": {
"foreground": "#AA0000"
}
}
@ajstarks
ajstarks / modviz.go
Last active May 29, 2019
visualize go modules
View modviz.go
// modviz: visualize go modules
// go mod graph | sed -Ee 's/@[^[:blank:]]+//g' | sort | uniq |
// awk '{print $1}' | sort | uniq -c | sort -nr | awk '{print $2 "\t" $1}' | modviz > f.svg
package main
import (
"bufio"
"flag"
"fmt"
"io"
View gist:2177ffdcbb1259002b353c5e0541665f
#!/bin/bash
. $HOME/Library/deckfuncs.sh
gopherstats -mode github-issue-close > gic
gopherstats -mode gerrit-cls > gerrit
awk '{print $1 "\t" substr($14, 2)}' gic > goog-people.d
awk '{print $1 "\t" substr($16, 2)}' gic > ext-people.d
awk '{print $1 "\t" substr($8, 1, length($8)-1)}' gic > goog.d
View pg.go
package main
import (
"fmt"
"github.com/ajstarks/pdfgen"
"os"
)
func blist(p *pdfgen.PDFDoc, x, y, size, ls float64, list []string, color string) {
qsize := size/4
@ajstarks
ajstarks / pg.go
Created Jun 12, 2018
pdfgen client
View pg.go
package main
import (
"os"
"github.com/ajstarks/pdfgen"
)
func main() {
xp := []float64{300, 350, 400}
yp := []float64{500, 550, 500}
@ajstarks
ajstarks / gcert.go
Created Jun 3, 2018
Generating the Gophercises certificate
View gcert.go
package main
import (
"github.com/ajstarks/deck/generate"
"os"
"time"
)
type certdata struct {
student string
@ajstarks
ajstarks / bars.go
Created May 25, 2018
Gophercises SVGo example refactor
View bars.go
package main
import (
"os"
"github.com/ajstarks/svgo"
)
func main() {
canvas := svg.New(os.Stdout)