Composite literal uses unkeyed fields
Hi Patricio
I agree with the way you are doing the SDF function types as I was wrapping the SDFX functions to get the same effect. I am having a go at porting sdfx-ui to using sdf.
I am using go 1.18 and go vet complains about composite literal using unkeyed fields.
So I am testing adding // New func to replace composite literal construction with unkeyed fields func NewV2(x, y float64) r2.Vec { return r2.Vec{X: x, Y: y} } to vector.gox`x
So the code changes (example of old and new): v[1] = NewV2(a.Max.X, a.Min.Y) // br v[2] = r2.Vec{a.Min.X, a.Max.Y} // tl
If you think it is a good idea I will try and create pull request when I am done.
Hey there! I've wanted to fix this issue for some time now in this module.
That said I think adding a function to this codebase is just noise. Users should implement their code using the r2 package as is. If they prefer to solve this via a user implemented function or adding field tags,that should be up to them.
Also an opinionof mine: there should be prefferably one way of declaring an r2Vec, and to me it seems r2.Vec{} is good enough. Short and self documenting.
If you want to fix these vet errors in sdf by adding the field tags I'd be very grateful!
Ok I fixed it mostly the other way round. The regex to replace them is easier. I will have bash at doing them other way round.
I should really learn regexes heh. By the way, this project might interest you https://github.com/soypat/sdf3ui.
That was great and works really well. I was wondering about bringing though colours, OpenScad can do this. It works for construction objects and highlighting parts. Thanks for the star but I am deleting my effort as my printer is now printing the stacking adaptor for bowls that I was trying to create.
Colors are a must have for the future. I've already given it bare-minimum thought for STL generation:
// Attributes contains all model attribute data.
type Attributes struct {
// main color
Color color.Color
SecondaryColor color.Color
}
// Attribute sets a single or various attributes of an Attributes type
type Attribute func(*Attributes)
// Probably worth storing this under a package, maybe helpers/attr
func AttrColor(c color.Color) Attribute {
return func(a *Attributes) { a.Color = c }
}
// Refactor CreateSTL with non-breaking changes
func CreateSTL(path string, r Renderer, attrs ...Attribute) error {
// loop over attrs and set a new Attributes struct
}
By the way, I'd like to warn you breaking changes are incoming as soon as https://github.com/gonum/gonum/issues/1791 is resolved. This would replace the d3.Box, render.Triangle3 and d2.Box types with their respective gonum types. This change would allow users to work with the Box types freely in their code. The Triangle type would further decouple the render package and make the Renderer interface more flexible and dependable as the Triangle type would be tied to a solid, trusted and tested library.
Moving development to https://github.com/soypat/gsdf. Closing all issues here.