-
Notifications
You must be signed in to change notification settings - Fork 43
Clarify restrictions on fill patterns. #3789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
maltelenz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are libraries out there that use this, and it is clearly useful, so removing this feature is not reasonable.
Example usage of HorizontalCylinder on a Polygon:
model Package
annotation(
Icon(
coordinateSystem(extent = {{-100, -100}, {100, 100}}, grid = {10, 10}),
graphics = {
Polygon(origin = {0.248, 0.044}, lineColor = {56, 56, 56}, fillColor = {128, 202, 255}, fillPattern = FillPattern.Solid, points = {{99.752, 100}, {99.752, 59.956}, {99.752, -50}, {100, -100}, {49.752, -100}, {-19.752, -100.044}, {-100.248, -100}, {-100.248, -50}, {-90.248, 29.956}, {-90.248, 79.956}, {-40.248, 79.956}, {-20.138, 79.813}, {-0.248, 79.956}, {19.752, 99.956}, {39.752, 99.956}, {59.752, 99.956}}, smooth = Smooth.Bezier),
Polygon(origin = {0, -13.079}, lineColor = {192, 192, 192}, fillColor = {255, 255, 255}, pattern = LinePattern.None, fillPattern = FillPattern.HorizontalCylinder, points = {{100, -86.921}, {50, -86.921}, {-50, -86.921}, {-100, -86.921}, {-100, -36.921}, {-100, 53.079}, {-100, 103.079}, {-50, 103.079}, {0, 103.079}, {20, 83.079}, {50, 83.079}, {100, 83.079}, {100, 33.079}, {100, -36.921}}, smooth = Smooth.Bezier),
Polygon(origin = {0, -10.704}, lineColor = {113, 113, 113}, fillColor = {255, 255, 255}, points = {{100, -89.296}, {50, -89.296}, {-50, -89.296}, {-100, -89.296}, {-100, -39.296}, {-100, 50.704}, {-100, 100.704}, {-50, 100.704}, {0, 100.704}, {20, 80.704}, {50, 80.704}, {100, 80.704}, {100, 30.704}, {100, -39.296}}, smooth = Smooth.Bezier)
}
)
);
end Package;
|
The best way to proceed might then be to let the tools that have implemented this describe what they do, so that we can see if the implementations have something in common that we can agree upon? |
|
We have libraries using these fill patterns on polygons. Why would we restrict/remove something that clearly is useful? |
Ok, making a table based on what I assume:
It seems that the only potentially missing feature is spherical gradient for polygons, and it shouldn't be that difficult to support. |
|
System Modeler also supports sphere fills on Polygons. |
|
For sphere fill on polygons, System Modeler does: |
|
Just wondering, but wouldn't it make sense if the center and radius of the If the center is defined so that it transforms naturally with the shape, it is natural to define the radius as the distance from the center to the controlling point furtherest away (simpler math compared to the distance to the point furtherest away on the curve delimiting the shape). One simple definition of the center is to use the origin in the local coordinates of the shape. This also has the advantage that the user can select where to put the center. Another option is to define the center as the center of mass of the polygon with vertices at the controlling points (simpler math compared to the center of mass of the curve delimiting the shape). For @d-hedberg's example of an equilateral triangle in #3789 (comment), this would result in the same color at all three corners of the triangle, no matter how it is rotated. |
|
Please don't take #3789 (comment) as a concrete proposal; it has several drawbacks:
One thing that I believe might help us reach agreement would be to introduce a However, when thinking more about how to define the "gradient length", I realized that it wasn't clear to me how Interpretations:
|
Yes, sphere-gradient and non-circles (including ellipses) is a problem. I say that "A", i.e., sphere-gradient on a circle stretched to make it an ellipse is the most intuitive - but I have no idea how to easily generalize it to polygons. |
|
If we are not sure exactly what to do, it might also help to take a look at SVG. A Modelica
(SVG makes the interpretation A in #3789 (comment).) |
I would say that you need something equivalent to an ellipse to define the gradient, and then you can clip it to any desired shape. For a However, note that even if defining a default for the specification is a nasty problem, making the Edit: Note that in comparison to SVG, SVG has a generic |
Do you also have an easy way to find applications of |
|
Looking more I realize that there are two additional issues with gradients, with relevant icons in MSL:
|
Yes. First I thought you had implemented the generalization to draw rays with a color gradient, each ray starting at the center and ending at the periphery, but then I saw the lighter "X" pattern which proved me wrong. |
Sounds very reasonable to me. |
|
Can you made an example model of all cases which other tools can load and show how they render patterns. This is how OpenModelica renders the example given here #3789 (review) For
For
|
|
This is more or less the model I used in #3789 (comment): |
This one gives,
|
Dymola 2026x generates the following (which I like):
|
I zoomed in, and it is not an optical illusion; the level curves of equal color are bent near the left end of the cylinder. Makes you wonder what is going on behind that gray connector… Any similar effects on a rectangle without rounded corners? |
There shouldn't be. I know what could cause it specifically for rounded corners, but didn't investigate it enough. |
|
With so much variation between tools in the looks of these gradients, maybe we better just conclude that the specification failed pretty badly this time by introducing all these underspecified ways of filling shapes. Instead of seeking agreement about how extend and clarify the specification, isn't it better that we make a plan to deprecate all these underspecified fills, and instead spend our efforts on strengthening the support for SVG? For example, these are all things that would seem more worthwhile standardizing:
|
|
I find the graphic primitives provided by Modelica sufficient for creating the graphics needed for icons (including the possibility to use SVG images in Bitmap primitives). Seems a bit too drastic to deprecate something that has been around pretty much since the birth of Modelica and replace it with something new that doesn't bring that much more to the table. All tools would still have to support the original primitives for many years to come as many libraries depend on these, so tools would become more complex not only for the developers of the tools but also for the users. |
|
And preliminarily for Dymola the model from #3789 (review) gives:
|
|
I have now tried to clarify the gradient instead of restricting it. |
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
|
I have tried to reformulate based on this, but without introducing "band". |
Sure, that seems workable. |
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
henrikt-ma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this looks very reasonable to me, but I'd like to leave it to others working closer to the graphical user interfaces to provide approving reviews.
|
Sounds good to me, but wouldn't it make sense to include some visual examples complementing the text? It would decrease the risk of different (mis)interpretations of the text. |
I can promise to provide one or two examples with tool-independent scalable vector graphics, but it would be most convenient for me to do this in a separate pull request initiated by me. With this promise, I suggest that we accept the present PR without examples. |
| The gradient goes from line color to fill color. | ||
| Gradients are defined for the geometry of a \lstinline!GraphicItem! before its \lstinline!rotation! is applied. | ||
| The coloring is defined for an enclosing shape, and then clipped to the actual shape of the \lstinline!GraphicItem!. | ||
| For \lstinline!HorizontalCylinder! and \lstinline!VerticalCylinder!, the minimal enclosing axis-parallel rectangle is used, while \lstinline!Sphere! uses the smallest enclosing ellipse. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be clarified that we don't mean the less computationally tractable smallest-perimeter ellipse:
| For \lstinline!HorizontalCylinder! and \lstinline!VerticalCylinder!, the minimal enclosing axis-parallel rectangle is used, while \lstinline!Sphere! uses the smallest enclosing ellipse. | |
| For \lstinline!HorizontalCylinder! and \lstinline!VerticalCylinder!, the minimal enclosing axis-parallel rectangle is used, while \lstinline!Sphere! uses the smallest area enclosing ellipse. |
Here they are (but I made them three figures start with): #3802 |











Closes #1826