Closed orwell96 closed 5 years ago
This could be done with image elements
I think an image drawing library (like cairo) would be better suited for this job.
~Formspec element positioning is so weird and buggy i don't think this would be usable for drawing anything as the elements couldn't be aligned. -1~
You can't draw arbitrary length diagonal lines with images because you can't rotate them except in multiples of 90 degrees. Stretching an image of a diagonal line will change the line's width. Same with circles, you can't get an arbitrary radius / line width circle without making a new image for every circle, which may not be possible if you are dynamically deciding these parameters.
Wouldn't #8524 solve your concern about coordinates being weird?
Related: #8549
Couldn't drawing primitives be done with vector graphics? (Related: #2419)
I think dynamic images (like ^[combine
, but actually designed for dynamically created images) would be a better solution to this problem. The main problem with ^[combine
is that it fills up the cache on the client after a while, making it non-feasible for something that can change constantly.
Dynamically-created images would be killing two birds with one stone -- both entities and formspecs could have dynamic images. You could also place the image on both an entity and a formspec (think placing the rail map on both the formspec and somewhere in the train entity).
How do you imagine I would draw a diagonal line of arbitrary length? I think one way it could be solved is with rotation modifiers other than in multiples of 90 degrees, but maybe you have something else in mind.
@DS-Minetest I think vector graphics would have the same problem with diagonal lines I mentioned in https://github.com/minetest/minetest/issues/8087#issuecomment-455709451
EDIT: Assuming that "using vector graphics" means "using SVG files" like the linked issue is about.
How do you imagine I would draw a diagonal line of arbitrary length? I think one way it could be solved is with rotation modifiers other than in multiples of 90 degrees, but maybe you have something else in mind.
By dynamic images, I mean images that you actually create. You would draw directly to pixels, and, if an API was created, probably lines, circles, and suchlike. I'm not speaking of modifying/rotating existing images, I mean making new ones entirely with the possibility to combine with existing images. There are a few issues for this.
Oh, I see. That doesn't sound very efficient if you wanted to draw a very long diagonal line, since you would need to draw and store a texture with size quadratic in the length of the line. With a line primitive the engine could just use two triangles to draw the line and the rasterizer would just need to fill in the pixels along the line instead of a huge square bounding the line.
Deleted my comment as formspec coordinates have been improved. However i still don't like the idea and it is disapproved by 2 other core devs.
@rubenwardy's disapproval is based on a false premise (that this feature is possible with image elements). For example, it is not possible to draw uniform length diagonal lines with procedural length and width.
Issue type
Summary
Unlike #6805, which is for in-world drawing.
Formspecs currently feature the box[] element to draw a colored rectangle. You can draw horizontal and vertical lines using this, too. However, I would like to draw polylines or other primitive shapes that may be diagonal. This would allow, for example, for creating in-game road/railway mappers.
If a replacement for the formspec language should be implemented, I would be fine with it implemented there.