imggg - go's image generic geometrics, reimplements image.Point
and image.Rectangle
to work with any number type you want: int
, int8
, int16
, int32
, int64
, float32
, float64
, uint
, uint8
, uint16
, uint32
, uint64
, uintptr
, instead of just int
.
Features:
- All the same methods and functions as
image
, the code is modified directly from https://go.dev/src/image/geom.go. - Cast them back to the standard library equivalent with the
Std()
method. - Get X and Y of a point as two variables quickly with the
XY()
method. - Multiply a point by another point with the
MulPt()
method.
Library made for the egriden game framework. .
Note
Using points and rectangles with floats changes their logic from the intentions of the image library, read more on The Go Blog about the package.
Warning
Operations on unsigned integers is not tested, just try not to underflow things.
package main
import (
"github.com/greenthepear/imggg"
"image"
)
func main(){
// Be implicit
floatPoint1 := imggg.Pt[float64](0.2,0.1)
// Let the compiler figure it out
floatPoint2 := imggg.Pt(1.6,2.2)
// Use the classic methods
rec := imggg.Rectangle[float64]{
floatPoint1.Mul(10),
floatPoint2.Div(0.1),
} // (2,1)-(16,22)
// Work with the standard library
img := image.NewRGNA(
rec.Std()
)
...
}
Do what you want with this, to be fancy I chose the 0BSD license.
Uses Go source code, Copyright 2010 The Go Authors. All rights reserved: LICENSE