Visit ComfyUI Online for ready-to-use ComfyUI environment
Converts layer image pixel coordinates to percentage values relative to a background image for responsive design.
The LayerUtility: XY to Percent node is designed to convert pixel coordinates (x, y) of a layer image into percentage values relative to a background image. This conversion is particularly useful when you need to position elements dynamically or proportionally within a canvas, ensuring that the placement remains consistent regardless of the canvas size. By transforming absolute pixel values into percentages, this node helps maintain the relative positioning of elements, which is essential for responsive design and layout adjustments in AI art projects.
The background_image parameter expects an image input that serves as the reference canvas for the percentage calculations. This image provides the dimensions against which the x and y coordinates of the layer image will be compared.
The layer_image parameter requires an image input that represents the layer whose x and y coordinates will be converted to percentages. This image's dimensions are used to adjust the coordinates before converting them to percentage values.
The x parameter is an integer input representing the x-coordinate of the layer image in pixels. This value is adjusted by half the width of the layer image and then converted to a percentage of the background image's width. The default value is 0, with a minimum of -99999 and a maximum of 99999.
The y parameter is an integer input representing the y-coordinate of the layer image in pixels. This value is adjusted by half the height of the layer image and then converted to a percentage of the background image's height. The default value is 0, with a minimum of -99999 and a maximum of 99999.
The x_percent output is a float value representing the x-coordinate of the layer image as a percentage of the background image's width. This value helps in maintaining the relative horizontal positioning of the layer image within the background image.
The y_percent output is a float value representing the y-coordinate of the layer image as a percentage of the background image's height. This value helps in maintaining the relative vertical positioning of the layer image within the background image.
© Copyright 2024 RunComfy. All Rights Reserved.