Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ vertical text

vertical text

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Zimmy   (31 posts)  Bio
Date Tue 11 Feb 2020 08:19 AM (UTC)

Amended on Wed 12 Feb 2020 06:05 AM (UTC) by Zimmy

Message
I'd like to be able to draw vertical text (rotated clockwise 90 degrees.) I've been able to do 180 degrees; but when I try 90, I get a distorted streak. Here is my attempt:


    WindowRectOp(win.."held", 2, 0, 0, voy.dimensions.window.x, voy.dimensions.font[1], col.window.transparent)
    WindowText(win.."held", "f", text, 0, 0, 0, 0, voy.colours.objects.held, false)
    WindowImageFromWindow(win, "held", win.."held")

    -- copied from the documentation:
    local angle = 90
    local radians = math.rad (angle)
    local sine   = math.sin (radians)
    local cosine = math.cos (radians)

    -- rotate clockwise
    WindowTransformImage(win, "held", voy.dimensions.font[1], voy.dimensions.window.y, 3, cosine,  sine,  -sine,  cosine)


I've also tried:
WindowTransformImage(win, "held", voy.dimensions.font[1], voy.dimensions.window.y, 3, 0, 1, -1, 0)


As well as different arbitrary coordinates. There must be something I don't understand.

[EDIT] I've been playing around with it further and found that reflections and stretching work fine. However, I can't get it to do any sort of sheering or rotation (copying examples from the documentation). When I try, I just end up with a reflection and/or stretch.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 12 Feb 2020 04:48 AM (UTC)
Message
Can you make up a complete example please? With all the miniwindow creation, etc?

Trying your code, and after making a "win" miniwindow I get:


Run-time error
World: smaug2
Immediate execution
[string "Immediate"]:7: attempt to index global 'voy' (a nil value)
stack traceback:
        [string "Immediate"]:7: in main chunk


I don't want to guess what all your variables are.

So, make "win" and "winheld" and "voy", and show what font you are using, and so on.

In other words, some code I can copy and paste and reproduce the issue.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zimmy   (31 posts)  Bio
Date Reply #2 on Wed 12 Feb 2020 06:06 AM (UTC)

Amended on Wed 12 Feb 2020 06:08 AM (UTC) by Zimmy

Message
Sorry about that, hopefully this is more helpful.


WIN_X, WIN_Y = 300, 300
WindowCreate("MAIN_WINDOW", 0, 0, WIN_X, WIN_Y, miniwin.pos_center_all, 0, ColourNameToRGB("black")) -- main window
WindowCreate("TEXT_WINDOW", 0, 0, 0, 0, miniwin.pos_center_all, 0, ColourNameToRGB("purple")) -- workspace for rotating text
WindowFont("TEXT_WINDOW", "font", "Dina", 15, false, false, false, false)
TXT_Y = WindowFontInfo("TEXT_WINDOW", "font", 1)
WindowResize("TEXT_WINDOW", WIN_X, TXT_Y, ColourNameToRGB("purple"))
WindowText("TEXT_WINDOW", "font", "text here", 0, 0, WIN_X, WIN_Y, ColourNameToRGB("white"), false)
WindowImageFromWindow("MAIN_WINDOW", "text", "TEXT_WINDOW")
-- rotation angle in degrees
angle = 90
-- angle converted to radians
radians = math.rad (angle)
-- calculate sine and cosine
sine   = math.sin (radians)
cosine = math.cos (radians)
-- rotate clockwise
WindowTransformImage("MAIN_WINDOW", "text", TXT_Y, WIN_X, miniwin.image_copy, cosine,  sine,  -sine,  cosine)
WindowShow("MAIN_WINDOW", true)


Thanks!
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #3 on Wed 12 Feb 2020 08:19 PM (UTC)
Message
I just want to point out that "cosine, sine, -sine, cosine" is not what the doc says to do for clockwise rotation.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Zimmy   (31 posts)  Bio
Date Reply #4 on Wed 12 Feb 2020 08:36 PM (UTC)
Message
Fiendish said:

I just want to point out that "cosine, sine, -sine, cosine" is not what the doc says to do for clockwise rotation.


Oh, it says: "cosine, -sine, sine, cosine," I did counter-clockwise on accident. I don't believe this is the source of my issue though.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Wed 12 Feb 2020 08:51 PM (UTC)
Message
Seems OK to me.



Template:version Please help us by advising the version of MUSHclient you are using. Use the Help menu -> About MUSHclient.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zimmy   (31 posts)  Bio
Date Reply #6 on Wed 12 Feb 2020 09:00 PM (UTC)
Message
https://imgur.com/a/Wwv3BiU

Must be a compatibility issue? I run mush on wine64.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #7 on Wed 12 Feb 2020 09:47 PM (UTC)

Amended on Wed 12 Feb 2020 09:49 PM (UTC) by Nick Gammon

Message

Yes, I tested on Wine under Ubuntu and got much less satisfactory results.

Looks like a Wine bug. The code uses SetWorldTransform, and I found a couple of reports of rotation not working in Wine:

I’m not sure what to suggest. You could pre-render the image, unless, of course, the text changes all the time.

For a fairly small image you might be able to do the rotation in Lua, although it might be slow, a pixel at a time (see example below).

There is a Lua image library, maybe that could help:

If you want to do the image occasionally (for example, if it is the name of the MUD you are playing) you can install ImageMagick and get that to make a rotated PNG for you.


Example of rotating in Lua

This code does a 90 degree rotation by copying a pixel at a time. The “200 - x” and “200 - y” below are to get the flipping right.

The rotation took 0.015 seconds on my PC using Wine under Ubuntu.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #8 on Wed 12 Feb 2020 09:54 PM (UTC)
Message

Rotating the entire image took 0.141 seconds.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zimmy   (31 posts)  Bio
Date Reply #9 on Wed 12 Feb 2020 09:59 PM (UTC)
Message
Nick Gammon said:

Rotating the entire image took 0.141 seconds.


Okay so I think what would be best, is if when the plugin loads, I make an image of each letter in the font and size I want to use. Then rotate each image, before-hand, using the same method.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #10 on Wed 12 Feb 2020 10:13 PM (UTC)
Message
If you got the exact dimensions for the text (which is achievable) then just doing one big rotation might be just as good. Doing lots of copies of each letter, and getting them spaced the right distance apart, would be time-consuming too.

After all, you only need to copy the non-black pixels in the source, which is what my first example tried to do, although I didn't calculate the exact size that the text took.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zimmy   (31 posts)  Bio
Date Reply #11 on Wed 12 Feb 2020 10:23 PM (UTC)
Message
The text changes and can not be per-determined so I need a dynamic solution. That's why I was thinking I would create images of each rotated letter on install. That way I could later produce vertical text by drawing the images under each-other to create words.
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #12 on Wed 12 Feb 2020 10:41 PM (UTC)
Message
Please tell me that you're doing an April fool's day gag where the player's output is all rotated sideways.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #13 on Wed 12 Feb 2020 10:48 PM (UTC)
Message
It might be the labels on tabbed windows.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zimmy   (31 posts)  Bio
Date Reply #14 on Wed 12 Feb 2020 11:00 PM (UTC)
Message
Nick Gammon said:

It might be the labels on tabbed windows.

I already have a bunch of mini-windows and a small laptop screen. So real estate is quite valuable! Just trying to fit things in the few remaining empty-spaces I have. Plus the miniwindow this is for is already very densely packed. Basically, just want to display the weapon I have held in each hand. Thought it would look neat to have the text vertically along the edge of the mini-window respective to the hand it was held in.

Thanks for all the help!
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


52,883 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.