Skip to content

Commit 4e1abbf

Browse files
committed
Add go module support, update import path
1 parent 0846d5e commit 4e1abbf

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

canvas.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ func (c *Canvas) CurrentMode() (*DisplayMode, error) {
457457
dm.VMode = int(v.vmode)
458458

459459
var pf PixelFormat
460-
pf.Depth = uint8(v.bits_per_pixel)
460+
pf.Depth = uint8(v.bitsPerPixel)
461461
pf.RedBits = uint8(v.red.length)
462462
pf.RedShift = uint8(v.red.offset)
463463
pf.GreenBits = uint8(v.green.length)

examples/simpleapp/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"os"
1414
"os/signal"
1515

16-
"github.com/samuel/framebuffer"
16+
"github.com/synthread/framebuffer"
1717
)
1818

1919
func main() {

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/synthread/framebuffer
2+
3+
go 1.21.7

go.sum

Whitespace-only changes.

pixelformat.go

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,35 @@ const (
2121
//
2222
// For example, a standard RGBA pixel would look like this:
2323
//
24-
// | bit 31 bit 0 |
25-
// | |
26-
// pixel: rrrrrrrrggggggggbbbbbbbbaaaaaaaa
24+
// | bit 31 bit 0 |
25+
// | |
26+
// pixel: rrrrrrrrggggggggbbbbbbbbaaaaaaaa
2727
//
2828
// The PixelFormat for this looks as follows:
2929
//
30-
// red bits: 8
31-
// red shift: 24
30+
// red bits: 8
31+
// red shift: 24
3232
//
33-
// green bits: 8
34-
// green shift: 16
33+
// green bits: 8
34+
// green shift: 16
3535
//
36-
// blue bits: 8
37-
// blue shift: 8
38-
//
39-
// alpha bits: 8
40-
// alpha shift: 0
36+
// blue bits: 8
37+
// blue shift: 8
4138
//
39+
// alpha bits: 8
40+
// alpha shift: 0
4241
//
4342
// We can extract the channel information as follows:
4443
//
45-
// red_mask := (1 << red_bits) - 1
46-
// green_mask := (1 << green_bits) - 1
47-
// blue_mask := (1 << blue_bits) - 1
48-
// alpha_mask := (1 << alpha_bits) - 1
49-
//
50-
// r := (pixel >> red_shift) & red_mask
51-
// g := (pixel >> green_shift) & green_mask
52-
// b := (pixel >> blue_shift) & blue_mask
53-
// a := (pixel >> alpha_shift) & alpha_mask
44+
// red_mask := (1 << red_bits) - 1
45+
// green_mask := (1 << green_bits) - 1
46+
// blue_mask := (1 << blue_bits) - 1
47+
// alpha_mask := (1 << alpha_bits) - 1
5448
//
49+
// r := (pixel >> red_shift) & red_mask
50+
// g := (pixel >> green_shift) & green_mask
51+
// b := (pixel >> blue_shift) & blue_mask
52+
// a := (pixel >> alpha_shift) & alpha_mask
5553
type PixelFormat struct {
5654
Depth uint8 // Total bit count for each pixel.
5755
RedBits uint8 // Bit count for the red channel.
@@ -66,7 +64,7 @@ type PixelFormat struct {
6664

6765
// Stride returns the width, in bytes, for a single pixel.
6866
func (p PixelFormat) Stride() int {
69-
return (p.Depth + 7) / 8
67+
return int((p.Depth + 7) / 8)
7068
}
7169

7270
// Type returns an integer constant from the PF_XXX list, which

0 commit comments

Comments
 (0)