Hello,
Does anyone have a good example of a visual logic code that maintains the aspect ratios of images without the blurred edges while creating a maximum height and width of what the images can be? Thanks in advance.
Hello,
Does anyone have a good example of a visual logic code that maintains the aspect ratios of images without the blurred edges while creating a maximum height and width of what the images can be? Thanks in advance.
Originally posted by ****
You shouldn’t need visual logic to do this.. Just set the checkbox to maintain aspect on the quad, and on the “texture coords” tab, set the Mode to “Border”. Border mode will fill the outside with transparency instead of repeating the edge pixels. Depending on which version of software you have, newer versions have more options for the “maintain aspect ratio” modes.
Have you ever found a solution to do this with the material face of a slab? I would assume it would require scripting…
The hard bit is reading the original sizes of the image so you can do the calculation I think.
What would the scripting look like using the GetDimensions method? I would assume once you pull in the values, you would assign those to a text object to be able to make adjustments in visual logic with texture coordinates.
I have never done it but that sounds like the right idea. Out of interest I just did the first bit for you to see if it works as you would hope.
dim slab as xpSlabObject
dim mat as xpMaterial
dim textWidth, textHeight as xpTextObject
dim width, height as long
self.GetObjectByName(“mySlab”, slab)
slab.GetMaterial(0, mat)
mat.GetDimensions(width, height)
self.GetObjectByName(“matWidth”, textWidth)
self.GetObjectByName(“matHeight”, textHeight)
textWidth.Text = width
textHeight.Text = height
so the next stage would be to scale these accordingly.
I have to finish working on something so I need to get back to that so perhaps you can take it from here.
Otherwise I’ll come back a bit later.
That code worked to pull the width and height values of the material. I then used those 2 numbers to calculate the aspect ratio and attempted to use visual logic to create a greater than/equal or less than 1 statement. Where if the aspect ratio was greater than or equal to 1, the ratio would be divided by 2 to get TextCordX and TextCordY would stay as 1. The inverse was done for less than 1, where TextCordY was ratio doubled and TextCordX was 1. However, in visual logic the ratio number that was calculated would not go through to the multiply and divide blocks and was getting stuck. Feels like I am just on the edge of figuring this out…
Are you connecting it to the correct point of the multi / divide blocks?
Those text blocks are showing as blank.
If you are using VB to get sizes and ratio, just do the rest of the math in VB. It is much more succinct and easier to debug.
Do all the math in one place, not two. Trust me. Do not scatter your coding.
Text blocks are showing up blank on layout mode but not on sequencer mode. Scripting is for events: OnOnline and OnPreviewRender. As far as scripting all the math on VB to adjust the texture coordinates, I have never really done math on there so not quite sure how I would do that. I would assume that it requires text values to be integers instead.