Older Newer
Thu, 19 Dec 2019 13:11:19 . . . . SyneRyder [formatting]


Changes by last author:

Added:
= scaleFactor =

== Syntax ==

int scaleFactor

== Description ==

scaleFactor is an integer that defines the scale ratio (zoom factor) of the image in the preview proxy window. You can use this value to ensure your image looks correct at all zoom levels, or to help you calculate the original image co-ordinates when a user clicks on a pixel in the preview window. scaleFactor will be set to 1 at 100% zoom, 3 for 33% zoom, 5 for 20% and so on. Think of it as the denominator in the scale ratio - a 50% zoom image is 1/2 size, so the scaleFactor is 2. A 20% zoom image is 1/5 the original size, so the scaleFactor is 5 (and so on).

== Example ==

<code>

%ffp

ctl(0): STATICTEXT, "Please right click on the preview to set a cross.", size=(100,20)

OnCtl(n): {

if (n == CTL_PREVIEW && e == FME_RIGHTCLICKED_DOWN) {

j0 = getPreviewCoordX() * scaleFactor;

j1 = getPreviewCoordY() * scaleFactor;

doAction(CA_PREVIEW );

}

return false;

}

ForEveryTile: {

int g, h, z, color;

int PreviewX = j0/scaleFactor;

int PreviewY = j1/scaleFactor;

// Calculate color of the cross

color = ( src(PreviewX, PreviewY, 0) + src(PreviewX, PreviewY, 1) + src(PreviewX, PreviewY, 2) ) /3;

if (color > 128 && color < 196) color=0;

if (color > 64 && color < 128) color=255;

else color =255-color;

// Display Cross

if (doingProxy){

for (z=0; z < Z; z++) {

for (g=-7; g < 8; g++)

if (g < -1 || g > 1) pset(PreviewX + g, PreviewY, z, color);

for (h=-7; h < 8; h++)

if (h < -1 || h > 1) pset(PreviewX, PreviewY + h, z, color );

}

}

return true;

}

</code>

== See Also ==

Constants, setZoom, getPreviewCoordX, getPreviewCoordY