Read about scripting
Draws an image into a miniwindow with optional rotation, scaling, reflection and shearing
View list of data type meanings
long WindowTransformImage(BSTR WindowName, BSTR ImageId, float Left, float Top, short Mode, float Mxx, float Mxy, float Myx, float Myy);
This copies an image to the miniwindow. You specify effectively a "matrix" which is applied to each pixel position, so that the image can be rotated, scaled, reflected, sheared and translated.
Note that changes to miniwindows will not become visible until the output window is redrawn. This happens when new (visible) lines arrive from the MUD, or if you call WindowShow, Repaint or Redraw.
WindowName - the name of an existing miniwindow.
ImageId - an image id that you have loaded.
Left, Top - the offset in the destination miniwindow for the image
Mode - the method of drawing the image:
1 - Copy non-transparently to the destination position.
2 - Not used.
3 - Do a transparent copy, where the pixel at the left,top corner (pixel position 0,0) is considered the transparent colour. Any pixels that exactly match that colour are not copied. WARNING - do not choose black or white as the transparent colour as that throws out the calculations. Choose some other colour (eg. purple) - you won't see that colour anyway.
The position of each destination pixel (x' and y') is given by:
x' = (x * Mxx) + (y * Mxy) + Left
y' = (x * Myx) + (y * Myy) + Top
Note that if you draw a monchrome image, such as one set up by WindowCreateImage then the pen colour from the most recent drawing operation is used as the foreground colour, and the brush colour for the background colour. Thus you may want to draw a small rectangle (eg. 1 x 1 pixel) with WindowCircleOp to establish those colours first.
For example images and code, see:
Some examples of rotating, scaling, shearing etc. can be found below in the Lua examples.
Note that in some cases you need to also modify the Left and Top parameters or you may not see the result. For example, reflecting an image is likely to reflect it off the side of the bitmap, so you need to add the size of the image back in, to put it back in its original place. The forum posting mentioned above has a discussion about this, and more detailed examples.
Available in MUSHclient version 4.59 onwards.
-- IDENTITY COPY (ie. copy without changing)
WindowTransformImage (win, imageid, 0, 0, miniwin.image_copy, 1, 0, 0, 1)
-- move in X direction
WindowTransformImage (win, imageid, 100, 0, miniwin.image_copy, 1, 0, 0, 1)
-- move in Y direction
WindowTransformImage (win, imageid, 0, 100, miniwin.image_copy, 1, 0, 0, 1)
-- REFLECT ON THE X AXIS
WindowTransformImage (win, imageid, 0, 0, miniwin.image_copy, -1, 0, 0, 1)
-- REFLECT ON THE Y AXIS
WindowTransformImage (win, imageid, 0, 0, miniwin.image_copy, 1, 0, 0, -1)
-- REFLECT ON BOTH AXES (ROTATE 180 DEGREES)
WindowTransformImage (win, imageid, 0, 0, miniwin.image_copy, -1, 0, 0, -1)
-- rotation angle in degrees
local angle = 30
-- angle converted to radians
local radians = math.rad (angle)
-- calculate sine and cosine
local sine = math.sin (radians)
local cosine = math.cos (radians)
-- rotate counterclockwise
WindowTransformImage (win, imageid, 0, 0, miniwin.image_copy, cosine, sine, -sine, cosine)
-- rotate clockwise
WindowTransformImage (win, imageid, 0, 0, miniwin.image_copy, cosine, -sine, sine, cosine)
-- shear vertically right side downwards
WindowTransformImage (win, imageid, 0, 0, miniwin.image_copy, 1, 0, 1, 1)
-- shear horizontally, bottom to the right
WindowTransformImage (win, imageid, 0, 0, miniwin.image_copy, 1, 0.5, 0, 1)
-- make 1.5 times larger
WindowTransformImage (win, imageid, 0, 0, miniwin.image_copy, 1.5, 0, 0, 1.5)
-- reduce to 50%
WindowTransformImage (win, imageid, 0, 0, miniwin.image_copy, 0.5, 0, 0, 0.5)
You can use the following constants for the mode:
miniwin.image_copy = 1
miniwin.image_transparent_copy = 3
View list of return code meanings
eNoSuchWindow - no such miniwindow
eImageNotInstalled - that image was not loaded with WindowLoadImage or WindowLoadImageMemory
eBadParameter - drawing mode not in list above or not available due to being run under Windows 95 or earlier
eOK - completed OK
See Also ...
(GetDeviceCaps) Gets screen device capabilities
(SetCursor) Changes the shape of the mouse cursor
(TextRectangle) Specifies the size of the rectangle in which text is displayed in the output window.
(WindowAddHotspot) Adds a hotspot to a miniwindow
(WindowArc) Draws an arc in a miniwindow
(WindowBezier) Draws a Bézier curve in a miniwindow
(WindowBlendImage) Blends an image into a miniwindow, using a specified blending mode
(WindowCircleOp) Draws ellipses, filled rectangles, round rectangles, chords, pies in a miniwindow
(WindowCreate) Creates a miniwindow
(WindowCreateImage) Creates an image in a miniwindow
(WindowDelete) Deletes a miniwindow
(WindowDeleteAllHotspots) Deletes all hotspots from a miniwindow
(WindowDeleteHotspot) Deletes a hotspot from a miniwindow
(WindowDragHandler) Adds a drag handler to a miniwindow hotspot
(WindowDrawImage) Draws an image into a miniwindow
(WindowDrawImageAlpha) Draws an image into a miniwindow respecting the alpha channel
(WindowFilter) Performs a filtering operation over part of the miniwindow.
(WindowFont) Loads a font into a miniwindow
(WindowFontInfo) Returns information about a font
(WindowFontList) Lists all fonts loaded into a miniwindow
(WindowGetImageAlpha) Draws the alpha channel of an image into a miniwindow
(WindowGetPixel) Gets the colour of a single pixel in a miniwindow
(WindowGradient) Draws a gradient in a rectangle
(WindowHotspotInfo) Returns information about a hotspot
(WindowHotspotList) Lists all hotspots installed into a miniwindow
(WindowHotspotTooltip) Changes the tooltip text for a hotspot in a miniwindow
(WindowImageFromWindow) Creates an image from another miniwindow
(WindowImageInfo) Returns information about an image
(WindowImageList) Lists all images installed into a miniwindow
(WindowImageOp) Draws an ellipse, rectangle or round rectangle, filled with an image
(WindowInfo) Returns information about a miniwindow
(WindowLine) Draws a line in a miniwindow
(WindowList) Lists all miniwindows
(WindowLoadImage) Loads an image into a miniwindow from a disk file
(WindowMenu) Creates a pop-up menu inside a miniwindow
(WindowMergeImageAlpha) Merges an image into a miniwindow based on an alpha mask
(WindowMoveHotspot) Moves a hotspot in a miniwindow
(WindowPolygon) Draws a polygon in a miniwindow
(WindowPosition) Moves a miniwindow
(WindowRectOp) Draws a rectangle in a miniwindow
(WindowResize) Resizes a miniwindow
(WindowScrollwheelHandler) Adds a scroll-wheel handler to a miniwindow hotspot
(WindowSetPixel) Sets a single pixel in a miniwindow to the specified colour
(WindowSetZOrder) Sets the Z-Order for a miniwindow
(WindowShow) Shows or hides a miniwindow
(WindowText) Draws text into a miniwindow
(WindowTextWidth) Calculates the width of text in a miniwindow
(WindowWrite) Writes the contents of a miniwindow to disk as a graphics file
(Help topic: function=WindowTransformImage)