getPreviewCoordX

Syntax

int getPreviewCoordX (void)

Arguments

None

Return

Returns the x coordinate in the image above which the mouse pointer is placed.

Description

Together with getPreviewCoordY you can use it to get the coordinates of the mouse pointer above the image in the preview. The returned coordinates are already converted to image coordinates. But it is recommended to multiply the returned value with scaleFactor to get a coordinate relative to the full image and not just a coordinate relative to the e.g. 33% zoomed version of the image.

Example

%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;
}

Also see

getPreviewCoordY, getCtlCoord, scaleFactor

Comments

Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.