Initial release: Go Jdenticon library v0.1.0
- Core library with SVG and PNG generation - CLI tool with generate and batch commands - Cross-platform path handling for Windows compatibility - Comprehensive test suite with integration tests
This commit is contained in:
@@ -1,61 +1,5 @@
|
||||
package engine
|
||||
|
||||
import "math"
|
||||
|
||||
// Matrix represents a 2D transformation matrix in the form:
|
||||
// | A C E |
|
||||
// | B D F |
|
||||
// | 0 0 1 |
|
||||
type Matrix struct {
|
||||
A, B, C, D, E, F float64
|
||||
}
|
||||
|
||||
// NewIdentityMatrix creates an identity matrix
|
||||
func NewIdentityMatrix() Matrix {
|
||||
return Matrix{
|
||||
A: 1, B: 0, C: 0,
|
||||
D: 1, E: 0, F: 0,
|
||||
}
|
||||
}
|
||||
|
||||
// Translate creates a translation matrix
|
||||
func Translate(x, y float64) Matrix {
|
||||
return Matrix{
|
||||
A: 1, B: 0, C: 0,
|
||||
D: 1, E: x, F: y,
|
||||
}
|
||||
}
|
||||
|
||||
// Rotate creates a rotation matrix for the given angle in radians
|
||||
func Rotate(angle float64) Matrix {
|
||||
cos := math.Cos(angle)
|
||||
sin := math.Sin(angle)
|
||||
return Matrix{
|
||||
A: cos, B: sin, C: -sin,
|
||||
D: cos, E: 0, F: 0,
|
||||
}
|
||||
}
|
||||
|
||||
// Scale creates a scaling matrix
|
||||
func Scale(sx, sy float64) Matrix {
|
||||
return Matrix{
|
||||
A: sx, B: 0, C: 0,
|
||||
D: sy, E: 0, F: 0,
|
||||
}
|
||||
}
|
||||
|
||||
// Multiply multiplies two matrices
|
||||
func (m Matrix) Multiply(other Matrix) Matrix {
|
||||
return Matrix{
|
||||
A: m.A*other.A + m.C*other.B,
|
||||
B: m.B*other.A + m.D*other.B,
|
||||
C: m.A*other.C + m.C*other.D,
|
||||
D: m.B*other.C + m.D*other.D,
|
||||
E: m.A*other.E + m.C*other.F + m.E,
|
||||
F: m.B*other.E + m.D*other.F + m.F,
|
||||
}
|
||||
}
|
||||
|
||||
// Transform represents a geometric transformation
|
||||
type Transform struct {
|
||||
x, y, size float64
|
||||
@@ -91,13 +35,5 @@ func (t Transform) TransformIconPoint(x, y, w, h float64) Point {
|
||||
}
|
||||
}
|
||||
|
||||
// ApplyTransform applies a transformation matrix to a point
|
||||
func ApplyTransform(point Point, matrix Matrix) Point {
|
||||
return Point{
|
||||
X: matrix.A*point.X + matrix.C*point.Y + matrix.E,
|
||||
Y: matrix.B*point.X + matrix.D*point.Y + matrix.F,
|
||||
}
|
||||
}
|
||||
|
||||
// NoTransform represents an identity transformation
|
||||
var NoTransform = NewTransform(0, 0, 0, 0)
|
||||
var NoTransform = NewTransform(0, 0, 0, 0)
|
||||
|
||||
Reference in New Issue
Block a user