blt::winop(3tcl)

✨ NAME ✨

blt::winop β€” Perform assorted window and image operations πŸ’…

Okay so this is the manual page for blt::winop(3tcl) from the BLT Built-In Commands squad. If you need to do window + image ops with low-level Xlib energy, bestie, you're in the right place. No cap. πŸ¦‹


🌸 SYNOPSIS 🌸

       winop changes window

       winop gradients leftcolor rightcolor gradients

       winop image subcommand ...

              winop image alpha srcImage destImage color

              winop image colors ?-alpha? srcImage

              winop image convolve srcImage destImage filter

              winop image gradient image leftcolor rightcolor ...

              winop image merge srcImage1 srcImage2 destImage ?alpha? ?...?

              winop image mirror srcImage1 destImage ?x|y|xy|tile|outer|inner?

              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 lower ?window?...

       winop map ?window?...

       winop move window x y

       winop query

       winop raise ?window?...

       winop snap window photoName ?width height ?

       winop unmap ?window?...

       winop warpto ?window?

πŸ’– DESCRIPTION πŸ’–

The winop command does a whole bunch of window and image operations on Tk windows, and it does them by calling low-level Xlib functions directly β€” specifically to work around window manager pecularities. πŸ’€βœ¨


🌈 INTRODUCTION 🌈

Tk already has commands for messing with its windows: raise, lower, wm, etc. The thing is, those commands ask the window manager to do the operation on Tk windows. And sometimes a particular window manager just won't do it the way you expected. Rude. 😭

For example, if you positioned a toplevel window using wm geometry, the window may not actually be at those exact coordinates. The position may be offset by the dimensions of the title bar that the window manager adds. It's giving "I moved it but not really." πŸ™ˆ

In situations like these, winop can be used to workaround these difficulties. Instead, it makes low-level Xlib calls (like XRaiseWindow and XMapWindow) to perform these operations. Slay. πŸ’…

              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 πŸ‘‘

Here are all the operations you can throw at the winop command:

  • winop changes window β€” Realizes window. Like, makes it exist for real. ✨
  • winop image subcommand ... β€” The image sub-command zone. πŸŽ€
    • winop image alpha ?-shift? srcImage destImage color ?alpha? ?withalpha? β€” Sets image pixels of the given color to transparent. If you don't give an alpha value, it defaults to 0 (which means transparent). An alpha of 255 is solid. The srcImage and destImage can be the same. If the color is *, any color is matched. If color is prefixed with !, the match is inverted. Iconic. πŸ”₯
    • winop gradients leftcolor rightcolor width β€” Returns a list of width colors that graduate from leftcolor to the color just before rightcolor. Heads up: the last color in the returned list is not rightcolor. A typical use for this is calculating shadow colors. 🌈
    • winop image blur srcImage dstImage ?radius? β€” Blurs an image using gaussian blur. Soft focus moment. πŸ¦‹
    • winop image colors ?-alpha? ?-count? srcImage β€” Returns a list of distinct colors. If -alpha is given, the alpha is appended to each color after a colon, e.g. #FF0000:00. If -count is given, it returns color/count pairs. πŸ’…
    • winop image convolve srcImage destImage filter β€” Convolves an image: filter is a list of numbers. The srcImage and destImage can be the same. Math but make it aesthetic. ✨
    • winop image gradient image leftcolor rightcolor ... β€” Generates a gradient from left to right into image. These options are available:
      • -type halfsine|sine|linear|rectangular|radial|split|blank β€” Sets 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. The default value is 1.0, meaning not skewed.
      • -slant N β€” Makes the gradient slant, where a value of 1.0 slants at 45 degrees. The value must be between -100.0 and 100.0.
      • -mathval N β€” Curves the gradient by passing the Y position to the function -mathfunc. The value must be between -100.0 and 100.0 (typically 1.0). The default is 0.0, which means disabled.
      • -mathfunc X β€” Function to use with -mathval. 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 β€” Adds small random purturbations to the gradient to avoid striation lines. The value must be between 0.0 and 0.1.
      • -height N β€” Changes the image height.
      • -width N β€” Changes the image width.
    • winop image merge srcImage1 srcImage2 destImage ?opacity? ?opacity2? β€” Merges two images with alpha blending. The default ?opacity? is 0.5, and the default for ?opacity2? is 1.0 - ?opacity?.
    • winop image mirror srcImage1 destImage ?x|y|xy|tile|outer|inner? ?halo? β€” 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 outer option is used to resize an image while preserving the outside border by halo pixels (default is 16). The inner option copies from the center of source keeping it centered. These last 2 are used implicitly by blt::tile::button -bdtile, etc. The srcImage1 and destImage must not be the same if using tile, inner or outer. The default is xy.
    • winop image quantize srcImage destImage ?nColors? β€” Limits the number of colors in an image. Default 1. The srcImage and destImage can be the same.
    • winop image readjpeg filename photoname β€” Reads a jpeg image using libjpeg. IMG makes this obsolete (and thus probably not builtin). πŸ™ˆ
    • winop image recolor srcImage destImage oldColor newColor ?alpha? β€” Changes pixels from oldColor to newColor. If ?alpha? is not given, it defaults to 255 (opaque). The srcImage and destImage can be the same.
    • winop image resample srcImage destImage ?horizFilter? ?vertFilter? β€” Resamples an image. If srcImage and destImage are the same size, it 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 β€” Rotates an image. The srcImage and destImage can be the same.
    • winop image subsample srcImage destImage x y width height ?horizFilter? ?vertFilter? β€” Resamples an area of an image. See resample.
    • winop image trans image x y ?alpha? β€” Gets or sets the integer alpha value within an image.
  • winop lower ?window?... β€” Lowers window to the bottom of the X window stack. Window is the path name of a Tk window. Down bad, but for windows. 😭
  • 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 β€” Moves 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 β€” Queries 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. Main character energy. πŸ‘‘
  • winop snap window photoName ?width height? β€” 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. If width or height is given, the image is resampled to the given size.
  • 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


That's the whole vibe, bestie. This page is from BLT 2.5, the blt::winop(3tcl) manual β€” the footer didn't give us a date, so we're just gonna say it's classic BLT era energy. πŸ’–βœ¨

πŸ“¦ where this page comes from