Skip to content

Instantly share code, notes, and snippets.

@ajstarks
ajstarks / gist:080972af9bf905ffe595e14009e8e471
Created January 21, 2024 02:37
wayland gio crash with #555 applied
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc0202e03a8 stack=[0xc0202e0000, 0xc0402e0000]
fatal error: stack overflow
runtime stack:
runtime.throw({0x7bbcd4?, 0x7fb4ca133778?})
/home/ajstarks/go/src/runtime/panic.go:1077 +0x5c fp=0x7fb4ca133728 sp=0x7fb4ca1336f8 pc=0x43ac9c
runtime.newstack()
/home/ajstarks/go/src/runtime/stack.go:1107 +0x5ac fp=0x7fb4ca1338d8 sp=0x7fb4ca133728 pc=0x45452c
traceback: unexpected SPWRITE function runtime.morestack
@ajstarks
ajstarks / old-api.go
Created November 30, 2023 16:16
giocanvas client with old event API
// kbpointer processes the keyboard events and pointer events in percent coordinates
func kbpointer(q event.Queue, cfg config) {
width, height := cfg.width, cfg.height
prec := cfg.precision
stepsize := cfg.stepsize
for _, ev := range q.Events(pressed) {
// keyboard events
if k, ok := ev.(key.Event); ok {
switch k.State {
case key.Press:
@ajstarks
ajstarks / filter-api.go
Created November 30, 2023 16:15
giocanvas client example with new Gio filter event API:
// kbpointer processes the keyboard events and pointer events in percent coordinates
func kbpointer(q input.Source, cfg config) {
width, height := cfg.width, cfg.height
prec := cfg.precision
stepsize := cfg.stepsize
for {
e, ok := q.Event(
key.Filter{Optional: key.ModCtrl},
pointer.Filter{Kinds: pointer.Press | pointer.Move | pointer.Release},
)
package main
import (
"flag"
"fmt"
"image"
"image/color"
_ "image/gif"
_ "image/jpeg"
_ "image/png"

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).

// Go Gestalt
// make a series of pages visualizing the layout of Go code
package main
import (
"bufio"
"flag"
"fmt"
"os"
"regexp"
// 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 03:42
visualize go modules
// 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"
@ajstarks
ajstarks / gist:2177ffdcbb1259002b353c5e0541665f
Last active September 9, 2018 17:13
gopherstats charting
#!/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
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