Add som drawing functions #3
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I just write notes. We will add missing prototypes latter.
Usefull
Probably useless but "classicals"
dsubimage
)I think most of these functions would deserve a full, independent graphing library, much like MonochromeLib. The problem here is that most of the time there's an enormous amount of parameters, which can be specified in multiple ways :
Currently gint only uses parameter-based specifications and so the only solution for now would be the painful one, which... is not a good idea.
I'm considering a way of implementing non-trivial "pen" and "fill" objects. This would allow me to have gint drawing functions with many parameters, and allow you to call them without specifying everything. Please give me some time to plan this change.
In any case, let's start with feasibility and API concerns :
This would be possible to a certain extent on fx-CG 50, but ultimately I think the best way to do this is just to generate the sprites you need at compile-time. This preserves performance which is much needed on fx-CG 50.
Same for text, if really needed I can implement a vertical-string mode and then you could use a manually-rotated font.
Rectangle with border is no problem. The border size could probably be configured as well.
A dashed line with configurable patterns feels too fancy to be in the gint core. Also, there's an awful lot of parameters here, including line endings, pattern speification, dots vs line, line width, etc.
Text placement is possible, I'll consider a way of specifying in
dtext()
that parametersx
andy
represent the position of another corner than the top-left one.We already talked about horizontal and vertical lines, so I implemented
dhline()
anddvline()
that do the same as the Basic commandsHorizontal
andVertical
in an optimized way (commitef0e5e3
).Is a square really needed? You only save one parameter out of 4 plus the color specification. x_x
Tile drawing would have much more parameters than that, starting with the distance which may not be 1px depending on the user. For instance on fx-CG 50, 1px is definitely too short.
I'm coming back to this now with a more concrete plan.
First off, image operations are now available through libimg, a library that manipulates a plain image format that is a lot more versatile than bopti (while also being a lot less efficient on fx-9860G). This leaves use with more basic geometry.
My plan is to have reasonable extensions to the current drawing API while keeping things short. I would like to:
drect()
.dtext()
anddprint()
, because most of the time bg isC_NONE
and it shouldn't be necessary to specify that.dtext()
anddprint()
at the same time.I have a way to make this work reasonably well without additional work. The idea is to use a transparent union so that the user may equally provide a simple color name, or a full structure with more parameters.
I also added a bit of preprocessor wizardry to make the pen specification easier.
I'm still unsure as to how advanced gint's drawing should be. Currently it is drastically limited by its ability to write only to VRAM rather than general surfaces, but something more versatile would definitely not count as kernel stuff and is probably suited for a library.
After thinking this through for a few more hours, I'll leave the optional argument trick for another time and use other function names. I don't want to expand on the drawing API too much, but this should be enough.
drect_border()
function for rectangles with borders.dtext_opt()
anddprint_opt()
that have both fg/bg and alignment options.dtext()
anddprint()
to have only fg.Let's recap :
See in libimg.
Not possible with topti fonts on fx9860g, at best I could do a vertical text mode and you'd have to convert fonts again. But this is already a niche for something to put in the kernel itself.
drect_border()
lets you choose both border width and color.Too many parameters here, doing this properly would require an immense API.
Added through
dtext_opt()
anddprint_opt()
.dhline()
anddvline()
will do asHorizontal
andVertical
in Basic, for other horizontal/vertical lines usedline()
withy1=y2
/x1=x2
.Not very interesting, you just save 1 parameter out of 7.
Seems very application-specific, there are many ways to arrange a tileset, not always with only 1px of space between tiles. If it's just a shortcut it's better to add it in your own util file.
I'll be closing this now and pushing the changes shortly. Any remarks are still welcome ^^