========================
CODE SNIPPETS
========================
TITLE: Krpano View Configuration Examples
DESCRIPTION: Examples demonstrating different view configurations in krpano XML, including standard view, little planet, and flat pano setups.
SOURCE: https://krpano.com/docu/html5
LANGUAGE: xml
CODE:
```
```
LANGUAGE: xml
CODE:
```
```
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Full Embedding Example
DESCRIPTION: A complete example demonstrating how to include the krpano script, define the viewer container, and initialize the viewer using the `embedpano()` function with common parameters. This setup ensures the virtual tour is correctly displayed on the webpage.
SOURCE: https://krpano.com/docu/embedpano
LANGUAGE: html
CODE:
```
krpano Viewer
```
----------------------------------------
TITLE: Krpano View Setup Examples
DESCRIPTION: Demonstrates common krpano XML view configurations for different scenarios, including setting lookat points, field of view, distortion, zoom limits, and viewing modes.
SOURCE: https://krpano.com/docu/quickref
LANGUAGE: APIDOC
CODE:
```
Example 1: Set looking direction and field of view
Example 2: Setup a 'little planet' view
Example 3: Good setting for viewing a flat pano
```
----------------------------------------
TITLE: Calling an Action on Startup
DESCRIPTION: Demonstrates how to execute a custom action ('intro') automatically when the krpano tour starts by using the 'onstart' attribute in the tag. Includes examples of common actions like 'lookat', 'wait', and 'lookto'.
SOURCE: https://krpano.com/docu/index
LANGUAGE: krpano
CODE:
```
...
lookat(0,0,90);
wait(LOAD);
lookto(120,10,110);
lookto(-50,40,110);
lookto(0,0,90);
...
```
----------------------------------------
TITLE: Krpano XML Configuration Examples
DESCRIPTION: Illustrative examples of how to apply the described krpano XML attributes within a configuration.
SOURCE: https://krpano.com/docu/html5
LANGUAGE: xml
CODE:
```
```
LANGUAGE: xml
CODE:
```
```
LANGUAGE: xml
CODE:
```
```
LANGUAGE: xml
CODE:
```
```
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Krpano Math Examples
DESCRIPTION: Code examples demonstrating the use of krpano's mathematical operations.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano-actions
CODE:
```
add(myvar, 10);
add(myvar, 5, 3);
sub(myvar, 2);
sub(myvar, 10, 4);
mul(myvar, 2);
mul(myvar, 3, 5);
div(myvar, 2);
div(myvar, 10, 2);
mod(myvar, 3);
mod(myvar, 10, 3);
pow(myvar, 2);
pow(myvar, 3, 2);
```
----------------------------------------
TITLE: Style Application Example
DESCRIPTION: Provides a practical example of defining a style with an image URL and then applying that style to multiple hotspot elements.
SOURCE: https://krpano.com/docu/xml
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Krpano Scene Transition Example
DESCRIPTION: An example demonstrating how to define a local krpano action to trigger a 3D transition to a new scene using the set3dtransition and loadscene actions.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano
CODE:
```
set3dtransition("sphere", caller.ath, 0);
loadscene(get(newscene), null, MERGE, BLEND(0.5));
```
----------------------------------------
TITLE: Krpano Autorotation Control Examples
DESCRIPTION: Examples of how to interactively control krpano's autorotation using event handlers like 'onclick', 'onover', and 'onout'. These demonstrate toggling enabled state, starting, pausing, and resuming.
SOURCE: https://krpano.com/docu/api
LANGUAGE: APIDOC
CODE:
```
onclick="switch(autorotate.enabled);"
onclick="autorotate.start();"
onover="autorotate.pause();"
onout="autorotate.resume();"
```
----------------------------------------
TITLE: krpano Examples
DESCRIPTION: Links to various examples showcasing krpano's capabilities, including virtual tours, gigapixel images, depth mapping, 3D integration, and VR experiences.
SOURCE: https://krpano.com/docu/tools/testingserver
LANGUAGE: apidoc
CODE:
```
## krpano Examples
- **Virtual Tours**: Standard virtual tour examples.
- **Gigapixel**: Demonstrations of high-resolution image tours.
- **Depthmapping**: Examples using depth mapping techniques.
- **3D**: Integration of 3D models and scenes.
- **Gaussian Splatting**: Examples utilizing Gaussian Splatting technology.
- **ThreeJS**: Showcases integration with the Three.js library.
- **Layers**: Examples demonstrating layer functionality.
- **Maps**: Virtual tours incorporating map views.
- **Video**: Examples of panoramic video playback.
- **VR**: Virtual Reality experiences created with krpano.
- **Javascript**: Examples of JavaScript interaction with krpano.
```
----------------------------------------
TITLE: Krpano JavaScript API Example: Adding a Layer
DESCRIPTION: Example demonstrating how to use the JavaScript API to add a layer, set its properties like URL and alignment, and define click/hover actions.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: javascript
CODE:
```
var layer = krpano.addlayer('button');
krpano.set('layer[button].url', 'button.jpg');
krpano.set('layer[button].align', 'bottom');
krpano.set('layer[button].x', 10);
krpano.set('layer[button].y', 20);
krpano.set('layer[button].onhover', "showtext('hovering the new button')");
krpano.set('layer[button].onclick', 'removelayer(button)');
```
----------------------------------------
TITLE: Krpano Focus Examples
DESCRIPTION: Code examples for managing input focus in the krpano viewer using both action scripts and Javascript.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano-actions
CODE:
```
focus();
releasefocus();
```
LANGUAGE: javascript
CODE:
```
krpano.focus();
krpano.releasefocus();
```
----------------------------------------
TITLE: Arithmetic and Variable Manipulation Examples
DESCRIPTION: Illustrates common usage patterns for arithmetic actions like set, add, mul, div, sub, mod, and pow. These examples show how to perform calculations and update variables, including using mouse input and tweening.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano
CODE:
```
set(val, 1);
add(val, 1);
trace('val should be 2: val=',val);
```
LANGUAGE: krpano
CODE:
```
mul(doublewidth, width, 2.0);
```
LANGUAGE: krpano
CODE:
```
mul(scale, 0.5);
```
LANGUAGE: krpano
CODE:
```
div(result, vala, valb);
```
LANGUAGE: krpano
CODE:
```
add(dst,rotate,360);
tween(rotate,get(dst),5);
```
LANGUAGE: krpano
CODE:
```
add(xpos, mouse.x, mouse_x_offset);
```
LANGUAGE: krpano
CODE:
```
sub(destx, stagewidth, destwidth);
```
LANGUAGE: krpano
CODE:
```
div(aspect,16,9);
```
LANGUAGE: krpano
CODE:
```
mod(cur_hlookat,cur_hlookat,360);
```
LANGUAGE: krpano
CODE:
```
pow(sqrt,val,0.5);
```
----------------------------------------
TITLE: Full Embedding Example
DESCRIPTION: A complete example demonstrating how to include the krpano script, define the viewer container div, and call the embedpano() function with essential parameters to initialize the viewer.
SOURCE: https://krpano.com/docu/swfkrpanojs
LANGUAGE: html
CODE:
```
krpano Embedding Example
```
----------------------------------------
TITLE: krpanotools Maketiles Example: Tiling an Image
DESCRIPTION: Provides an example of using the krpanotools maketiles command to split an image into smaller tiles, specifying the output tile naming pattern and tile size.
SOURCE: https://krpano.com/docu/tools
LANGUAGE: shell
CODE:
```
krpanotools maketiles image.jpg tile_%v_%h.jpg 512
```
----------------------------------------
TITLE: Krpano Movement Examples
DESCRIPTION: Demonstrates the usage of krpano's movement and lookto actions with different motion types and parameters.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano
CODE:
```
moveto(100.0, 5, linear(10));
```
LANGUAGE: krpano
CODE:
```
zoomto(130, smooth());
```
LANGUAGE: krpano
CODE:
```
lookto(33, -22, 30, smooth(100, 50, 20));
```
LANGUAGE: krpano
CODE:
```
looktohotspot(hotspot1);
```
LANGUAGE: krpano
CODE:
```
looktohotspot(hotspot2, 40);
```
LANGUAGE: krpano
CODE:
```
looktohotspot(hotspot3, 25, smooth(100, 50, 20));
```
LANGUAGE: krpano
CODE:
```
looktohotspot(get(name));
```
----------------------------------------
TITLE: Setup HTTPS for krpano Testing Server with mkcert
DESCRIPTION: Instructions for setting up HTTPS for the krpano Testing Server using the mkcert tool. This involves installing a local certificate authority and generating certificates for specific IP addresses.
SOURCE: https://krpano.com/docu/tools/testingserver
LANGUAGE: APIDOC
CODE:
```
mkcert -install
- Description: Installs a local certificate authority (CA) certificate on your system. This CA will be used to authenticate certificates generated for your local development servers.
- Usage: Run this command once to establish trust for certificates created by mkcert.
mkcert
- Description: Generates a certificate and a private key for a specified IP address. This is crucial for enabling HTTPS on your local network.
- Parameters:
- IP_ADDRESS: The static IP address of the machine running the krpano Testing Server (e.g., 192.168.0.100).
- Output: Creates files like .pem (certificate) and -key.pem (private key) in the current directory.
- Example: mkcert 192.168.0.100
HTTPS Setup Steps:
1. Install mkcert and run `mkcert -install`.
2. Generate a certificate for your server's IP: `mkcert YOUR_IP_ADDRESS`.
3. Copy the generated .pem file to the root folder of your krpano Testing Server.
4. On iOS, open the .pem file via the server URL in Safari to install the certificate.
5. In the krpano Testing Server GUI, use the SSL Certificate Browse button to select one of the .pem files.
6. For the command-line version, use the `-cert` argument: `tour_testingserver.exe -cert=path/to/your.pem`.
7. Access the server using `https://YOUR_IP_ADDRESS`.
```
----------------------------------------
TITLE: Krpano Examples Overview
DESCRIPTION: Highlights various types of virtual tours and demos created with krpano, showcasing its versatility.
SOURCE: https://krpano.com/docu/releasenotes
LANGUAGE: apidoc
CODE:
```
Examples:
- Virtual Tours: Standard 360 virtual tours.
- Gigapixel: High-resolution, zoomable panoramas.
- Depthmapping: Utilizing depth information.
- 3D: Integration with 3D models and scenes.
- Gaussian Splatting: Support for Gaussian Splatting data.
- ThreeJS: Demos using Three.js integration.
- Layers: Demonstrating layered content.
- Maps: Virtual tours with map integration.
- Video: Panoramic video playback.
- VR: Virtual Reality experiences.
- Javascript: Examples of JS integration.
- Refer to: https://krpano.com/examples/
```
----------------------------------------
TITLE: krpano View Configuration Examples
DESCRIPTION: Provides examples of how to configure the krpano view element for different scenarios, including setting basic lookat and fov, creating a 'little planet' view, and optimizing for flat panoramas.
SOURCE: https://krpano.com/docu/xml
LANGUAGE: krpano XML
CODE:
```
```
----------------------------------------
TITLE: Krpano Context Menu Windows 7 Native Look Example
DESCRIPTION: An example that mimics the native look and feel of Windows 7 for the krpano context menu.
SOURCE: https://krpano.com/docu/quickref
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: OpenSSL 1.0 Installation for Windows
DESCRIPTION: Provides instructions and download links for installing OpenSSL 1.0 on Windows to resolve the 'cannot load ssleay32.dll' error, which is a dependency for some applications.
SOURCE: https://krpano.com/docu/tools/testingserver
LANGUAGE: APIDOC
CODE:
```
ERROR: cannot load ssleay32.dll
- Cause: This error indicates that the OpenSSL 1.0 libraries are not found on the system.
- Solution: Download and install the OpenSSL 1.0 Light version for Windows.
Download Link:
- [Win64OpenSSL_Light-1_0_2u.exe](https://slproweb.com/download/Win64OpenSSL_Light-1_0_2u.exe) (Source)
- [Win64OpenSSL_Light-1_0_2u.exe](https://krpano.com/download/files/Win64OpenSSL_Light-1_0_2u.exe) (Mirror)
Source Information:
- [Win32OpenSSL](https://slproweb.com/products/Win32OpenSSL.html)
```
----------------------------------------
TITLE: Krpano JavaScript API Example: Adding a Hotspot
DESCRIPTION: Example showing how to add a hotspot using the JavaScript API and set its URL property.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: javascript
CODE:
```
var hotspot = krpano.addhotspot('newspot');
krpano.set('hotspot[newspot].url', 'spot.png');
```
----------------------------------------
TITLE: Krpano Layer Example
DESCRIPTION: An example demonstrating the structure of a krpano layer element, including its name, URL, positioning attributes (align, x, y), and an onclick action.
SOURCE: https://krpano.com/docu/html5
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Krpano XML View Configuration Examples
DESCRIPTION: Illustrates how to configure the viewer's perspective and behavior using the '' XML element. Examples cover basic lookat and FOV settings, a 'little planet' effect, and settings for flat panoramas.
SOURCE: https://krpano.com/docu/api
LANGUAGE: XML
CODE:
```
```
LANGUAGE: XML
CODE:
```
```
LANGUAGE: XML
CODE:
```
```
----------------------------------------
TITLE: Conditional Logic Examples
DESCRIPTION: Demonstrates basic conditional checks using krpano's scripting language based on device properties.
SOURCE: https://krpano.com/docu/programming
LANGUAGE: krpano
CODE:
```
if(device.html5, ...);
```
LANGUAGE: krpano
CODE:
```
if(device.flash, ...);
```
LANGUAGE: krpano
CODE:
```
if(device.android, if(device.flash, ...); );
```
LANGUAGE: krpano
CODE:
```
if(device.iOSversion GT 5.1, ...);
```
----------------------------------------
TITLE: Krpano Context Menu Custom Style Example
DESCRIPTION: An example demonstrating a custom style configuration for the krpano context menu, allowing fine-grained control over appearance.
SOURCE: https://krpano.com/docu/quickref
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Krpano Array Properties and Actions
DESCRIPTION: Lists key properties and actions available for krpano arrays and their items. These include getting the item count, sorting arrays, and managing array items.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: APIDOC
CODE:
```
Array Properties/Actions:
count: Get or set the number of items in the array. Setting to 0 clears the array.
sortby(attribute, parameters): Sorts array items by a specified attribute. Parameters can include 'caseinsensitive', 'descending', 'numeric'.
createarrayitem(name or index): Adds a new item to the array.
removearrayitem(name or index): Removes an item from the array.
Array-Item Properties:
index: Read-only, 0-based index of the item.
name: The name of the array item. Setting to null deletes the item.
```
----------------------------------------
TITLE: krpano XML: Relative Width Example
DESCRIPTION: Illustrates using percentage values for positioning and sizing an area, specifically using 75% of the available width starting from 25% of the screen.
SOURCE: https://krpano.com/docu/html5
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: loadpano() and lookto() Example
DESCRIPTION: Shows loading a new panorama with blending and then using lookto() and wait(BLEND) to control camera orientation after loading.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano
CODE:
```
loadpano(pano2.xml,null,MERGE,BLEND(2));
lookat(100,50,5);
wait(BLEND);
lookto(100,50,150);
```
----------------------------------------
TITLE: Basic Control Configuration Examples
DESCRIPTION: Demonstrates common ways to configure the krpano control element for different behaviors like desktop interaction, zoom direction, and keyboard input.
SOURCE: https://krpano.com/docu/api
LANGUAGE: xml
CODE:
```
```
LANGUAGE: xml
CODE:
```
```
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Krpano Textstyle Example
DESCRIPTION: An example XML snippet demonstrating the configuration of a krpano textstyle with various attributes applied.
SOURCE: https://krpano.com/docu/html5
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Krpano Area Element Examples
DESCRIPTION: XML examples showing how to configure the '' element using both 'align' and 'border' modes.
SOURCE: https://krpano.com/docu/html5
LANGUAGE: xml
CODE:
```
```
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Krpano XML Example: Simple Logo
DESCRIPTION: An example of a simple krpano layer acting as a logo that opens a URL when clicked. It demonstrates basic attributes like url, alignment, positioning, and onclick action.
SOURCE: https://krpano.com/docu/quickref
LANGUAGE: XML
CODE:
```
```
----------------------------------------
TITLE: Krpano Linking Examples
DESCRIPTION: Provides practical examples of using the 'link:' attribute in Krpano XML for various scenarios, including simple variable linking, linking with expressions for formatting, combining multiple variables, linking to events, and using linking for responsive design.
SOURCE: https://krpano.com/docu/index
LANGUAGE: krpano-xml
CODE:
```
text="link:view.fov"
```
LANGUAGE: krpano-xml
CODE:
```
text="link:view.fov:roundval(view.fov,2)"
```
LANGUAGE: krpano-xml
CODE:
```
text="link:view.hlookat,view.vlookat:'Lookat:'+roundval(view.hlookat,2)+'/'+roundval(view.vlookat,2)"
```
LANGUAGE: krpano-xml
CODE:
```
text="link:event.onfullscreen,event.onexitfullscreen:fullscreen ? 'Exit Fullscreen' : 'Enter Fullscreen'"
```
LANGUAGE: krpano-xml
CODE:
```
scale="link:stagewidth:stagewidth LT 400 ? 0.7 : 1.0"
```
----------------------------------------
TITLE: krpano Control Settings Example
DESCRIPTION: Example configuration for user interaction controls in krpano, specifying how users can navigate the panorama using mouse and keyboard. It includes settings for user control types, interaction modes, and inertia/friction.
SOURCE: https://krpano.com/docu/quickref
LANGUAGE: XML
CODE:
```
```
----------------------------------------
TITLE: Krpano Stereoscopic Cube Image Example
DESCRIPTION: Example demonstrating how to configure stereoscopic display for a cube panorama using the 'stereo' and 'stereolabels' attributes.
SOURCE: https://krpano.com/docu/api
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: AS3 krpano Plugin Example
DESCRIPTION: This ActionScript 3 code demonstrates how to create a krpano plugin. It covers initialization, registering attributes and actions with the krpano interface, and handling graphical elements and resizing. Dependencies include the krpano Flash API.
SOURCE: https://krpano.com/docu/plugininterface/pluginexample
LANGUAGE: as3
CODE:
```
package
{
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.utils.*;
import flash.system.*;
[SWF(width="200", height="200", backgroundColor="#000000")]
public class pluginexample extends Sprite
{
// krpano and plugin interfacing objects
public var krpano : Object = null;
public var plugin : Object = null;
private var xml_value : Number = 100.0; // the value for a custom xml attribute
private var text : TextField = null; // example content (text)
public function pluginexample()
{
if (stage == null)
{
// normal startup when loaded as plugin inside krpano
// do nothing here, wait for the 'registerplugin' call from krpano
}
else
{
// direct/standalone startup - show the plugin information / version
stage.scaleMode = "noScale";
stage.align = "TL";
var txt:TextField = new TextField();
txt.defaultTextFormat = new TextFormat("_sans",14,0xFFFFFF,false,false,false,null,null,"center");
txt.autoSize = "center";
txt.htmlText = "krpano\npluginexample\nversion 1.0";
addChild(txt);
var resizefu:Function = function(event:Event=null):void
{
txt.x = (stage.stageWidth - txt.width)/2;
txt.y = (stage.stageHeight - txt.height)/2;
}
stage.addEventListener(Event.RESIZE, resizefu);
resizefu();
}
}
// registerplugin - startup point for the plugin (required)
// - krpanointerface = krpano interface object
// - pluginpath = the fully qualified plugin name (e.g. "plugin[name]")
// - pluginobject = the xml plugin object itself
public function registerplugin(krpanointerface:Object, pluginfullpath:String, pluginobject:Object):void
{
// get the krpano interface and the plugin object
krpano = krpanointerface;
plugin = pluginobject;
// first - say hello
krpano.trace(1, "hello from plugin[" + plugin.name + "]");
// add plugin attributes
plugin.registerattribute("mode", "normal");
plugin.registerattribute("value", xml_value, value_setter, value_getter);
// add plugin action (the attribute needs to be lowercase!)
plugin.dosomething = action_dosomething;
// optionally - add some graphical content:
// register the size of the content
plugin.registercontentsize(200,200);
// draw a background (on the plugin itself)
var g:Graphics = this.graphics;
g.beginFill(0x0A3264, 0.5);
g.drawRect(0,0, 200,200);
g.endFill();
// add a textfield
text = new TextField();
text.defaultTextFormat = new TextFormat("_sans",14,0xFFFFFF,false,false,false,null,null,"center");
text.autoSize = "center";
text.multiline = true;
text.mouseEnabled = false;
text.htmlText = "Flash
TEST PLUGIN
click me";
// the plugin itself is already a Flash Sprite Object,
// so to add addtional Flash DisplayObjects
// just add them to the plugin itself (to this):
this.addChild(text);
}
// unloadplugin - exit point for the plugin (optionally)
// - will be called from krpano when the plugin will be removed
// - everything that was added by the plugin should be removed here
public function unloadplugin():void
{
plugin = null;
krpano = null;
}
// onresize (optionally)
// - width,height = the new size for the plugin
// - when not defined then only the krpano plugin html element will be sized
// - can be used to resize sub elements manually
// return:
// - return true to let krpano scale the plugin automatically
// - return false to disable any automatic scaling
public function onresize(width:int, height:int):Boolean
{
// redraw the background with the new size
var g:Graphics = this.graphics;
g.clear();
g.beginFill(0x0A3264, 0.5);
g.drawRect(0,0, width,height);
g.endFill();
// center the text element
text.x = width/2 - text.textWidth/2;
text.y = height/2 - text.textHeight/2;
return false; // don't do any automatically scaling
}
private function value_setter(newvalue:Number):void
{
if (newvalue != xml_value)
{
xml_value = newvalue;
krpano.trace(1, "plugin[${plugin.name}].value = ${xml_value}");
}
}
private function value_getter():Number
{
return xml_value;
}
// example action function
private function action_dosomething(params:String):void
{
krpano.trace(1, "plugin[${plugin.name}].dosomething called with: ${params}");
// example: change the text content
text.htmlText = "Action called!\n" + params;
}
}
}
```
----------------------------------------
TITLE: Basic Tween Example
DESCRIPTION: A simple example demonstrating how to tween a variable 'scale' to the value '2'.
SOURCE: https://krpano.com/docu/programming
LANGUAGE: krpano
CODE:
```
tween(scale, 2);
```
----------------------------------------
TITLE: Krpano XML Preview Element Example
DESCRIPTION: An example of how to define a preview image within krpano XML, specifying its URL and strip order.
SOURCE: https://krpano.com/docu/index
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Control Fullscreen Mode
DESCRIPTION: Provides examples for switching krpano into fullscreen mode or toggling between fullscreen and windowed states. It highlights the use of the 'fullscreen' variable.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: XML
CODE:
```
onclick="set(fullscreen,true);"
```
LANGUAGE: XML
CODE:
```
onclick="toggle(fullscreen);"
```
----------------------------------------
TITLE: Krpano XML Preview Usage Examples
DESCRIPTION: Provides examples of how to use the element in Krpano XML to specify preview images, including using a static image file and a dynamically generated grid image.
SOURCE: https://krpano.com/docu/quickref
LANGUAGE: xml
CODE:
```
```
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Calling Actions with Parameter Passing
DESCRIPTION: Demonstrates how to call krpano actions with parameters and how to access these parameters within the action using positional placeholders like %1, %2. The example shows passing literal values and dynamic values obtained via get().
SOURCE: https://krpano.com/docu/api
LANGUAGE: krpano
CODE:
```
showlog();
trace('parameter1=',%1);
trace('parameter2=',%2);
trace('fov=',%3);
test('Test1', 'Test2', get(view.fov));
```
----------------------------------------
TITLE: Calling Actions on Startup and from Plugins
DESCRIPTION: Examples showing how to trigger actions. The first demonstrates calling an action ('intro') via the 'onstart' attribute of the element. The second shows calling actions ('overaction', 'outaction') from plugin events ('onover', 'onout').
SOURCE: https://krpano.com/docu/quickref
LANGUAGE: xml
CODE:
```
...
lookat(0,0,90);
wait(LOAD);
lookto(120,10,110);
lookto(-50,40,110);
lookto(0,0,90);
...
```
LANGUAGE: xml
CODE:
```
tween(scale, 2.0);
tween(alpha, 1.0);
tween(scale, 1.0);
tween(alpha, 0.5);
```
----------------------------------------
TITLE: Get Variable Value (get) - krpano Actions
DESCRIPTION: The 'get' action retrieves the value of a variable. It can be used as a standalone action or within other actions like 'set' or 'calc'. The asterisk (*) can be used as a shorthand for 'get(variable)' in certain contexts.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: APIDOC
CODE:
```
get(variable)
action( *variable, ... )
Retrieve the value of a variable.
Examples:
```
action( get(variable), ... )
```
```
action( *variable, ... )
```
```
----------------------------------------
TITLE: Krpano Action Call Syntax and Parameters
DESCRIPTION: Details how to call actions in krpano, which can be built-in actions, XML elements, or variables containing code or JavaScript functions. It illustrates various ways to pass parameters, including direct values, variables (using get() or *), expressions (using calc() or ()), and quoted strings.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano
CODE:
```
action(parameters);
action(parameter1, parameter2, parameter3);
action(get(variable));
action(*variable);
action(calc(expression));
action((expression));
action('a quoted text, can contain commas');
```
----------------------------------------
TITLE: Coordinate Conversion Example
DESCRIPTION: Example of using the screentosphere action to convert mouse screen coordinates to spherical coordinates.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano
CODE:
```
screentosphere(mouse.x, mouse.y, toh, tov);
```
----------------------------------------
TITLE: Krpano Raycast Usage Examples
DESCRIPTION: Demonstrates how to use raycast actions to find distances to surfaces and place hotspots on detected surfaces.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano
CODE:
```
// Get the distance to the next wall/surface in front of the viewer:
hit = raycast(view.tx, view.ty, view.tz, view.dir.x, view.dir.y, view.dir.z);
if(hit,
trace('distance to wall:', hit.d, 'cm');
);
```
LANGUAGE: krpano
CODE:
```
// Place a hotspot on the surface of a Depthmap / 3D-Model:
hit = screenraycast(mouse.x, mouse.y);
if(hit,
copy(hs.tx, hit.x);
copy(hs.ty, hit.y);
copy(hs.tz, hit.z);
copy(hs.rx, hit.rx);
copy(hs.ry, hit.ry);
copy(hs.rz, hit.rz);
);
```
----------------------------------------
TITLE: Basic Krpano XML Structure
DESCRIPTION: A fundamental example of a krpano XML file structure, demonstrating the root element with version and onstart attributes, and a basic definition.
SOURCE: https://krpano.com/docu/html5
LANGUAGE: xml
CODE:
```
...
```
----------------------------------------
TITLE: Direct JavaScript Access Example
DESCRIPTION: An example demonstrating how to achieve the same functionality as the legacy interface using direct JavaScript access to krpano objects and properties. This method is faster and often preferred.
SOURCE: https://krpano.com/docu/js
LANGUAGE: javascript
CODE:
```
var hs = krpano.actions.addhotspot("test");
hs.url = "image.png";
hs.ath = krpano.view.hlookat;
hs.atv = krpano.view.vlookat;
```
----------------------------------------
TITLE: Setting Hotspot Properties
DESCRIPTION: Demonstrates setting various properties for a krpano hotspot, including its position, scale, zoom behavior, and click action.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano
CODE:
```
set(hotspot[newspot].ath,150);
set(hotspot[newspot].atv,30);
set(hotspot[newspot].scale,0.7);
set(hotspot[newspot].zoom,true);
set(hotspot[newspot].onclick, removehotspot(newspot) );
```
----------------------------------------
TITLE: Calling Actions on Startup
DESCRIPTION: Example of how to call a krpano action ('intro') on startup by assigning it to the 'onstart' attribute of the element. The 'intro' action itself demonstrates sequential calls to other actions like 'lookat', 'wait', and 'lookto'.
SOURCE: https://krpano.com/docu/api
LANGUAGE: krpano
CODE:
```
...
lookat(0,0,90);
wait(LOAD);
lookto(120,10,110);
lookto(-50,40,110);
lookto(0,0,90);
...
```
----------------------------------------
TITLE: Getting Current Date with Javascript (jsget)
DESCRIPTION: Shows how to use `jsget()` to execute Javascript code that gets the current date and formats it, storing the result in a krpano variable.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano
CODE:
```
jsget(date, 'new Date().toISOString().slice(0,10);');
trace('date=', get(date));
```
----------------------------------------
TITLE: Krpano XML Preview Element Example
DESCRIPTION: An example of how to define a preview image within krpano XML, specifying its URL and strip order.
SOURCE: https://krpano.com/docu/api
LANGUAGE: xml
CODE:
```
```
----------------------------------------
TITLE: Krpano Adjustment and Tweening Examples
DESCRIPTION: Illustrates how to use adjusthlookat and adjust360 in krpano, often combined with the tween action for smooth visual updates.
SOURCE: https://krpano.com/docu/actions
LANGUAGE: krpano
CODE:
```
adjusthlookat(140);
tween(view.hlookat, 140);
```
LANGUAGE: krpano
CODE:
```
adjust360(hotspot[test].ath, view.hlookat);
tween(hotspot[test].ath, get(view.hlookat), 1.0);
```
----------------------------------------
TITLE: Krpano Stereoscopic Panoramic Video Example
DESCRIPTION: Example showing the configuration for stereoscopic display of a panoramic video using 'stereo' and 'stereoformat' attributes.
SOURCE: https://krpano.com/docu/api
LANGUAGE: xml
CODE:
```
```