Top 10 API changes that you will hate #7
tinne26
announced in
Announcements
Replies: 2 comments
-
A few more ideas:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Progress update I've made some progress in the last months, so I'm writing an update as an exercise for myself. My memory is terrible and this helps me know where I am. The docs for the still incomplete alpha can be previewed at https://pkg.go.dev/github.com/tinne26/[email protected]. There have been multiple interesting decisions and changes from what I initially planned:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm publicly listing some planned API changes in case people have any opinions. If you have any opinions regarding other parts of the library that you also consider relevant, now it's a good time to speak so I can consider them.
NewStdRenderer()
andNewRenderer(rast)
intoNewRenderer(arguments ...any)
. This is the most controversial change as it affects almost all users of the library, and using variadic args is not particularly loved by the community, but it allows shorter init, I'll add a special flagCache16MiB
for simpler automatic cache initialization, can pass the rasterizer, sizer, font, color, size, align and more right away, etc. May not be very type safe, may not be very beautiful, but it's practical. Worst case, you keep using it without arguments and then use the manual setters.NewDefaultCache()
given the newCache16MiB
flag, and leave only theecache.NewDefaultCache()
version.QuantizationMode
with aRenderer.SetQuantizeStep()
, so we don't only have full or no quantization, but can compromise at any value in between.SelectionRectAt(text, x, y)
, because we need to allow passing the exact fractional positioning or precision losses can easily accumulate after each glyph advance + quantization. I'm also considering renamingSelectionRect
toMeasure
. I preferredSelectionRect
due to being more technically accurate and explicit, but at the end of the day it may not matter and we may prefer a shorter name. Also,renderer.Fract.MeasureAt()
sounds better to me thanrenderer.Fract.SelectionRectAt()
, which starts to get just a bit too long.fixed.Int26_6
values under a newfract.Pixel
andfract.Rect
model. Basically,etxt/fract
will replaceetxt/efixed
, but will become much more prominent too. Since the ugly internal-sounding names will be gone, I think this will make more sense to everyone.fract.Rect
, that will become the return value ofSelectionRect
/Measure
, andRectSize
will disappear.Renderer
:Renderer.Fract
andRenderer.Glyph
. These will have their own types and will provide access to fractional-pixel and glyph index operations respectively. Instead ofRenderer.Draw()
andRenderer.DrawFract()
, we will haveRenderer.Draw()
andRenderer.Fract.Draw()
. Same for size, traverse, selectionRect/measure and a few others. For glyphs, this will also be much cleaner, and some of the most internal-sounding operations likeLoadGlyphMask
andDefaultDrawFunc
will becomerenderer.Glyph.LoadMask()
andrenderer.Glyph.DrawGlyph()
. I think the organization of the documentation should be significantly improved, and these more advanced operations will clutter the mainRenderer
documentation much less. Also, glyphs will have a proper place and I can delete theeglyr
subpackage, which I don't love.SetSizePx()
to simplySetSize()
. I don't know why, but under the more structured model I like it more.SetScaling()
and have display scaling support be directly provided in the renderer. This will allow usingSetSize()
with logical sizes and have to do less conversions when working, creating a simple path for people to do HiDPI right. Two display scaling modes,ScaleFract
(fract.Pixel
based) andScaleNear
(int
based) will be added and supported inNewRenderer(...)
. So, proper cached, HiDPI rendering will be more easily available by simply callingNewRenderer(etxt.Cache16MiB, etxt.ScaleFract)
.GlyphShader
,LineShader
andBlockShader
under a new subpackage, which will make rendering text with shaders applied significantly more straightforward. Also, multiple kage shaders will be embedded and ready to use.\color[args]{content}
,\bold{content}
,\size[args]{content}
,\italics{content}
, etc), do basic line wrapping and that stuff, but this won't happen for the initial big change yet.Beta Was this translation helpful? Give feedback.
All reactions