Compare commits
No commits in common. "9214f70b617f9239216746c34bdc7f0aa9a1110c" and "9dc929f5453251975e411785e648e800949ec97b" have entirely different histories.
9214f70b61
...
9dc929f545
12
box.go
12
box.go
@ -339,14 +339,10 @@ func (this *box) Draw (can canvas.Canvas) {
|
|||||||
// centered texture
|
// centered texture
|
||||||
if this.textureMode == textureModeCenter {
|
if this.textureMode == textureModeCenter {
|
||||||
textureBounds := this.texture.Bounds()
|
textureBounds := this.texture.Bounds()
|
||||||
textureOrigin :=
|
textureOrigin := image.Pt (
|
||||||
bounds.Min.
|
textureBounds.Dx() / -2,
|
||||||
Add(image.Pt (
|
textureBounds.Dy() / -2).
|
||||||
bounds.Dx() / 2,
|
Add(bounds.Min)
|
||||||
bounds.Dy() / 2)).
|
|
||||||
Sub(image.Pt (
|
|
||||||
textureBounds.Dx() / 2,
|
|
||||||
textureBounds.Dy() / 2))
|
|
||||||
|
|
||||||
pen.Fill(color.Transparent)
|
pen.Fill(color.Transparent)
|
||||||
pen.Texture(this.texture)
|
pen.Texture(this.texture)
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import "image"
|
|
||||||
import "git.tebibyte.media/tomo/x"
|
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
|
||||||
|
|
||||||
func main () {
|
|
||||||
tomo.Register(0, x.NewBackend)
|
|
||||||
err := tomo.Run(run)
|
|
||||||
if err != nil { panic(err) }
|
|
||||||
}
|
|
||||||
|
|
||||||
func run () {
|
|
||||||
window, err := tomo.NewWindow(image.Rect(0, 0, 200, 300))
|
|
||||||
if err != nil { panic(err) }
|
|
||||||
window.OnClose(tomo.Stop)
|
|
||||||
window.SetVisible(true)
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import "image"
|
|
||||||
import "image/color"
|
|
||||||
import "git.tebibyte.media/tomo/x"
|
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
|
||||||
import "golang.org/x/image/font/basicfont"
|
|
||||||
|
|
||||||
func main () {
|
|
||||||
tomo.Register(0, x.NewBackend)
|
|
||||||
err := tomo.Run(run)
|
|
||||||
if err != nil { panic(err) }
|
|
||||||
}
|
|
||||||
|
|
||||||
func run () {
|
|
||||||
window, err := tomo.NewWindow(image.Rectangle { })
|
|
||||||
if err != nil { panic(err) }
|
|
||||||
|
|
||||||
text := tomo.NewTextBox()
|
|
||||||
text.SetText("hello, world!")
|
|
||||||
text.SetTextColor(color.White)
|
|
||||||
text.SetColor(color.Black)
|
|
||||||
text.SetFace(basicfont.Face7x13)
|
|
||||||
text.SetPadding(tomo.I(8))
|
|
||||||
window.SetRoot(text)
|
|
||||||
|
|
||||||
window.OnClose(tomo.Stop)
|
|
||||||
window.SetVisible(true)
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import "math"
|
|
||||||
import "image"
|
|
||||||
import "math/rand"
|
|
||||||
import "image/color"
|
|
||||||
import "git.tebibyte.media/tomo/x"
|
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
|
||||||
|
|
||||||
func main () {
|
|
||||||
tomo.Register(0, x.NewBackend)
|
|
||||||
err := tomo.Run(run)
|
|
||||||
if err != nil { panic(err) }
|
|
||||||
}
|
|
||||||
|
|
||||||
func run () {
|
|
||||||
window, err := tomo.NewWindow(image.Rect(0, 0, 256, 256))
|
|
||||||
if err != nil { panic(err) }
|
|
||||||
|
|
||||||
texture := tomo.NewTexture(coolTexture())
|
|
||||||
|
|
||||||
box := tomo.NewBox()
|
|
||||||
box.SetColor(color.Black)
|
|
||||||
box.SetTextureCenter(texture)
|
|
||||||
box.SetBorder (
|
|
||||||
tomo.Border {
|
|
||||||
Color: [4] color.Color {
|
|
||||||
color.Black, color.Black,
|
|
||||||
color.Black, color.Black },
|
|
||||||
Width: tomo.I(2),
|
|
||||||
},
|
|
||||||
tomo.Border {
|
|
||||||
Color: [4] color.Color {
|
|
||||||
color.White, color.White,
|
|
||||||
color.White, color.White },
|
|
||||||
Width: tomo.I(2),
|
|
||||||
})
|
|
||||||
|
|
||||||
window.SetRoot(box)
|
|
||||||
window.OnClose(tomo.Stop)
|
|
||||||
window.SetVisible(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func coolTexture () image.Image {
|
|
||||||
// this picture IS COOL because i spent AN HOUR on it when i could have
|
|
||||||
// been FIXING BUGS!
|
|
||||||
speedX := 0.015
|
|
||||||
speedY := 0.035
|
|
||||||
bitmap := image.NewRGBA (image.Rect(0, 0, 200, 200))
|
|
||||||
for y := bitmap.Bounds().Min.Y; y < bitmap.Bounds().Max.Y; y++ {
|
|
||||||
for x := bitmap.Bounds().Min.X; x < bitmap.Bounds().Max.X; x++ {
|
|
||||||
value := ((
|
|
||||||
math.Sin(float64(y) * speedY) +
|
|
||||||
math.Cos(float64(x) * speedX)) + 2) / 4
|
|
||||||
value *= 0.7
|
|
||||||
|
|
||||||
r := value * 0.7 + 0.3
|
|
||||||
g := math.Sin(value * 7) * 0.7
|
|
||||||
b := (1 - value) * 0.7
|
|
||||||
|
|
||||||
noise := math.Mod(rand.Float64(), 1)
|
|
||||||
noise = math.Pow(noise, 2) + noise * 0.5
|
|
||||||
noise *= 0.05
|
|
||||||
|
|
||||||
channel := func (f float64) uint8 {
|
|
||||||
contrast := 1.4
|
|
||||||
f = f * (contrast) - ((contrast - 1) / 2)
|
|
||||||
|
|
||||||
if f < 0 { f = 0 }
|
|
||||||
if f > 1 { f = 1 }
|
|
||||||
|
|
||||||
return uint8(f * 255)
|
|
||||||
}
|
|
||||||
|
|
||||||
bitmap.Set(x, y, color.RGBA {
|
|
||||||
R: channel(r + noise),
|
|
||||||
G: channel(g + noise),
|
|
||||||
B: channel(b + noise),
|
|
||||||
A: 255,
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
return bitmap
|
|
||||||
}
|
|
@ -241,9 +241,7 @@ func (window *window) afterEvent () {
|
|||||||
// set child bounds
|
// set child bounds
|
||||||
childBounds := window.metrics.bounds
|
childBounds := window.metrics.bounds
|
||||||
childBounds = childBounds.Sub(childBounds.Min)
|
childBounds = childBounds.Sub(childBounds.Min)
|
||||||
if window.root != nil {
|
window.root.SetBounds(childBounds)
|
||||||
window.root.SetBounds(childBounds)
|
|
||||||
}
|
|
||||||
|
|
||||||
// full relayout/redraw
|
// full relayout/redraw
|
||||||
if window.root != nil {
|
if window.root != nil {
|
||||||
|
Reference in New Issue
Block a user