[squeak-dev] Has anyone made Morphs good for showing compass like visuals?

Ron Teitelbaum ron at usmedrec.com
Fri Mar 10 20:56:01 UTC 2017


We have one that is just png images.

[image: pasted1]
you just rotate the arrow when you click:

onCompassDownProportional: evt

"Mouse down in the compass rose.  Turn toward the heading indicated by the
mouse position.
The further the heading is from our current one, the more we turn."

| hitAngle oldAngle diff factor |

factor := 1.5.  "Divisor of turn to take at each tick.  1 gives immediate
full rotation."

hitAngle := 360 - ((32 at 32) bearingToPoint: (evt position)).
hitAngle < 0 ifTrue: [hitAngle := hitAngle + 360].
oldAngle := compassArrow angle - 90.
oldAngle < 0 ifTrue: [oldAngle := oldAngle + 360.].

diff := (hitAngle - oldAngle).
lastEvent := evt.

(diff abs) < 1 ifTrue: [
^ self
].

"Take the shorter path around the compass..."
diff > 180 ifTrue: [
diff := diff - 360.
] ifFalse: [
diff < -180 ifTrue: [
diff := 360 + diff.
].
].

"unless direct, put a ceiling on the amount of spin in a single increment."
factor > 1 ifTrue: [
diff positive ifTrue: [
diff := diff min: 120.
] ifFalse: [
diff := diff max: -120.
].
].

newAngle := oldAngle + (diff/factor).

self signal: #rotateToNewAngle.

Then just set the rotationAngle on the image.

All the best,

Ron Teitelbaum
www.3dicc.com

On Fri, Mar 10, 2017 at 3:22 PM Ken G. Brown <kbrown at mac.com> wrote:

> Try <http://windalert.com>
> Search for a place on the map, then explore all the widgets. If you see a
> balloon on the map, click it to reveal options.
>
> Ken G. Brown
>
> On Mar 10, 2017, at 13:09, Tom Rushworth <tom.b.rushworth at gmail.com>
> wrote:
>
> Hi All,
>
> On 10/03/2017 11:00, tim Rowledge wrote:
>
> [snip]
>
> ...For wind speed and direction I think a compass rose and some magnitude
> indicator like the length of the needle would work.
>
> Why not leave the length of the needle as fixed, and use either:
>
>  (a) the colour, or
>  (b) the number of decoration (e.g. arrowheads)
>      ASCII graphics won't show much, but here goes -
>      -------> gentle breeze
>      ------>>
>      ----->>>
>      ---->>>>
>      --->>>>> gale
>
> for speed? FWIW, I think there is a type of wind speed/direction map that
> uses a grid of small needles with varying numbers of half arrowheads to
> show strength.  I can't dig up an example at the moment though.
>
> Regards,
>
> --
> Tom Rushworth
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170310/842f5f51/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pasted1
Type: image/png
Size: 5379 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170310/842f5f51/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compassRoseOver.png
Type: image/png
Size: 3478 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170310/842f5f51/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compassRose.png
Type: image/png
Size: 1604 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170310/842f5f51/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compassRoseDown.png
Type: image/png
Size: 1600 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170310/842f5f51/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compassArrow.png
Type: image/png
Size: 243 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170310/842f5f51/attachment-0004.png>


More information about the Squeak-dev mailing list