You are not logged in.

publicitarios360

Intermediate

  • "publicitarios360" started this thread

Posts: 330

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • Send private message

1

Monday, December 11th 2017, 3:24am

Help: To finish Code for create dynamic image layer with border around. SOLVED

Hi, I working in easy code for show a picture as layer type Image:

Source code

1
2
3
4
5
6
<action name="create_picture_window">
addlayer(%1);
set(layer[%1].url,%2);
set(layer[%1].align,center);
set(layer[%1].onclick,removelayer(%1));
</action>


For use:
create_picture_window(mypicture1,picture1.jpg);

Very simple until now, but for add a background border: How to create that layer using width and height of the first layer created?

I tried creating container layer, copyng the width and height and add 15 px but not work.
Please helpme to complete this code, use the argument vars instead of % is too welcome.

Greets,

Fernando
publicitarios360 has attached the following image:
  • post.jpg

This post has been edited 3 times, last edit by "publicitarios360" (Dec 11th 2017, 4:14pm) with the following reason: solved label


PanLUX

Beginner

Posts: 26

Location: Zagreb, Croatia

  • Send private message

2

Monday, December 11th 2017, 9:52am

Try something like this

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<krpano version="1.19" title="Virtual Tour" debugmode="true" >

	<preview type="grid( cube,32,32,512,0xffcccc,0xeeeeee,0xffcccc );" />
	
	<layer name="layButton" type="container" align="lefttop" x="30" y="25" width="100"
			height="30" bgcolor="0xcccccc" bgalpha="1">
		<layer name="layButtCapt" type="text" align="center" background="false"
			css="font-size:14px; color:#0000ff;" html="Show image"
			onclick="set( layer[layButton].visible, false ); ShowImage( some_image.jpg );" />
	</layer>
	
	<layer name="layImgContainer" type="container" visible="false" maskchildren="true"
		align="center" bgborder="15 0x0000ff 0.5" bgroundedge="20">
	</layer>
	
	<action name="ShowImage">
		addlayer( layImg );
		set( layer[layImg],
			align='center',
			parent='layImgContainer',
			url=%1,
			onloaded='set( layer[layImgContainer].width, get( layer[layImg].width ) );
				set( layer[layImgContainer].height, get( layer[layImg].height ) );',
			onclick='set( layer[layImgContainer].visible, false );
				removelayer( layImg );
				set( layer[layButton].visible, true );'
		);
		set( layer[layImgContainer].visible, true );
	</action>

</krpano>

publicitarios360

Intermediate

  • "publicitarios360" started this thread

Posts: 330

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • Send private message

3

Monday, December 11th 2017, 1:41pm

Thanks very much Pantux, your solution is ok. My question was not.

I can“t use it the bgborder property, because I need to put objects inside this border (title, exit button). I would require add 15px to container layer width and similar value to height, for example 5px.

I think that the solution is way calc for add the border.
Very grateful,
Fernando.

This post has been edited 2 times, last edit by "publicitarios360" (Dec 11th 2017, 3:17pm)


publicitarios360

Intermediate

  • "publicitarios360" started this thread

Posts: 330

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • Send private message

4

Monday, December 11th 2017, 4:12pm

solved with INC

<action
name="creafoto_ventana">

<!-- the background or border-->
addlayer(fondo_%1);
set(layer[fondo_%1].type,container);
set(layer[fondo_%1].maskchildren,true);
set(layer[fondo_%1].align,center);
set(layer[fondo_%1].bgborder,5 0x0000ff 0.5);
set(layer[fondo_%1].bgroundedge,8);
set(layer[fondo_%1].bgalpha,1);
set(layer[fondo_%1].bgcolor,0x0000ff);
set(layer[fondo_%1].bgcapture,true);
set(layer[fondo_%1].ondown,draglayer(););

<!-- the picture -->
addlayer(%1);
set(layer[%1].url,%2);
set(layer[%1].align,center);
set(layer[%1].zorder,1);
set(layer[%1].parent,fondo_%1);
set(layer[%1].onloaded,
set(tempowidth,get(layer[%1].width));
inc(tempowidth,45);
set(layer[fondo_%1].width,get(tempowidth));
set(tempoheight,get(layer[%1].height));
inc(tempoheight,45);
set(layer[fondo_%1].height,get(tempoheight));

</action>

PanLUX

Beginner

Posts: 26

Location: Zagreb, Croatia

  • Send private message

5

Monday, December 11th 2017, 5:30pm

Source code

1
2
3
4
set(layer[%1].onloaded,
	set( layer[fondo_%1].width, calc( layer[%1].width + 45 ) );
	set( layer[fondo_%1].height, calc( layer[%1].height + 45 ) );
);

publicitarios360

Intermediate

  • "publicitarios360" started this thread

Posts: 330

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • Send private message

6

Tuesday, December 12th 2017, 1:11am

Thanks very much PanLux, your solution with calc instead inc is perfect. Now change it in my project.

Very grateful,

Fernando.

Similar threads