func pixel_is_light(img *image.Paletted, x int, y int) bool { r, g, b, _ := img.At(x, y).RGBA() sum := r + g + b return (sum > 0x18000) && (sum < 0x2e000) }
func debarf_frame(frame *image.Paletted) error { xmin := frame.Rect.Min.X ymin := frame.Rect.Min.Y xmax := frame.Rect.Max.X ymax := frame.Rect.Max.Y for y := ymin; y < ymax; y++ { for x := xmin; x < xmax; x++ { c := frame.At(x, y) r, g, b, a := c.RGBA() if pixel_is_transparent(frame, x, y) { fmt.Printf("...") frame.Set(x, y, color.RGBA64{uint16(r), uint16(g), uint16(b), 0xffff}) } else if should_turn_pixel_transparent(frame, x, y) { fmt.Printf("xxx") frame.Set(x, y, color.RGBA64{0, 0, 0, 0xffff}) } else { r /= 0x1000 g /= 0x1000 b /= 0x1000 if a != 0xffff { fmt.Printf("barf") } fmt.Printf("%x%x%x", r, g, b) } } fmt.Printf("\n") } return nil }
func pixel_is_transparent(img *image.Paletted, x int, y int) bool { _, _, _, a := img.At(x, y).RGBA() return a == 0 }