You are not logged in.

jvh

Beginner

  • "jvh" started this thread

Posts: 14

Location: Mexico

  • Send private message

1

Monday, January 7th 2019, 3:18am

Draw a frame in aspect ratio

I'm trying to create frame in the center with an aspect ratio, when i set directly the pixels works fin but when is with variables does not draw the container


eg: for 2:1 works ok

div(aspect,2,1);
set(layer[imageCamera].height, "300");
set(layer[imageCamera].width, "600");
set(layer[imageCamera].align, center);

eg: for 2:1 doesnt works

div(aspect,2,1);
set(layer[imageCamera].height, "300");
mul(destwidth, layer[imageCamera].height, aspect);
set(layer[imageCamera].width, destwidth);
set(layer[imageCamera].align, center);



<layer name="introimage" type="container" align="center" width="100%" height="100%" bgcolor="0x000000" bgalpha="0.5" keep="true" visible="false" status="closed" parent="pano" >
<layer name="btn_21" style="skin_glow" url="views/21.png" align="topleft" x="30" y="180" scale="0.25" keep="true" onclick="act21();" />
<layer name="imageCamera" type="container" align="center" enable="true" capture="true" width="50%" height="50%" keep="true" bgalpha="0.0" bgborder="4 0xFFFFFF 4" parent="pano" >
</layer>
<action name="act21">
div(aspect,2,1);
trace(aspect); set(layer[imageCamera].height, "300");
mul(destwidth, layer[imageCamera].height, aspect);
set(layer[imageCamera].width, "600");
set(layer[imageCamera].align, center);
set(layer[btn_ind].y, 195); set(layer[btnImagePic].align,"top");
set(layer[btnImagePic].y,"75");
trace(get(layer[imageCamera].width));
trace(get(layer[imageCamera].height));
</action>

This post has been edited 2 times, last edit by "jvh" (Jan 7th 2019, 7:18am)


2

Monday, January 7th 2019, 11:24am

this is wrong
set(layer[imageCamera].width, destwidth);
you need
copy(layer[imageCamera].width, destwidth);


or do it directly
mul(layer[imageCamera].width, layer[imageCamera].height, aspect);


https://krpano.com/docu/actions/#copy

jvh

Beginner

  • "jvh" started this thread

Posts: 14

Location: Mexico

  • Send private message

3

Monday, January 7th 2019, 11:38pm

Thank you works perfect *smile*

Now after the
set(layer[imageCamera].align, center);



how can i get the x and y position for the frame?

This post has been edited 1 times, last edit by "jvh" (Mar 4th 2019, 7:39am)