F Bek
unread,Feb 12, 2021, 8:59:21 PM2/12/21You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Beginner's question,
Dolphin Smalltalk 7.2.4
I've been toying with Gdipus and got it to draw a Rectangle or a T-section, based on dimensions entered by the user, while displaying some calculated properties, by:
- Scaling the graphics (+/-) to fit in no more than half the view;
- Reflecting the graphics about axis-x, to get the y-axis pointing upward instead of downward;
- Translating the graphics to shift the coord. Origin point, and center the graphics in the middle of the view;
- drawing & filling the model as a Path of points;
- drawing x & y arrows at the [new] origin point. - drawing a CG symbol at the centroid of the model.
- drawing an adaptive Grid, both horizontal & vertical, proportional to say half the model dimension, corrected to a power-of-10-multiple of 1, 2, 2.5, 5, or 10.
Most of the magic was performed in one transformation:
graphics transform: (GdiplusMatrix m11: 1 m12: 0 m21: 0 m22: -1 m31: tx m32: ty).
where, 1 & -1 are the Reflection about x-x, and tx ty are the translation vector.
With the above, I had 4 problems:
1)- I could have included scaling in the matrix but I kept it separate, as a simple multiplication, because a #scaleTransform would also affect the line width of the graphics, which was not what I wanted. I've found a partial workaround by experimenting with a line width of 0, which would keep the line thin. But what if I wanted a fixed line width, say 3, irrespective of scale? Is there any way to do that?
2)- Then, I displayed 'O', 'x' and 'y' text at the new Origin, and of course, the writing was upside-down due to the Reflection! I would hate to have to reset the Transform and have to recalculate the text locations to display them properly! Is there any more elegant way of doing this?
3)- I've also experimented for a while with the concept of layers, by constructing a second bitmap for the grids and displaying it on top of the main one, but got all sorts of truncated half grids due to the translation - I finally gave up. But will need to resolve that in order to display dimensions on the graphics as well. Any suggestions?
4)- Currently, the graphics code is still bulky and requires rewriting; it is based on a main method in the Presenter and the <graphics> variable being tossed around a coupe of other methods to add the various decorations... I am rethinking the approach.
Thank you for reading and eventually answering.
FB
___________________________________________