Posted by
| Nick Gammon
Australia (23,042 posts) bio
Forum Administrator |
Message
| Yes that is fairly simple. You need to make a miniwindow, and set it to be drawn underneath the text. Here is an example:
<aliases>
<alias
match="makerect"
enabled="y"
send_to="12"
sequence="100"
>
<send>
local background_window = "world_background_image" -- miniwindow ID
-- location for window (and image)
local left = 350
local top = 400
local right = left + GetInfo (213) * 80 -- offset + width for 80 characters
local bottom = GetInfo (280) - 15 -- 15 pixels from bottom
-- tell the client where to draw the text
TextRectangle(left,
top,
right,
bottom,
5, -- BorderOffset,
ColourNameToRGB ("gray"), -- BorderColour,
2, -- BorderWidth,
ColourNameToRGB ("silver"), -- OutsideFillColour,
8) -- OutsideFillStyle (fine hatch)
-- make a miniwindow under the text
check (WindowCreate (background_window, -- window ID
left,
top,
right - left, -- width
bottom - top, -- depth
12, -- center it (ignored anyway)
3, -- draw underneath (1) + absolute location (2)
0x000000)) -- background colour
-- load the background image
check (WindowLoadImage (background_window, "background", GetInfo (66) .. "background_image.png"))
-- draw it
check (WindowDrawImage (background_window, "background", 0, 0, 0, 0, 1)) -- draw it
-- show the window
WindowShow (background_window, true)
</send>
</alias>
</aliases>
This example draws without scaling, so a suitable image would be one that fits the area you have allocated. Alternatively with a bit more fiddling around you can scale, preserving the aspect ratio, so you can accommodate any size image (although there may be black bars if the image's aspect ratio is not the same as the text box's aspect ratio). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|