logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

winop - Perform assorted window and image operations

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 wmgeometry, 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

Keywords

window, map, raise, lower, pointer, warp BLT 2.5 blt::winop(3tcl)

Name

winop - Perform assorted window and image operations

Operations

The following operations are available for the winop command: winopchangeswindow Realize window. winopimagesubcommand ... Image sub-commands. winopimagealpha ?-shift? srcImagedestImagecolor ?alpha? ?withalpha? 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. If the color is * any color is matched. If color is prefixed with ! match is inverted. winopgradientsleftcolorrightcolorwidth Return a list of width colors that graduate from leftcolor to the color just before rightcolor. Note that the last color in the returned list is not rightcolor. A typical use for this is calculating shadow colors. winopimageblursrcImagedstImage ?radius? Blur an image using gaussian blur. winopimagecolors ?-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. winopimageconvolvesrcImagedestImagefilter Convolve an image: filter is a list of numbers. The srcImage and destImage may be the same. winopimagegradientimageleftcolorrightcolor ... Generate a gradient from left to right into image. The following options are available: -typehalfsine|sine|linear|rectangular|radial|split|blank Set the type of gradient. The default is sine. -skewN 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. -slantN Make the gradient slant where a value of 1.0 slants at 45 degrees. The value must be between -100.0 and 100.0. -mathvalN Curve 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. -mathfuncX Function to use with -mathval. The default value is sin. The value must be one of: sincostansinhcoshtanhasinacosatanloglog10expsqrtrandcircle. -randN Add small random purturbations to gradient to avoid striation lines. The value must be between 0.0 and 0.1. -heightN Change the image height. -widthN Change the image width. winopimagemergesrcImage1srcImage2destImage ?opacity? ?opacity2? Merge two images with alpha blending. The default ?opacity? is 0.5, and the default for ?opacity2? is 1.0 - ?opacity?. winopimagemirrorsrcImage1destImage ?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. winopimagequantizesrcImagedestImage ?nColors? Limit number of colors in image. Default 1. The srcImage and destImage may be the same. winopimagereadjpegfilenamephotoname Read a jpeg image using libjpeg. IMG makes this obsolete (and thus probably not builtin). winopimagerecolorsrcImagedestImageoldColornewColor ?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. winopimageresamplesrcImagedestImage ?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: bellbesselboxbsplinecatromdefaultdummygauss8gaussiangilanczos3mitchellnonesinctriangle. The destImage must be greater than 1x1. winopimagerotatesrcImagedestImageangle Rotate an image. The srcImage and destImage may be the same. winopimagesubsamplesrcImagedestImagexywidthheight ?horizFilter? ?vertFilter? Resample area of an image. See resample. winopimagetransimagexy ?alpha? Get or set the integer alpha value within an image. winoplower ?window?... Lowers window to the bottom of the X window stack. Window is the path name of a Tk window. winopmap ?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. winopmovewindowxy 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. winopquery Query pointer position. Returns @X,Y. winopraise ?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. winopsnapwindowphotoName ?widthheight? 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. winopunmap ?window?... Unmaps window from the screen. Window is the path name of a Tk window. winopwarpto ?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'veneverheardagoodcaseforwarpingthepointerinanapplication.Itcanbeusefulfortesting,butinapplications,it'salwaysabadidea.Simplystated,theuserownsthepointer,nottheapplication.Ifyouhaveanapplicationthatneedsit,I'dliketohearaboutit.] If no window argument is present the current location of the pointer is returned. The location is returned as a list in the form "xy", where x and y are the current coordinates of the pointer.

Synopsis

winopchangeswindowwinopgradientsleftcolorrightcolorgradientswinopimagesubcommand ... winopimagealphasrcImagedestImagecolorwinopimagecolors ?-alpha? srcImagewinopimageconvolvesrcImagedestImagefilterwinopimagegradientimageleftcolorrightcolor ... winopimagemergesrcImage1srcImage2destImage ?alpha? ?...? winopimagemirrorsrcImage1destImage ?x|y|xy|tile|outer|inner? winopimagequantizesrcImagedestImage ?nColors? winopimagereadjpegfilenamephotonamewinopimageresamplesrcImagedestImage ?horizFilter? ?vertFilter? winopimagerotatesrcImagedestImageanglewinopimagesubsamplesrcImagedestImagexywidthheight ?horizFilter? ?vertFilter? winoplower ?window?... winopmap ?window?... winopmovewindowxywinopquerywinopraise ?window?... winopsnapwindowphotoName ?widthheight ? winopunmap ?window?... winopwarpto ?window? _________________________________________________________________

See Also