Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions _examples/imagebug/firefly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
author_id = "demo"
app_id = "go-imagebug"
author_name = "Demo"
app_name = "Image bug Demo (Go)"

[files]
img = { path = "image.png" }
9 changes: 9 additions & 0 deletions _examples/imagebug/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module demoimage

go 1.24.0

replace github.com/firefly-zero/firefly-go => ../../

require github.com/firefly-zero/firefly-go v0.14.0

require github.com/orsinium-labs/tinymath v1.2.0 // indirect
2 changes: 2 additions & 0 deletions _examples/imagebug/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/orsinium-labs/tinymath v1.2.0 h1:mxbQzDQz00XQvPqPmIRCgXvYMyPCgCng1kYWfvjXr6M=
github.com/orsinium-labs/tinymath v1.2.0/go.mod h1:WPXX6ei3KSXG7JfA03a+ekCYaY9SWN4I+JRl2p6ck+A=
42 changes: 42 additions & 0 deletions _examples/imagebug/image.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import "github.com/firefly-zero/firefly-go/firefly"

func init() {
firefly.Boot = boot
firefly.Update = update
firefly.Render = render
}

var (
image firefly.Image
subimage firefly.SubImage
showImage bool
oldButtons firefly.Buttons
)

func boot() {
// img is 240x160
image = firefly.LoadFile("img", nil).Image()
subimage = image.Sub(firefly.P(0, 0), firefly.S(240, 160))
}

func update() {
buttons := firefly.ReadButtons(firefly.Combined)
if buttons.JustPressed(oldButtons).Any() {
showImage = !showImage
}
oldButtons = buttons
}

func render() {
firefly.ClearScreen(firefly.ColorWhite)

if showImage {
// Full image works:
image.Draw(firefly.Point{X: 0, Y: 16})
} else {
// But drawing sub-image fails:
subimage.Draw(firefly.Point{X: 0, Y: 16})
}
}
Binary file added _examples/imagebug/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading