Touchup - JavaScript


This code is an example of what you can do with Touchup. It determines if the browser is running on a Macintosh, and compensates for the lower (or darker) video gamma on the Macintosh. Note that all calls must be made after the Touchup applet has loaded. To do this, we need to add to the body statement as well: <body onLoad="compensate()">

function compensate()
{ if ((navigator.appVersion.indexOf("Mac") != -1)) // macintosh? for (var i=0; i<document.applets.length; i++) document.applets[i].setPlatformGammaCompensation(1/1.45); }

Another example, showing code that can be used with buttons or thumbnails to change the displayed image and link:

function changeTouchupImage(file,link,target)
{ document.applets[0].loadImage(file,'','','','','');

The following Touchup calls are available through JavaScript:
  (Floating point values: level, contrast, brightness, saturation, red, green, blue, alpha
   Boolean values: onOrOff)

Call  Notes
setTitle(title,justify)Set image title and justification (left, right, center, bottom)1.3
setDesc(desc, fgColor, bgColor)Sets the image description, text and background colors2.1
setPlatformGammaCompensation(gamma)Set the platform gamma compensation (default 1)1.4
setHyperlink(link,target)Change the hyperlink and target window1.1
setRGB(red,green,blue)Set color gamma (1.0, 1.0, 1.0 default)
getRed()Get color gamma
setRed(gamma)Set color gamma (0.0 to 100)
setRGBChannels(red,green,blue)Set channels (-1 invert, 0 void, 1 default)1.3
getRedChannel()Get color scale1.3
getGamma()Get the gamma value (1.0 default)1.1
setGamma(gamma)Set gamma1.1
getBrightness()Get the brightness value (0 default)1.5
setBrightness(level)Set brightness1.5
getZoom()zoom scale value (1.0 default)
getHorizontal()get horizontal move value: -left, +right2.3
setHorizontal(pixels)move image: -left, +right2.3
getVertical()get vertical move value: -up, +down2.3
setVertical(pixels)move image: -up, +down2.3
mirror()Flip the image horizontally1.4
flip()Flip the image vertically1.4
setRotate(degrees)Rotate 0, 90, 180 or 270 degrees1.4
getNegative()inverted colors? (boolean)
setNegative(onOrOff)true for negative, false for positive
negative()Toggle setting
blackAndWhite()Toggle setting
getContrast()(default 1.0)
getSaturation()(default 1.0)
getAlpha()0.0 (no alphaColor) to 1.0 (just alphaColor)
getPosterize()Get posterization steps1.2
setPosterize(level)Set posterization steps1.2
getNoiseFrequency()Get frequency of pixel noise
setNoiseFrequency(level)Set frequency of pixel noise
getNoiseLevel()Get pixel noise brightness adjustment
setNoiseLevel(level)Set pixel noise brightness adjustment
setEntryExitScripts(entryScript,exitScript)Set scripts for when mouse enters or leaves Touchup2.0
setClick(message,script)Set statusbar message and click javascript1.3
setUserBtn(title,script)Set user button title and script1.3
disableUpdating()Don't apply filter changes until enabled1.4
enableUpdating()Apply all delayed filter changes1.4
setApplyImageLevelFilters(onOrOff)Enable/disable image level filter settings1.5
setDistanceCalibration(scale,units)set the distance per pixel, and the units (default 1, pixels)
loadImage(file,lowRes,desc,info,title,justification)Load a new image into Touchup1.1
loadImage(file,lowRes,desc,info,title,justify,red,green,blue, gamma,contrast,brightness,saturation) Load a new image into Touchup1.3
syncSetApplet(contrast, brightness, gamma, saturation, red, green, blue, redChannel, greenChannel, blueChannel, alphaColor, alpha, color, neg) 1.3    Change all settings

1.1 - 3.0 Feature was introduced or modified in that version of Touchup