Table of Contents

## Name

winop - Perform assorted window and image operations

## Synopsis

winop changes window

winop image subcommand ...

> winop image colors ?-alpha? srcImage

> winop image convolve srcImage destImage filter

> winop image gradient image leftcolor rightcolor ?lines|normal|rectangular|linear|radial|sine|halfsine|blank? ?skew?

> winop image merge srcImage1 srcImage2 destImage ?alpha?

> winop image mirror srcImage1 destImage ?x|y|xy|tile?

> winop image quantize srcImage destImage ?nColors?

> winop image readjpeg filename photoname

> winop image resample srcImage destImage ?horizFilter? ?vertFilter?

> winop image rotate srcImage destImage angle

> winop image subsample srcImage destImage x y width height ?horizFilter? ?vertFilter?

> winop image snap window photoName

> winop image transparent srcImage destImage color

winop lower ?window?...

winop map ?window?...

winop move window x y

winop query

winop raise ?window?...

winop unmap ?window?...

winop warpto ?window?

## Description

The winop command performs various window and image operations on Tk windows using low-level Xlib function calls to work around window manager pecularities.

## Introduction

Tk has several commands for manipulating its windows: raise, lower, wm, etc. These commands ask the window manager to perform operations on Tk windows. In some cases, a particular window manager won't perform the operation as expected.

For example, if you positioned a toplevel window using wm geometry, the window may not actually be at those particular coordinates. The position of the window may be offset by dimensions of the title bar added by the window manager.

In situations like these, the winop command can be used to workaround these difficulties. Instead, it makes low-level Xlib (such XRaiseWindow and XMapWindow) calls to perform these operations.
`toplevel .top
wm withdraw .top
`

# Set the geometry to make the window manager
# place the window.
wm geometry .top +100+100

# Move the window to the desired location
# and "update" to force the window manager
# to recognize it.
winop move .top 100 100
update

wm deiconify .top
winop move .top 100 100

## Operations

The following operations are available for the winop command:

winop changes window
  Realize window.
winop image subcommand ...
  Image sub-commands.

winop image alpha srcImage destImage color ?alpha?
  Set image pixels of the given color to transparent. If an alpha value is not given, it defaults to 0 (meaning transparent). An alpha of 255 is used for solid. The srcImage and destImage may be the same.
winop image colors ?-alpha? ?-count? srcImage
  Return list of distinct colors. If -alpha is given, the alpha is appended to each color after a colon, eg #FF0000:00. If -count is given, returns color/count pairs.
winop image convolve srcImage destImage filter
  Convolve an image: filter is a list of numbers. The srcImage and destImage may be the same.
winop image gradient image leftcolor rightcolor ...
  Generate a gradient into image.

-type halfsine|sine|linear|rectangular|radial|blank
  Set the type of gradient. The default is sine.
-skew N
  The skew determines the initial fraction of the image that the gradient occupies, after which only rightcolor is used. The skew must be > 0 and <= 1.0 and has a default value of 1.0 (ie. not skewed).
-slant N
  Make the gradient slant where a value of 1.0 slants at 45 degrees. The value must be between -100.0 and 100.0.
-curve N
  Curve the gradient by passing the Y position to a function (see -func) scaled with the given value. The value must be between -100.0 and 100.0 (typically 1.0).
-func X
  Function to use with -curve. The default value is sin. The value must be one of: sin cos tan sinh cosh tanh asin acos atan log log10 exp sqrt rand circle.
-rand N
  Add small random purturbations to gradient to avoid striation lines. The value must be between 0.0 and 0.1.

winop image merge srcImage1 srcImage2 destImage ?alpha?
  Merge two images with alpha blending. The default alpha is 128.
winop image mirror srcImage1 destImage ?x|y|xy|tile?
  Flips an image on axis x, y or xy. The tile option results in a double size image with mirror copies appended to generate a tile-able image. The srcImage1 and destImage must not be the same if using tile. The default is xy.
winop image quantize srcImage destImage ?nColors?
  Limit number of colors in image. Default 1. The srcImage and destImage may be the same.
winop image readjpeg filename photoname
  Read a jpeg image using libjpeg. IMG makes this obsolete (and thus probably not builtin).
winop image recolor srcImage destImage oldColor newColor ?alpha?
  Change pixels from oldColor to newColor. If ?alpha? is not given it defaults to 255 (opaque). The srcImage and destImage may be the same.
winop image resample srcImage destImage ?horizFilter? ?vertFilter?
  Resample an image. If srcImage and destImage are the same size, just makes a copy. Otherwise the image is resized to the size of destImage, possibly wih filtering. Filters are one of: bell bessel box bspline catrom default dummy gauss8 gaussian gi lanczos3 mitchell none sinc triangle. The destImage must be greater than 1x1.
winop image rotate srcImage destImage angle
  Rotate an image. The srcImage and destImage may be the same.
winop image subsample srcImage destImage x y width height ?horizFilter? ?vertFilter?
  Resample area of an image. See resample.
winop image snap window photoName
  Takes a snapshot of the window and stores the contents in the photo image photoName. Window is the valid path name of a Tk window which must be totally visible (unobscured). PhotoName is the name of a Tk photo image which must already exist. This command can fail if the window is obscured in any fashion, such as covered by another window or partially offscreen. In that case, an error message is returned.

winop lower ?window?...
  Lowers window to the bottom of the X window stack. Window is the path name of a Tk window.
winop map ?window?...
  Maps window on the screen. Window is the path name of a Tk window. If window is already mapped, this command has no effect.
winop move window x y
  Move window to the screen location specified by x and y. Window is the path name of a Tk window, while x and y are screen coordinates. This command returns the empty string.
winop query
  Query pointer position. Returns @X,Y.
winop raise ?window?...
  Raises window to the top of the X window stack. Window must be a valid path name of a Tk window. This command returns the empty string.
winop unmap ?window?...
  Unmaps window from the screen. Window is the path name of a Tk window.
winop warpto ?window?
  Warps the pointer to window. Window is the path name of a Tk window which must be mapped. If window is in the form @x,y, where x and y are root screen coordinates, the pointer is warped to that location on the screen.

  [I've never heard a good case for warping the pointer in an application. It can be useful for testing, but in applications, it's always a bad idea. Simply stated, the user owns the pointer, not the application. If you have an application that needs it, I'd like to hear about it.]

  If no window argument is present the current location of the pointer is returned. The location is returned as a list in the form "x y", where x and y are the current coordinates of the pointer.

## Keywords

window, map, raise, lower, pointer, warp

Table of Contents

- Name
- Synopsis
- Description
- Introduction
- Operations
- Keywords