Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Unix soit qui mal y pense [Unix to him who evil thinks?]


programming / comp.lang.smalltalk.dolphin / Re: Mirror Mirror, the writing is upside-down on the Wall!

SubjectAuthor
* Mirror Mirror, the writing is upside-down on the Wall!F Bek
`- Re: Mirror Mirror, the writing is upside-down on the Wall!F Bek

1
Subject: Mirror Mirror, the writing is upside-down on the Wall!
From: F Bek
Newsgroups: comp.lang.smalltalk.dolphin
Date: Sat, 13 Feb 2021 01:59 UTC
X-Received: by 2002:a37:6ca:: with SMTP id 193mr5474521qkg.436.1613181560730;
Fri, 12 Feb 2021 17:59:20 -0800 (PST)
X-Received: by 2002:aca:ba56:: with SMTP id k83mr1712476oif.82.1613181560375;
Fri, 12 Feb 2021 17:59:20 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.smalltalk.dolphin
Date: Fri, 12 Feb 2021 17:59:20 -0800 (PST)
Complaints-To: groups-abuse@google.com
Injection-Info: google-groups.googlegroups.com; posting-host=80.79.145.136; posting-account=5ZCy9QoAAAAoNnwHIxbmglmR4vxJHcnW
NNTP-Posting-Host: 80.79.145.136
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e733d68f-276e-4782-b072-c80ee2036704n@googlegroups.com>
Subject: Mirror Mirror, the writing is upside-down on the Wall!
From: fbekd...@gmail.com (F Bek)
Injection-Date: Sat, 13 Feb 2021 01:59:20 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
View all headers
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
___________________________________________


Subject: Re: Mirror Mirror, the writing is upside-down on the Wall!
From: F Bek
Newsgroups: comp.lang.smalltalk.dolphin
Date: Thu, 25 Feb 2021 12:44 UTC
References: 1
X-Received: by 2002:a37:a8cc:: with SMTP id r195mr2328408qke.151.1614257081953;
Thu, 25 Feb 2021 04:44:41 -0800 (PST)
X-Received: by 2002:a05:6830:118a:: with SMTP id u10mr2159576otq.112.1614257081650;
Thu, 25 Feb 2021 04:44:41 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.smalltalk.dolphin
Date: Thu, 25 Feb 2021 04:44:41 -0800 (PST)
In-Reply-To: <e733d68f-276e-4782-b072-c80ee2036704n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=194.126.5.145; posting-account=5ZCy9QoAAAAoNnwHIxbmglmR4vxJHcnW
NNTP-Posting-Host: 194.126.5.145
References: <e733d68f-276e-4782-b072-c80ee2036704n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <05c36a91-f814-4d2c-aecd-4033688248b7n@googlegroups.com>
Subject: Re: Mirror Mirror, the writing is upside-down on the Wall!
From: fbekd...@gmail.com (F Bek)
Injection-Date: Thu, 25 Feb 2021 12:44:41 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
View all headers
Ref to my message below, the current progress is as follows:

 1)- Found a fix: (#Gdiplus.Pen) has a full set of transform methods, including (Pen >> scaleTransform: order:) which can be used to reverse the effects of (GdiplusGraphics >> scaleTransform:) on the pen, effectively maintaining the Pen width independent from scale - which was the required effect!
 
 2)- In order to display text upside-up, I had to reset the transform, apply a translation-only and reverse the sign of 'point y' where the string will display. Still looking for a better way to control Graphics >> displayString: orientation.

Gdiplus.StringFormat Class is a promising alternative, sadly there is no documentation on how to use it to control _text orientation_. Any help would be much appreciated!

 3 & 4)- Getting closer to restarting work on a 'Layer' approach to the various components of the graphics, as well as a general code re-write.

Thanks for reading and possibly answering
FB
______________________________________

On Saturday, February 13, 2021 at 3:59:21 AM UTC+2, F Bek wrote:
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
___________________________________________


1
rocksolid light 0.7.2
clearneti2ptor