Documentation
¶
Overview ¶
Example (Canvas_Circ) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
dst := image.NewPaletted(image.Rect(0, 0, 9, 9), pal)
gc := canvas.New(dst)
gc.Translate(4, 4)
gc.Cls(0)
gc.Color(1)
gc.Circ(0, 0, 2)
gc.Identity()
for y := 0; y < dst.Bounds().Dy(); y++ {
for x := 0; x < dst.Bounds().Dx(); x++ {
if dst.ColorIndexAt(x, y) == 1 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░ ░░░░░░▓▓▓▓▓▓░░░░░░ ░░░░▓▓░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░▓▓░░░░ ░░░░░░▓▓▓▓▓▓░░░░░░ ░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░
Example (Canvas_CircFill) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
dst := image.NewPaletted(image.Rect(0, 0, 9, 9), pal)
gc := canvas.New(dst)
gc.Cls(0)
gc.Translate(4, 4)
gc.Color(1)
gc.CircFill(0, 0, 2)
gc.Identity()
for y := 0; y < dst.Bounds().Dy(); y++ {
for x := 0; x < dst.Bounds().Dx(); x++ {
if dst.ColorIndexAt(x, y) == 1 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░ ░░░░░░▓▓▓▓▓▓░░░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░░░▓▓▓▓▓▓░░░░░░ ░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░
Example (Canvas_GlyphBounds) ¶
package main
import (
"fmt"
"os"
"github.com/lucasepe/doodlekit/internal/canvas"
"github.com/lucasepe/doodlekit/internal/fonts"
)
func main() {
r := rune('A')
face := canvas.MustLoadFont(fonts.Micro()).NewFace()
bounds, advance, ok := face.GlyphBounds(r)
if !ok {
fmt.Fprintf(os.Stderr, "the face does not contain a glyph for '%v'", r)
return
}
w := canvas.UnfixI(bounds.Max.X) - canvas.UnfixI(bounds.Min.X)
h := canvas.UnfixI(bounds.Max.Y) - canvas.UnfixI(bounds.Min.Y)
fmt.Printf("GlyphBounds: %dx%d\n", w, h)
fmt.Printf("Advance: %v\n", canvas.UnfixI(advance))
}
Output: GlyphBounds: 4x5 Advance: 4
Example (Canvas_Line) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
dst := image.NewPaletted(image.Rect(0, 0, 8, 8), pal)
gc := canvas.New(dst)
gc.Cls(0)
gc.Color(1)
gc.Line(1, 1, 6, 6)
for y := 0; y < dst.Bounds().Dy(); y++ {
for x := 0; x < dst.Bounds().Dx(); x++ {
if dst.ColorIndexAt(x, y) == 1 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░░░░░░░░░░░ ░░▓▓░░░░░░░░░░░░ ░░░░▓▓░░░░░░░░░░ ░░░░░░▓▓░░░░░░░░ ░░░░░░░░▓▓░░░░░░ ░░░░░░░░░░▓▓░░░░ ░░░░░░░░░░░░▓▓░░ ░░░░░░░░░░░░░░░░
Example (Canvas_Line_H) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
dst := image.NewPaletted(image.Rect(0, 0, 8, 3), pal)
gc := canvas.New(dst)
gc.Cls(0)
gc.Color(1)
gc.Line(1, 1, 6, 1)
for y := 0; y < dst.Bounds().Dy(); y++ {
for x := 0; x < dst.Bounds().Dx(); x++ {
if dst.ColorIndexAt(x, y) == 1 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░░░░░░░░░░░ ░░▓▓▓▓▓▓▓▓▓▓▓▓░░ ░░░░░░░░░░░░░░░░
Example (Canvas_Line_V) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
dst := image.NewPaletted(image.Rect(0, 0, 3, 8), pal)
gc := canvas.New(dst)
gc.Cls(0)
gc.Color(1)
gc.Line(1, 1, 1, 6)
for y := 0; y < dst.Bounds().Dy(); y++ {
for x := 0; x < dst.Bounds().Dx(); x++ {
if dst.ColorIndexAt(x, y) == 1 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░ ░░▓▓░░ ░░▓▓░░ ░░▓▓░░ ░░▓▓░░ ░░▓▓░░ ░░▓▓░░ ░░░░░░
Example (Canvas_MustLoadFont) ¶
package main
import (
"fmt"
"github.com/lucasepe/doodlekit/internal/canvas"
"github.com/lucasepe/doodlekit/internal/fonts"
)
func main() {
fnt := canvas.MustLoadFont(fonts.Micro())
fmt.Printf("Name: %s\n", fnt.Name)
fmt.Printf("Size: %d\n", fnt.Size)
}
Output: Name: micro Size: -1
Example (Canvas_Print) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
out := image.NewPaletted(image.Rect(0, 0, 21, 5), pal)
gc := canvas.New(out)
gc.Cls(1)
gc.Color(2)
gc.Print("Hello!", 1, 0)
// //gc.Color(7)
// //gc.Rect(0, 0, 3, 4)
// gc.Save("before.gif")
// letH := gc.Smake(0, 0, 3, 5, 12, 15)
// gc.Reset()
// gc.Cls(1)
// gc.Translate(float64(gc.Width())*0.5, float64(gc.Height())*0.5)
// gc.Rotate(0.785398)
// gc.Sput(letH, 0, 0, 0.5, 0.5)
// //gc.Record()
// gc.Save("after.gif")
for y := 0; y < out.Bounds().Dy(); y++ {
for x := 0; x < out.Bounds().Dx(); x++ {
if out.ColorIndexAt(x, y) == 2 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░▓▓░░▓▓░░░░░░░░░░▓▓▓▓░░░░▓▓▓▓░░░░░░░░░░░░ ░░▓▓░░▓▓░░▓▓▓▓▓▓░░░░▓▓░░░░░░▓▓░░░░▓▓▓▓▓▓░░ ░░▓▓▓▓▓▓░░▓▓░░▓▓░░░░▓▓░░░░░░▓▓░░░░▓▓░░▓▓░░ ░░▓▓░░▓▓░░▓▓▓▓░░░░░░▓▓░░░░░░▓▓░░░░▓▓░░▓▓░░ ░░▓▓░░▓▓░░▓▓▓▓▓▓░░░░▓▓░░░░░░▓▓░░░░▓▓▓▓▓▓░░
Example (Canvas_Smake) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
out := image.NewPaletted(image.Rect(0, 0, 16, 10), pal)
gc := canvas.New(out)
gc.Cls(1)
gc.Color(2)
gc.Print("Hi!", 0, 0)
out = gc.Smake(0, 0, 3, 5, 9, 10)
for y := 0; y < out.Bounds().Dy(); y++ {
for x := 0; x < out.Bounds().Dx(); x++ {
if out.ColorIndexAt(x, y) == 2 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ▓▓▓▓▓▓░░░░░░▓▓▓▓▓▓ ▓▓▓▓▓▓░░░░░░▓▓▓▓▓▓ ▓▓▓▓▓▓░░░░░░▓▓▓▓▓▓ ▓▓▓▓▓▓░░░░░░▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓░░░░░░▓▓▓▓▓▓ ▓▓▓▓▓▓░░░░░░▓▓▓▓▓▓ ▓▓▓▓▓▓░░░░░░▓▓▓▓▓▓ ▓▓▓▓▓▓░░░░░░▓▓▓▓▓▓
Example (Canvas_Sput) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
out := image.NewPaletted(image.Rect(0, 0, 22, 12), pal)
gc := canvas.New(out)
gc.Cls(1)
gc.Color(2)
gc.Print("Hi!", 0, 0)
letH := gc.Smake(0, 0, 3, 5, 15, 10)
gc.Cls(1)
gc.Translate(10, 6)
gc.Sput(letH, 0, 0, 0.5, 0.5)
for y := 0; y < out.Bounds().Dy(); y++ {
for x := 0; x < out.Bounds().Dx(); x++ {
if out.ColorIndexAt(x, y) == 2 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Example (Gfx_Rect) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
dst := image.NewPaletted(image.Rect(0, 0, 9, 11), pal)
gc := canvas.New(dst)
gc.Cls(0)
gc.Translate(4, 5)
gc.Color(1)
gc.Rect(-2, -4, 4, 8)
gc.Identity()
for y := 0; y < dst.Bounds().Dy(); y++ {
for x := 0; x < dst.Bounds().Dx(); x++ {
if dst.ColorIndexAt(x, y) == 1 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░░░░░░░░░░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░░░░░░░░░░░░░░░
Example (Gfx_RectFill) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
dst := image.NewPaletted(image.Rect(0, 0, 9, 11), pal)
gc := canvas.New(dst)
gc.Cls(0)
gc.Translate(4, 5)
gc.Color(1)
gc.RectFill(-2, -4, 4, 8)
gc.Identity()
for y := 0; y < dst.Bounds().Dy(); y++ {
for x := 0; x < dst.Bounds().Dx(); x++ {
if dst.ColorIndexAt(x, y) == 1 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░░░░░░░░░░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░░░░░░░░░░░░░░░
Example (Gfx_Rect_2) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
dst := image.NewPaletted(image.Rect(0, 0, 11, 7), pal)
gc := canvas.New(dst)
gc.Cls(0)
gc.Translate(5, 3)
gc.Color(1)
gc.Rect(-4, -2, 8, 4)
gc.Identity()
for y := 0; y < dst.Bounds().Dy(); y++ {
for x := 0; x < dst.Bounds().Dx(); x++ {
if dst.ColorIndexAt(x, y) == 1 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░░░░░░░░░░░░░░░░░ ░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░ ░░▓▓░░░░░░░░░░░░░░▓▓░░ ░░▓▓░░░░░░░░░░░░░░▓▓░░ ░░▓▓░░░░░░░░░░░░░░▓▓░░ ░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░ ░░░░░░░░░░░░░░░░░░░░░░
Example (Gfx_RoundRect) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
dst := image.NewPaletted(image.Rect(0, 0, 17, 11), pal)
gc := canvas.New(dst)
gc.Cls(0)
gc.Translate(8, 5)
gc.Color(1)
gc.RoundRect(-6, -4, 12, 8, 2)
gc.Identity()
for y := 0; y < dst.Bounds().Dy(); y++ {
for x := 0; x < dst.Bounds().Dx(); x++ {
if dst.ColorIndexAt(x, y) == 1 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓░░░░░░░░░░░░░░░░░░▓▓░░░░░░ ░░░░▓▓░░░░░░░░░░░░░░░░░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░░░░░░░░░░░░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░░░░░░░░░░░░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░░░░░░░░░░░░░░░░░▓▓░░░░ ░░░░▓▓░░░░░░░░░░░░░░░░░░░░░░▓▓░░░░ ░░░░░░▓▓░░░░░░░░░░░░░░░░░░▓▓░░░░░░ ░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Example (Gfx_RoundRectFill) ¶
package main
import (
"fmt"
"image"
"image/color"
"github.com/lucasepe/doodlekit/internal/canvas"
)
func main() {
pal := color.Palette{
color.NRGBA{0x00, 0x00, 0x00, 0x00},
color.NRGBA{0x00, 0x00, 0x00, 0xFF},
color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF},
}
dst := image.NewPaletted(image.Rect(0, 0, 17, 11), pal)
gc := canvas.New(dst)
gc.Cls(0)
gc.Translate(8, 5)
gc.Color(1)
gc.RoundRectFill(-6, -4, 12, 8, 2)
gc.Identity()
for y := 0; y < dst.Bounds().Dy(); y++ {
for x := 0; x < dst.Bounds().Dx(); x++ {
if dst.ColorIndexAt(x, y) == 1 {
fmt.Print("▓▓")
} else {
fmt.Print("░░")
}
}
fmt.Println()
}
}
Output: ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░ ░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░ ░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Index ¶
- func Color(p color.Palette, n int) color.NRGBA
- func Fix(x float64) fixed.Int26_6
- func Unfix(x fixed.Int26_6) float64
- func UnfixI(x fixed.Int26_6) int
- type Align
- type Canvas
- func (ctx *Canvas) At(x, y int) int
- func (ctx *Canvas) Circ(x0, y0, r int)
- func (ctx *Canvas) CircFill(x, y, r int)
- func (ctx *Canvas) Cls(idx int)
- func (ctx *Canvas) Color(idx int)
- func (ctx *Canvas) Height() int
- func (dc *Canvas) Identity()
- func (dc *Canvas) InvertY()
- func (ctx *Canvas) Line(x1, y1, x2, y2 int)
- func (ctx *Canvas) MeasureString(s string) (int, int)
- func (ctx *Canvas) Pix(x, y int)
- func (ctx *Canvas) Print(s string, x, y int)
- func (ctx *Canvas) Record()
- func (ctx *Canvas) Rect(x, y, w, h int)
- func (ctx *Canvas) RectFill(x, y, w, h int)
- func (ctx *Canvas) Reset()
- func (ctx *Canvas) Resize(sf int)
- func (dc *Canvas) Rotate(angle float64)
- func (dc *Canvas) RotateAbout(angle, x, y float64)
- func (ctx *Canvas) RoundRect(x, y, w, h, r int)
- func (ctx *Canvas) RoundRectFill(x, y, w, h, r int)
- func (ctx *Canvas) Save(fn string) error
- func (dc *Canvas) Scale(x, y float64)
- func (dc *Canvas) ScaleAbout(sx, sy, x, y float64)
- func (dc *Canvas) Shear(x, y float64)
- func (dc *Canvas) ShearAbout(sx, sy, x, y float64)
- func (ctx *Canvas) Smake(cx, cy, cw, ch, sw, sh int) *image.Paletted
- func (ctx *Canvas) Sput(im *image.Paletted, x, y int, ax, ay float64)
- func (dc *Canvas) TransformPoint(x, y float64) (tx, ty float64)
- func (dc *Canvas) Translate(x, y float64)
- func (ctx *Canvas) Width() int
- type Character
- type Face
- func (f *Face) Close() error
- func (f *Face) Glyph(dot fixed.Point26_6, r rune) (dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ...)
- func (f *Face) GlyphAdvance(r rune) (advance fixed.Int26_6, ok bool)
- func (f *Face) GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool)
- func (f *Face) Kern(_, _ rune) fixed.Int26_6
- func (f *Face) Metrics() font.Metrics
- type Font
- type Matrix
- func (a Matrix) Multiply(b Matrix) Matrix
- func (a Matrix) Rotate(angle float64) Matrix
- func (a Matrix) Scale(x, y float64) Matrix
- func (a Matrix) Shear(x, y float64) Matrix
- func (a Matrix) TransformPoint(x, y float64) (tx, ty float64)
- func (a Matrix) TransformVector(x, y float64) (tx, ty float64)
- func (a Matrix) Translate(x, y float64) Matrix
Examples ¶
- Package (Canvas_Circ)
- Package (Canvas_CircFill)
- Package (Canvas_GlyphBounds)
- Package (Canvas_Line)
- Package (Canvas_Line_H)
- Package (Canvas_Line_V)
- Package (Canvas_MustLoadFont)
- Package (Canvas_Print)
- Package (Canvas_Smake)
- Package (Canvas_Sput)
- Package (Gfx_Rect)
- Package (Gfx_RectFill)
- Package (Gfx_Rect_2)
- Package (Gfx_RoundRect)
- Package (Gfx_RoundRectFill)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
func (*Canvas) Identity ¶
func (dc *Canvas) Identity()
Identity resets the current transformation matrix to the identity matrix. This results in no translating, scaling, rotating, or shearing.
func (*Canvas) InvertY ¶
func (dc *Canvas) InvertY()
InvertY flips the Y axis so that Y grows from bottom to top and Y=0 is at the bottom of the image.
func (*Canvas) Rotate ¶
Rotate updates the current matrix with a anticlockwise rotation. Rotation occurs about the origin. Angle is specified in radians.
func (*Canvas) RotateAbout ¶
RotateAbout updates the current matrix with a anticlockwise rotation. Rotation occurs about the specified point. Angle is specified in radians.
func (*Canvas) RoundRectFill ¶
func (*Canvas) Scale ¶
Scale updates the current matrix with a scaling factor. Scaling occurs about the origin.
func (*Canvas) ScaleAbout ¶
ScaleAbout updates the current matrix with a scaling factor. Scaling occurs about the specified point.
func (*Canvas) Shear ¶
Shear updates the current matrix with a shearing angle. Shearing occurs about the origin.
func (*Canvas) ShearAbout ¶
ShearAbout updates the current matrix with a shearing angle. Shearing occurs about the specified point.
func (*Canvas) Smake ¶ added in v0.2.0
Smake creates a sprite from the specified rect on canvas. The sprits can be stretched if sw and/or sh are > 0.
cx: x coordinate of the upper left corner of the rectangle in the canvas. cy: y coordinate of the upper left corner of the rectangle in the canvas. cw: width of the rectangle in the canvas, as a number of pixels. ch: height of the rectangle in the canvas, as a number of pixels.
sw: width of the sprite. sh: height of sprite.
func (*Canvas) Sput ¶ added in v0.2.0
Sput draws the specified image at the specified anchor point. The anchor point is x - w * ax, y - h * ay, where w, h is the size of the image. Use ax=0.5, ay=0.5 to center the image at the specified point.
func (*Canvas) TransformPoint ¶
TransformPoint multiplies the specified point by the current matrix, returning a transformed position.
type Font ¶
type Font struct {
Name string
Size int
PixelSize int
DPI [2]int
BPP int
Ascent int
Descent int
CapHeight int
XHeight int
Characters []Character
CharMap map[rune]*Character
Encoding string
DefaultChar rune
}
func MustLoadFont ¶
type Matrix ¶
type Matrix struct {
XX, YX, XY, YY, X0, Y0 float64
}