<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.impvis.co.uk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=SarmpaviUthayakumar</id>
	<title>ImpVis Wiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.impvis.co.uk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=SarmpaviUthayakumar"/>
	<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Special:Contributions/SarmpaviUthayakumar"/>
	<updated>2026-04-13T04:17:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.36.0</generator>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1456</id>
		<title>Three.js</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1456"/>
		<updated>2022-08-22T00:37:02Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: Final edit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Author - Sarmpavi'''&lt;br /&gt;
&lt;br /&gt;
I developed an interactive visualisation using three.js on quantum gates and their effects on quantum states. This visualisation is intended for 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; and 4&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; undergraduate Physics students taking the Quantum Information module. I also created a design template (with the learning outcomes) which can be found on the Miro page under Bloch Sphere. As I developed this visualisation, I documented what I had learnt about three.js and how it can be used to create visualisations. Below is a summary of what I have learnt. &lt;br /&gt;
&lt;br /&gt;
'''Introduction'''&lt;br /&gt;
&lt;br /&gt;
This guidance page provides some basic information on how to use three.js including example code (which can be found on ImpVis’ GitHub) and some useful resources to learn and gain more knowledge about the package. Please note that the example code has been written by myself with only a few weeks of three.js experience – a lot of improvements can be made (some of which I have listed below) but I hope this will be somewhat useful for any beginners who are reading this. This page also assumes that you have some basic JavaScript/HTML/CSS knowledge.&lt;br /&gt;
&lt;br /&gt;
three.js is a library which allows you to create 3D content and is a useful tool when developing interactive visualisations. &lt;br /&gt;
&lt;br /&gt;
'''Installation:'''&lt;br /&gt;
&lt;br /&gt;
three.js can be installed by navigating to your project folder in your terminal and then typing:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;npm install three&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Once installed, import it into your JavaScript file: &lt;br /&gt;
[[File:Import threejs.png|thumb|Import three.js]]&lt;br /&gt;
&amp;lt;code&amp;gt;import * as THREE from &amp;quot;../node_modules/three/build/three.module.js&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
'''Orbit Controls:'''&lt;br /&gt;
&lt;br /&gt;
'''Orbit Controls:'''&lt;br /&gt;
&lt;br /&gt;
The Orbit Controls package must also be imported – this allows you to interact with (e.g. rotate, pan, zoom in/out) your 3D object. To import this into your JavaScript file: &lt;br /&gt;
[[File:Import OrbitControls.png|thumb|Import OrbitControls]]&lt;br /&gt;
&amp;lt;code&amp;gt;import {OrbitControls} from &amp;quot;../vendor_mods/three/examples/jsm/controls/OrbitControls.js&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scene'''&lt;br /&gt;
&lt;br /&gt;
First, we construct the ‘Scene’ which can be thought of as the canvas for the 3D object. To create the Scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const scene = new THREE.Scene()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The position of the scene can be adjust using CSS.&lt;br /&gt;
&lt;br /&gt;
'''Camera'''&lt;br /&gt;
&lt;br /&gt;
The Camera controls how the user views the 3D object on the scene. There are lots of different types of cameras but generally the ‘PerspectiveCamera’ is used where objects further away appear smaller just how the human eye sees things. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const camera = new THREE.PerspectiveCamera()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PerspectiveCamera takes several variables in which one can define the type of lens (wide-angle, telephoto) and the aspect ratio. If we want the Scene to cover the entire page, the aspect ratio is window.innerWidth/window.innerHeight. &lt;br /&gt;
&lt;br /&gt;
The position of the Camera can be changed by setting the x, y and z positions: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;camera.position.x = (enter float)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;camera.position.y = (enter float)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;camera.position.z = (enter float)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We must finally add the Camera to the Scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scene.add(camera)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Renderer'''&lt;br /&gt;
&lt;br /&gt;
Next we need the Renderer which can be thought of as taking a photo of the Scene through the perspective of the Camera. There are many types of Renderers, but the most common type is WebGLRenderer: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const renderer = new THREE.WebGLRenderer()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We would like the Renderer to fill the whole page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;renderer.setSize(window.innerWidth, window.innerHeight)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then add: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;document.body.append(renderer.domElement)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally add: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;renderer.render(scene, camera)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Controls'''&lt;br /&gt;
&lt;br /&gt;
To enable Orbit Controls and allow interaction with the objects in your Scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;var controls = new OrbitControls(camera, renderer.domElement)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To change the focal point of the controls: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;controls.target.set(x, y, z )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where x, y and z specify the position of the focal point.&lt;br /&gt;
&lt;br /&gt;
To disable panning: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;controls.enablePan = false&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To set the maximum angle at which you want to rotate about to, say 30 radians: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;controls.maxPolarAngle = 30&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mesh'''&lt;br /&gt;
&lt;br /&gt;
To add the 3D object, we use ‘Mesh’. The Mesh is made up of two variables: the geometry (the shape of the object) and the material (how the geometry looks). Let us take the example of a sphere.&lt;br /&gt;
&lt;br /&gt;
''Geometry:''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const geometry_sphere = new THREE.SphereGeometry(1,100,100)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the first input specifies the radius of the sphere, the second and third inputs specify the number of horizontal and vertical segments the sphere is divided into respectively (increasing the number results in a smoother sphere).&lt;br /&gt;
&lt;br /&gt;
''Material:''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const material_sphere = new THREE.MeshLambertMaterial({color: 0xB9F4FF,transparent:true, opacity:0.5})&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the input ‘color’ specifies the color of the material of the sphere whilst the ‘transparent’ and ‘opacity’ inputs specify the transparency of the material of the sphere (the ‘transparent’ variable must be set to true before specifying the opacity value).&lt;br /&gt;
&lt;br /&gt;
Defining the sphere as an object which takes ‘geometry_sphere' as the geometry variable and ‘material_sphere’ as the material variable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const sphere = new THREE.Mesh(geometry_sphere, material_sphere)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally add the sphere to the Scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scene.add(sphere)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Vectors'''&lt;br /&gt;
&lt;br /&gt;
Vectors can be implemented in the following way:&lt;br /&gt;
&lt;br /&gt;
Define variable: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const vector = new THREE.Vector3(1, 0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the inputs specify the x, y, and z values of the vector respectively.&lt;br /&gt;
&lt;br /&gt;
To display the vector as an arrow, we define an arrow with the direction of the defined vector. Before that, we must define the origin at which we want the vector to start. We define this origin, say at the position (0, 0, 0), as a vector: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const origin – new THREE.Vector3(0,0,0)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We define the arrow: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const vector_display = new THREE.ArrowHelper(vector, origin, 1, 0xffff00)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the inputs specify the direction, starting point, magnitude and color of the arrow respectively.&lt;br /&gt;
&lt;br /&gt;
Finally, add the vector to the scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scene.add(vector_display)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To rotate ‘vector’: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const vector_rotated = vector.applyaxisangle(axis, angle)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the first input ‘axis’ refers to the axis about which the vector is to be rotated, and the second input ‘angle’ refers to the angle of rotation.&lt;br /&gt;
&lt;br /&gt;
'''Coordinate axes'''&lt;br /&gt;
&lt;br /&gt;
To add coordinate axes: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const axes = new THREE.AxesHelper(1)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the input ‘1’ specifies the size of the coordinates axes.&lt;br /&gt;
[[File:Content screenshot part 1.png|thumb|Content screenshot part 1]]&lt;br /&gt;
[[File:Content screenshot part 2.png|thumb|Content screenshot part 2]]&lt;br /&gt;
Finally, add the axes to the scene: &lt;br /&gt;
[[File:Content screenshot part 3.png|thumb|Content screenshot part 3]]&lt;br /&gt;
[[File:Content screenshot part 4.png|thumb|Content screenshot part 4]]&lt;br /&gt;
&amp;lt;code&amp;gt;scene.add(axes)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Screenshot of three.js visualisation and content (see images):'''&lt;br /&gt;
&lt;br /&gt;
'''Things to work on in future:'''&lt;br /&gt;
&lt;br /&gt;
* Integration with the ImpVis template: Found it difficult to use import three.js into the template&lt;br /&gt;
* Removing the previous vectors each time the user wants to define and interact with a new state&lt;br /&gt;
* [[File:Template screenshot.png|thumb|Template screenshot]]Text on sphere to show the basis states (Pauli-x, Pauli-y and Pauli-z eigenstates)&lt;br /&gt;
* Explanations (see pdf)&lt;br /&gt;
&lt;br /&gt;
'''Resources and links'''&lt;br /&gt;
&lt;br /&gt;
* ''Guidance on the official three.js website:'' https://threejs.org/manual/#en/fundamentals&lt;br /&gt;
* ''Three.js coding tutorial: how to enhance a website by adding a 3D element? ft Bruno Simon - Prismic:'' https://www.youtube.com/watch?v=tVr89249gwM&lt;br /&gt;
* ''Three.JS Orbit Controls: Zoom, Pan, Rotate - SyntaxByte:'' https://www.youtube.com/watch?v=4ZgkMS5rH3E&lt;br /&gt;
* ''Three.js Crash Course for Absolute Beginners – DesignCourse:'' https://www.youtube.com/watch?v=6oFvqLfRnsU&lt;br /&gt;
* ''Getting Started With Your First three.js Project: Part 1 - The Setup:'' https://medium.com/nerd-for-tech/getting-started-with-your-first-three-js-project-part-one-the-setup-17f18660aecc&lt;br /&gt;
* ''Getting Started With Your First three.js Project: Part 2 - The Build:'' https://medium.com/nerd-for-tech/getting-started-with-your-first-three-js-project-part-two-the-build-3fd9a2f21418&lt;br /&gt;
&lt;br /&gt;
[[Category:Records]]&lt;br /&gt;
[[Category:Summer 2022]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=File:Content_screenshot_part_4.png&amp;diff=1455</id>
		<title>File:Content screenshot part 4.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=File:Content_screenshot_part_4.png&amp;diff=1455"/>
		<updated>2022-08-22T00:36:04Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Content screenshot part 4&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=File:Content_screenshot_part_3.png&amp;diff=1454</id>
		<title>File:Content screenshot part 3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=File:Content_screenshot_part_3.png&amp;diff=1454"/>
		<updated>2022-08-22T00:35:41Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Content screenshot part 3&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=File:Content_screenshot_part_2.png&amp;diff=1453</id>
		<title>File:Content screenshot part 2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=File:Content_screenshot_part_2.png&amp;diff=1453"/>
		<updated>2022-08-22T00:35:01Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Content screenshot part 2&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=File:Content_screenshot_part_1.png&amp;diff=1452</id>
		<title>File:Content screenshot part 1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=File:Content_screenshot_part_1.png&amp;diff=1452"/>
		<updated>2022-08-22T00:34:20Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Content screenshot part 1&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=File:Template_screenshot.png&amp;diff=1451</id>
		<title>File:Template screenshot.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=File:Template_screenshot.png&amp;diff=1451"/>
		<updated>2022-08-22T00:32:38Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Template screenshot&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=File:Import_OrbitControls.png&amp;diff=1450</id>
		<title>File:Import OrbitControls.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=File:Import_OrbitControls.png&amp;diff=1450"/>
		<updated>2022-08-22T00:24:21Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Import OrbitControls&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=File:Import_threejs.png&amp;diff=1449</id>
		<title>File:Import threejs.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=File:Import_threejs.png&amp;diff=1449"/>
		<updated>2022-08-22T00:23:07Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Import three.js&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1448</id>
		<title>Three.js</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1448"/>
		<updated>2022-08-22T00:21:04Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: edit 2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Author - Sarmpavi'''&lt;br /&gt;
&lt;br /&gt;
I developed an interactive visualisation using three.js on quantum gates and their effects on quantum states. This visualisation is intended for 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; and 4&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; undergraduate Physics students taking the Quantum Information module. I also created a design template (with the learning outcomes) which can be found on the Miro page under Bloch Sphere. As I developed this visualisation, I documented what I had learnt about three.js and how it can be used to create visualisations. Below is a summary of what I have learnt. &lt;br /&gt;
&lt;br /&gt;
'''Introduction'''&lt;br /&gt;
&lt;br /&gt;
This guidance page provides some basic information on how to use three.js including example code (which can be found on ImpVis’ GitHub) and some useful resources to learn and gain more knowledge about the package. Please note that the example code has been written by myself with only a few weeks of three.js experience – a lot of improvements can be made (some of which I have listed below) but I hope this will be somewhat useful for any beginners who are reading this. This page also assumes that you have some basic JavaScript/HTML/CSS knowledge.&lt;br /&gt;
&lt;br /&gt;
three.js is a library which allows you to create 3D content and is a useful tool when developing interactive visualisations. &lt;br /&gt;
&lt;br /&gt;
'''Installation:'''&lt;br /&gt;
&lt;br /&gt;
three.js can be installed by navigating to your project folder in your terminal and then typing:  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;npm install three&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Once installed, import it into your JavaScript file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;import * as THREE from &amp;quot;../node_modules/three/build/three.module.js&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Orbit Controls:'''&lt;br /&gt;
&lt;br /&gt;
The Orbit Controls package must also be imported – this allows you to interact with (e.g. rotate, pan, zoom in/out) your 3D object. To import this into your JavaScript file: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;import {OrbitControls} from &amp;quot;../vendor_mods/three/examples/jsm/controls/OrbitControls.js&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scene'''&lt;br /&gt;
&lt;br /&gt;
First, we construct the ‘Scene’ which can be thought of as the canvas for the 3D object. To create the Scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const scene = new THREE.Scene()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The position of the scene can be adjust using CSS.&lt;br /&gt;
&lt;br /&gt;
'''Camera'''&lt;br /&gt;
&lt;br /&gt;
The Camera controls how the user views the 3D object on the scene. There are lots of different types of cameras but generally the ‘PerspectiveCamera’ is used where objects further away appear smaller just how the human eye sees things. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const camera = new THREE.PerspectiveCamera()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PerspectiveCamera takes several variables in which one can define the type of lens (wide-angle, telephoto) and the aspect ratio. If we want the Scene to cover the entire page, the aspect ratio is window.innerWidth/window.innerHeight. &lt;br /&gt;
&lt;br /&gt;
The position of the Camera can be changed by setting the x, y and z positions: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;camera.position.x = (enter float)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;camera.position.y = (enter float)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;camera.position.z = (enter float)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We must finally add the Camera to the Scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scene.add(camera)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Renderer'''&lt;br /&gt;
&lt;br /&gt;
Next we need the Renderer which can be thought of as taking a photo of the Scene through the perspective of the Camera. There are many types of Renderers, but the most common type is WebGLRenderer: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const renderer = new THREE.WebGLRenderer()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We would like the Renderer to fill the whole page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;renderer.setSize(window.innerWidth, window.innerHeight)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We then add: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;document.body.append(renderer.domElement)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally add: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;renderer.render(scene, camera)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Controls'''&lt;br /&gt;
&lt;br /&gt;
To enable Orbit Controls and allow interaction with the objects in your Scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;var controls = new OrbitControls(camera, renderer.domElement)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To change the focal point of the controls: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;controls.target.set(x, y, z )&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where x, y and z specify the position of the focal point.&lt;br /&gt;
&lt;br /&gt;
To disable panning: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;controls.enablePan = false&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To set the maximum angle at which you want to rotate about to, say 30 radians: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;controls.maxPolarAngle = 30&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mesh'''&lt;br /&gt;
&lt;br /&gt;
To add the 3D object, we use ‘Mesh’. The Mesh is made up of two variables: the geometry (the shape of the object) and the material (how the geometry looks). Let us take the example of a sphere.&lt;br /&gt;
&lt;br /&gt;
''Geometry:''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const geometry_sphere = new THREE.SphereGeometry(1,100,100)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the first input specifies the radius of the sphere, the second and third inputs specify the number of horizontal and vertical segments the sphere is divided into respectively (increasing the number results in a smoother sphere).&lt;br /&gt;
&lt;br /&gt;
''Material:''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const material_sphere = new THREE.MeshLambertMaterial({color: 0xB9F4FF,transparent:true, opacity:0.5})&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the input ‘color’ specifies the color of the material of the sphere whilst the ‘transparent’ and ‘opacity’ inputs specify the transparency of the material of the sphere (the ‘transparent’ variable must be set to true before specifying the opacity value).&lt;br /&gt;
&lt;br /&gt;
Defining the sphere as an object which takes ‘geometry_sphere' as the geometry variable and ‘material_sphere’ as the material variable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const sphere = new THREE.Mesh(geometry_sphere, material_sphere)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally add the sphere to the Scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scene.add(sphere)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Vectors'''&lt;br /&gt;
&lt;br /&gt;
Vectors can be implemented in the following way:&lt;br /&gt;
&lt;br /&gt;
Define variable: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const vector = new THREE.Vector3(1, 0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the inputs specify the x, y, and z values of the vector respectively.&lt;br /&gt;
&lt;br /&gt;
To display the vector as an arrow, we define an arrow with the direction of the defined vector. Before that, we must define the origin at which we want the vector to start. We define this origin, say at the position (0, 0, 0), as a vector: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const origin – new THREE.Vector3(0,0,0)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We define the arrow: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const vector_display = new THREE.ArrowHelper(vector, origin, 1, 0xffff00)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the inputs specify the direction, starting point, magnitude and color of the arrow respectively.&lt;br /&gt;
&lt;br /&gt;
Finally, add the vector to the scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scene.add(vector_display)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To rotate ‘vector’: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const vector_rotated = vector.applyaxisangle(axis, angle)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the first input ‘axis’ refers to the axis about which the vector is to be rotated, and the second input ‘angle’ refers to the angle of rotation.&lt;br /&gt;
&lt;br /&gt;
'''Coordinate axes'''&lt;br /&gt;
&lt;br /&gt;
To add coordinate axes: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;const axes = new THREE.AxesHelper(1)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the input ‘1’ specifies the size of the coordinates axes.&lt;br /&gt;
&lt;br /&gt;
Finally, add the axes to the scene: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;scene.add(axes)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Screenshot of three.js visualisation and content (pdf):'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Things to work on in future:'''&lt;br /&gt;
&lt;br /&gt;
* Integration with the ImpVis template: Found it difficult to use import three.js into the template&lt;br /&gt;
* Removing the previous vectors each time the user wants to define and interact with a new state&lt;br /&gt;
* Text on sphere to show the basis states (Pauli-x, Pauli-y and Pauli-z eigenstates)&lt;br /&gt;
* Explanations (see pdf)&lt;br /&gt;
&lt;br /&gt;
'''Resources and links'''&lt;br /&gt;
&lt;br /&gt;
* ''Guidance on the official three.js website:'' https://threejs.org/manual/#en/fundamentals&lt;br /&gt;
* ''Three.js coding tutorial: how to enhance a website by adding a 3D element? ft Bruno Simon - Prismic:'' https://www.youtube.com/watch?v=tVr89249gwM&lt;br /&gt;
* ''Three.JS Orbit Controls: Zoom, Pan, Rotate - SyntaxByte:'' https://www.youtube.com/watch?v=4ZgkMS5rH3E&lt;br /&gt;
* ''Three.js Crash Course for Absolute Beginners – DesignCourse:'' https://www.youtube.com/watch?v=6oFvqLfRnsU&lt;br /&gt;
* ''Getting Started With Your First three.js Project: Part 1 - The Setup:'' https://medium.com/nerd-for-tech/getting-started-with-your-first-three-js-project-part-one-the-setup-17f18660aecc&lt;br /&gt;
* ''Getting Started With Your First three.js Project: Part 2 - The Build:'' https://medium.com/nerd-for-tech/getting-started-with-your-first-three-js-project-part-two-the-build-3fd9a2f21418&lt;br /&gt;
&lt;br /&gt;
[[Category:Records]]&lt;br /&gt;
[[Category:Summer 2022]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1447</id>
		<title>Three.js</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1447"/>
		<updated>2022-08-21T23:59:44Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Author - Sarmpavi'''&lt;br /&gt;
&lt;br /&gt;
I developed an interactive visualisation using three.js on quantum gates and their effects on quantum states. This visualisation is intended for 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; and 4&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; undergraduate Physics students taking the Quantum Information module. I also created a design template (with the learning outcomes) which can be found on the Miro page under Bloch Sphere. As I developed this visualisation, I documented what I had learnt about three.js and how it can be used to create visualisations. Below is a summary of what I have learnt. &lt;br /&gt;
&lt;br /&gt;
'''Introduction'''&lt;br /&gt;
&lt;br /&gt;
This guidance page provides some basic information on how to use three.js including example code (which can be found on ImpVis’ GitHub) and some useful resources to learn and gain more knowledge about the package. Please note that the example code has been written by myself with only a few weeks of three.js experience – a lot of improvements can be made (some of which I have listed below) but I hope this will be somewhat useful for any beginners who are reading this. This page also assumes that you have some basic JavaScript/HTML/CSS knowledge.&lt;br /&gt;
&lt;br /&gt;
three.js is a library which allows you to create 3D content and is a useful tool when developing interactive visualisations. &lt;br /&gt;
&lt;br /&gt;
'''Installation:'''&lt;br /&gt;
&lt;br /&gt;
three.js can be installed by navigating to your project folder in your terminal and then typing: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
npm install three&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Records]]&lt;br /&gt;
[[Category:Summer 2022]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1446</id>
		<title>Three.js</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1446"/>
		<updated>2022-08-21T23:58:37Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: edit 1&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Author - Sarmpavi'''&lt;br /&gt;
&lt;br /&gt;
I developed an interactive visualisation using three.js on quantum gates and their effects on quantum states. This visualisation is intended for 3&amp;lt;sup&amp;gt;rd&amp;lt;/sup&amp;gt; and 4&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; undergraduate Physics students taking the Quantum Information module. I also created a design template (with the learning outcomes) which can be found on the Miro page under Bloch Sphere. As I developed this visualisation, I documented what I had learnt about three.js and how it can be used to create visualisations. Below is a summary of what I have learnt. &lt;br /&gt;
&lt;br /&gt;
'''Introduction'''&lt;br /&gt;
&lt;br /&gt;
This guidance page provides some basic information on how to use three.js including example code (which can be found on ImpVis’ GitHub) and some useful resources to learn and gain more knowledge about the package. Please note that the example code has been written by myself with only a few weeks of three.js experience – a lot of improvements can be made (some of which I have listed below) but I hope this will be somewhat useful for any beginners who are reading this. This page also assumes that you have some basic JavaScript/HTML/CSS knowledge.&lt;br /&gt;
&lt;br /&gt;
three.js is a library which allows you to create 3D content and is a useful tool when developing interactive visualisations. &lt;br /&gt;
&lt;br /&gt;
'''Installation:'''&lt;br /&gt;
&lt;br /&gt;
three.js can be installed by navigating to your project folder in your terminal and then typing: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Records]]&lt;br /&gt;
[[Category:Summer 2022]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1444</id>
		<title>Three.js</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1444"/>
		<updated>2022-07-26T01:03:11Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: Added summer 2022 category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Introduction'''&lt;br /&gt;
&lt;br /&gt;
Author - Sarmpavi&lt;br /&gt;
&lt;br /&gt;
This page provides some basic information on how to use Three.js including example code and some useful resources to learn and gain more knowledge about the package. Please note that the example code has been written by myself with only a few weeks of Three.js experience – a lot of improvements can be made but I hope this will be somewhat useful for any beginners who are reading this. This page also assumes that you have some basic JavaScript/HTML/CSS knowledge.&lt;br /&gt;
&lt;br /&gt;
Three.js is a library which allows you to create 3D content and is a useful tool when developing interactive visualisations.&lt;br /&gt;
&lt;br /&gt;
'''Installation:'''&lt;br /&gt;
&lt;br /&gt;
Three.js can be installed by navigating to your project folder in your terminal and then typing: npm install three&lt;br /&gt;
&lt;br /&gt;
Once installed, import it into your JavaScript file: import * as THREE from &amp;quot;../node_modules/three/build/three.module.js&amp;quot;; (insert image)&lt;br /&gt;
&lt;br /&gt;
'''Orbit controls:'''&lt;br /&gt;
&lt;br /&gt;
The Orbit controls package must also be imported – this allows you to interact with (e.g. rotate, pan, zoom in/out) your 3D object. To import this into your JavaScript file - import {OrbitControls} from &amp;quot;../vendor_mods/three/examples/jsm/controls/OrbitControls.js&amp;quot;; (pic)&lt;br /&gt;
&lt;br /&gt;
'''Scene'''&lt;br /&gt;
&lt;br /&gt;
First, we construct the ‘Scene’ which can be thought of as the canvas for the 3D object. To create the Scene – const scene = new THREE.Scene() &lt;br /&gt;
&lt;br /&gt;
'''Camera'''&lt;br /&gt;
&lt;br /&gt;
The camera controls how the user views the 3D object on the scene. There are lots of different types of cameras but generally the ‘PerspectiveCamera’ is used where objects further away appear smaller just how the human eye sees things.&lt;br /&gt;
&lt;br /&gt;
const camera = new THREE.PerspectiveCamera()&lt;br /&gt;
&lt;br /&gt;
PerspectiveCamera takes several variables in which one can define the type of lens (wide-angle, telephoto) and the aspect ratio. If we want the scene to cover the entire page, the aspect ratio is window.innerWidth/window.innerHeight.&lt;br /&gt;
&lt;br /&gt;
The position of the camera can be changed by setting the x, y and z positions:&lt;br /&gt;
&lt;br /&gt;
camera.position.x = (enter float)&lt;br /&gt;
&lt;br /&gt;
camera.position.y = (enter float)&lt;br /&gt;
&lt;br /&gt;
camera.position.z = (enter float)&lt;br /&gt;
&lt;br /&gt;
We must finally add the camera to the Scene: scene.add(camera)&lt;br /&gt;
&lt;br /&gt;
'''Mesh'''&lt;br /&gt;
&lt;br /&gt;
To add the 3D object, we use ‘Mesh’. The Mesh is made up of two variables: the geometry (the shape of the object) and the material (how the geometry looks). Let us take the example of a sphere.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally add the object to the Scene:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Link to example code:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Screenshot of Three.js visualisation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Things to work on in future:&lt;br /&gt;
&lt;br /&gt;
-         Integration with the ImpVis template: Found it difficult to use import Three.js into the template&lt;br /&gt;
[[Category:Records]]&lt;br /&gt;
[[Category:Summer 2022]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1443</id>
		<title>Three.js</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Three.js&amp;diff=1443"/>
		<updated>2022-07-26T00:59:29Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: Three.js summer project review&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Introduction'''&lt;br /&gt;
&lt;br /&gt;
Author - Sarmpavi&lt;br /&gt;
&lt;br /&gt;
This page provides some basic information on how to use Three.js including example code and some useful resources to learn and gain more knowledge about the package. Please note that the example code has been written by myself with only a few weeks of Three.js experience – a lot of improvements can be made but I hope this will be somewhat useful for any beginners who are reading this. This page also assumes that you have some basic JavaScript/HTML/CSS knowledge.&lt;br /&gt;
&lt;br /&gt;
Three.js is a library which allows you to create 3D content and is a useful tool when developing interactive visualisations.&lt;br /&gt;
&lt;br /&gt;
'''Installation:'''&lt;br /&gt;
&lt;br /&gt;
Three.js can be installed by navigating to your project folder in your terminal and then typing: npm install three&lt;br /&gt;
&lt;br /&gt;
Once installed, import it into your JavaScript file: import * as THREE from &amp;quot;../node_modules/three/build/three.module.js&amp;quot;; (insert image)&lt;br /&gt;
&lt;br /&gt;
'''Orbit controls:'''&lt;br /&gt;
&lt;br /&gt;
The Orbit controls package must also be imported – this allows you to interact with (e.g. rotate, pan, zoom in/out) your 3D object. To import this into your JavaScript file - import {OrbitControls} from &amp;quot;../vendor_mods/three/examples/jsm/controls/OrbitControls.js&amp;quot;; (pic)&lt;br /&gt;
&lt;br /&gt;
'''Scene'''&lt;br /&gt;
&lt;br /&gt;
First, we construct the ‘Scene’ which can be thought of as the canvas for the 3D object. To create the Scene – const scene = new THREE.Scene() &lt;br /&gt;
&lt;br /&gt;
'''Camera'''&lt;br /&gt;
&lt;br /&gt;
The camera controls how the user views the 3D object on the scene. There are lots of different types of cameras but generally the ‘PerspectiveCamera’ is used where objects further away appear smaller just how the human eye sees things.&lt;br /&gt;
&lt;br /&gt;
const camera = new THREE.PerspectiveCamera()&lt;br /&gt;
&lt;br /&gt;
PerspectiveCamera takes several variables in which one can define the type of lens (wide-angle, telephoto) and the aspect ratio. If we want the scene to cover the entire page, the aspect ratio is window.innerWidth/window.innerHeight.&lt;br /&gt;
&lt;br /&gt;
The position of the camera can be changed by setting the x, y and z positions:&lt;br /&gt;
&lt;br /&gt;
camera.position.x = (enter float)&lt;br /&gt;
&lt;br /&gt;
camera.position.y = (enter float)&lt;br /&gt;
&lt;br /&gt;
camera.position.z = (enter float)&lt;br /&gt;
&lt;br /&gt;
We must finally add the camera to the Scene: scene.add(camera)&lt;br /&gt;
&lt;br /&gt;
'''Mesh'''&lt;br /&gt;
&lt;br /&gt;
To add the 3D object, we use ‘Mesh’. The Mesh is made up of two variables: the geometry (the shape of the object) and the material (how the geometry looks). Let us take the example of a sphere.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally add the object to the Scene:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Link to example code:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Screenshot of Three.js visualisation:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Things to work on in future:&lt;br /&gt;
&lt;br /&gt;
-         Integration with the ImpVis template: Found it difficult to use import Three.js into the template&lt;br /&gt;
[[Category:Records]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1437</id>
		<title>Basic Component Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1437"/>
		<updated>2022-07-18T10:35:04Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contains basic information on how to set up the Pane and Hotspot components in your visualisation code. For information on how to edit the components, see [[Editing ImpVis Components]]. The page assumes you have set up a new visualisation, as described [[Tutorial for setting up the coding environment#Creating a new visualisation|here]]. &lt;br /&gt;
[[File:Pane screenshot.png|thumb|Screenshot of the pane being implemented.]]&lt;br /&gt;
&lt;br /&gt;
== Panes ==&lt;br /&gt;
&lt;br /&gt;
[[Pane|Panes]] are clickable and draggable environments to place text and images over a visualisation. The code seen below is what's needed to produce the pane seen to the right of this text; this can also be seen on the left-hand side of [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_27.html Pane tutorial page]. &lt;br /&gt;
Code to implement the Pane seen on the right.&lt;br /&gt;
&lt;br /&gt;
== Adding content to the mainstage ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example implements a simple harmonic motion (SHM) graphic on the mainstage. Firstly, if you want to copy and paste this code, check out the SHM folder contained in the GitHub repository for this tutorial document at https://github.com/Imperial-visualizations/Tutorial. This document is intended to be useful seeing the logic of setting up such a visualisation, as opposed to providing the code to be changed. But please do spend some time messing around with it!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default {&lt;br /&gt;
    props:{&lt;br /&gt;
       mag: {&lt;br /&gt;
            default: 0.005,&lt;br /&gt;
  &lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    mounted(){&lt;br /&gt;
        let vm = this;&lt;br /&gt;
        let canvas = document.querySelector('canvas');&lt;br /&gt;
        let parent = document.getElementById('parent');&lt;br /&gt;
        let x = 50 + canvas.width/2;&lt;br /&gt;
        let dx = 0;&lt;br /&gt;
&lt;br /&gt;
        canvas.width = parent.offsetWidth;&lt;br /&gt;
        canvas.height = parent.offsetHeight;&lt;br /&gt;
        &lt;br /&gt;
        let c = canvas.getContext('2d');&lt;br /&gt;
        &lt;br /&gt;
        function animate(){&lt;br /&gt;
            requestAnimationFrame(animate);&lt;br /&gt;
        &lt;br /&gt;
                   &lt;br /&gt;
            c.clearRect(0,0,canvas.width, canvas.height);&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(0,0);&lt;br /&gt;
            c.lineTo(canvas.width, 0);&lt;br /&gt;
            c.lineTo(canvas.width, canvas.height);&lt;br /&gt;
            c.lineTo(0, canvas.height);&lt;br /&gt;
            c.lineTo(0, 0);&lt;br /&gt;
            c.strokeStyle = 'black';&lt;br /&gt;
            c.stroke();&lt;br /&gt;
            &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(x, canvas.height/2);&lt;br /&gt;
            c.lineTo(canvas.width/2, canvas.height/2);&lt;br /&gt;
            c.strokeStyle = 'blue';&lt;br /&gt;
            c.lineWidth = 2;&lt;br /&gt;
            c.stroke();&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.arc(x, canvas.height/2, 20, 0, Math.PI * 2); &lt;br /&gt;
            c.fillStyle = 'orange';&lt;br /&gt;
            c.fill();&lt;br /&gt;
           &lt;br /&gt;
             x += dx;&lt;br /&gt;
            dx += - mag * (x-canvas.width/2);&lt;br /&gt;
        }&lt;br /&gt;
        animate();&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code to produce an object which performs SHM is pasted to the left of this text. This should sit in the MainStage.vue file, as we want to treat the SHM block as a component, which we can use multiple times anywhere. Specifically, the code makes a basic SHM vis using a prop for any variables I may want to control with sliders/buttons. When you run this code, you should see a ball conducting SHM on the screen.&lt;br /&gt;
&lt;br /&gt;
Sliders which control the SHM motion can be be added, to see this in action, check out the App.vue file in the SHM vis, from there, you will be able to see how interaction with the MainStage component is brought about.&lt;br /&gt;
&lt;br /&gt;
== Toggleable hotspots ==&lt;br /&gt;
[[File:Toggleable hotspot screenshot.png|thumb|600x600px|Screenshot of the implementation of the toggleable hotspot.]]&lt;br /&gt;
&lt;br /&gt;
Hotspots overlay onto the page similarly to a Pane, but are smaller, and can be stuck on the corners or edges of a page. They can be used to house text or tools used to interact with a visualisation. The code pasted here demonstrates how to produce a ''toggleable'' hotspot, which is a hotspot that can be toggled in and out of the way of the visualisation.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An interactive version of the toggleable hotspot is found on the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_28.html toggle hotspot] page of the ImpVis tutorial.&lt;br /&gt;
&lt;br /&gt;
== Fixed hotspots ==&lt;br /&gt;
Hotspots can also be fixed in position so that they ''always'' appear onscreen, as opposed to being toggleable where they can be brought on and off. For example now, to add a fixed hotspot to the code on the previous page, we could write the code as seen below. &lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
				&amp;lt;iv-fixed-hotspot position=&amp;quot;topright&amp;quot; title=&amp;quot;Fixed&amp;quot;&amp;gt;&lt;br /&gt;
                    This will go inside the fixed hotspot, so will always appear on the screen. &lt;br /&gt;
                    P.S. You must specify a title and position&lt;br /&gt;
				&amp;lt;/iv-fixed-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Fixed hotspot screenshot.png|thumb|Fixed hotspot screenshot]]&lt;br /&gt;
Notice how the hotspot overlays over the main content of the visualisation. We will later discuss how to use this feature effectively when designing the learning journey for the users of your visualisations. The screenshotted code would produce a fixed hotspot in the top right of the page. For this demonstration, I have displayed the hotspot in the bottom right for clarity. See the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_29.html tutorial page on fixed hotspots] to see this implemented online.&lt;br /&gt;
&lt;br /&gt;
== Importing your own components ==&lt;br /&gt;
Say you wanted to create your own component that does its own thing, you can import this as a separate file and use it in your visualisations. &lt;br /&gt;
[[File:Filename.png|thumb|Mainstage.vue file]]&lt;br /&gt;
In order to use the file (which we will call MainStage.vue for now), you must export it. Everything you might want to use outside of the MainStage.vue file is written in the export default code block.&lt;br /&gt;
&lt;br /&gt;
For example, we might want to create a canvas that we can display some interactive content in (check out the SHM visualisation, we'll go through some of that content here). To do this, we'd write the following pieces of code:&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default{&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line highlight=&amp;quot;17&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
				&amp;lt;iv-fixed-hotspot position=&amp;quot;topright&amp;quot; title=&amp;quot;Fixed&amp;quot;&amp;gt;&lt;br /&gt;
                    This will go inside the fixed hotspot, so will always appear on the screen. &lt;br /&gt;
                     P.S. You must specify a title and position&lt;br /&gt;
				&amp;lt;/iv-fixed-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
			&amp;lt;MainStage&amp;gt;&amp;lt;/MainStage&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
import {name} from ‘../package.json’;&lt;br /&gt;
import MainStage from ‘.components/MainStage.vue’;&lt;br /&gt;
&lt;br /&gt;
export default {&lt;br /&gt;
	name: &amp;quot;App&amp;quot;,&lt;br /&gt;
	components: {&lt;br /&gt;
		MainStage,&lt;br /&gt;
	},&lt;br /&gt;
	data(){&lt;br /&gt;
		return {&lt;br /&gt;
			projectName: name&lt;br /&gt;
		}&lt;br /&gt;
	},&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.) Place the input from mainstage into the correct part of template (where you want it to go) in App.vue &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
  	&amp;lt;div id=&amp;quot;parent&amp;quot; style=&amp;quot;height: 50%; width: 50%; padding: 50px;&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;canvas id=&amp;quot;canvas&amp;quot;&amp;gt;&amp;lt;/canvas&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default {&lt;br /&gt;
    mounted(){&lt;br /&gt;
        let canvas = document.querySelector('canvas');&lt;br /&gt;
        let parent = document.getElementById('parent');&lt;br /&gt;
&lt;br /&gt;
        canvas.width = parent.offsetWidth;&lt;br /&gt;
        canvas.height = parent.offsetHeight;&lt;br /&gt;
        &lt;br /&gt;
        let c = canvas.getContext('2d');&lt;br /&gt;
        &lt;br /&gt;
        function animate(){&lt;br /&gt;
            requestAnimationFrame(animate);&lt;br /&gt;
        &lt;br /&gt;
                   &lt;br /&gt;
            c.clearRect(0,0,canvas.width, canvas.height);&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(0,0);&lt;br /&gt;
            c.lineTo(canvas.width, 0);&lt;br /&gt;
            c.lineTo(canvas.width, canvas.height);&lt;br /&gt;
            c.lineTo(0, canvas.height);&lt;br /&gt;
            c.lineTo(0, 0);&lt;br /&gt;
            c.strokeStyle = 'black';&lt;br /&gt;
            c.stroke();&lt;br /&gt;
        }&lt;br /&gt;
        animate();&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.) Insert the code that draws a box around the edges of the canvas drawing area on the screen (that's what we currently want to do, so we can see the canvas).&lt;br /&gt;
&lt;br /&gt;
A screenshot of the result of this code is pasted below.&lt;br /&gt;
[[File:Canvas box display.7731b0f1.png|center|thumb|600x600px|Canvas box result displayed.]]&lt;br /&gt;
[[Category:Coding Guidance]]&lt;br /&gt;
[[Category:Tips Whilst Coding]]&lt;br /&gt;
[[Category:ImpVis Template]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=How_to_Make_the_Template_Mobile_Friendly&amp;diff=1436</id>
		<title>How to Make the Template Mobile Friendly</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=How_to_Make_the_Template_Mobile_Friendly&amp;diff=1436"/>
		<updated>2022-07-18T09:51:20Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The current template is using CSS grid style, the position of the hotspots are set to be in specific grid areas. To see this, go to the visualisation component under the layout folder and scroll down to css style:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot; line&amp;gt;&lt;br /&gt;
.hotspot-manager{&lt;br /&gt;
	display: grid;&lt;br /&gt;
	grid-template-areas: &amp;quot;topleft top topright&amp;quot; &amp;quot;left . right&amp;quot; &amp;quot;bottomleft bottom bottomright&amp;quot;;&lt;br /&gt;
	height: 100%;&lt;br /&gt;
	width: 100%;&lt;br /&gt;
	pointer-events: none;&lt;br /&gt;
	position: absolute;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If we want to make it mobile friendly, one thing we can do is to have different grid settings in different type of screens (differ by maximum width). An example of this can be found at https://dodung1221.medium.com/best-way-to-design-web-responsive-with-grid-view-in-css-ad44cb5974a4 . In the example, the grod layout was only specified by columns. However, given the hotspot we want to implement, we need both row and column to be written in percentages.&lt;br /&gt;
[[Category:Maintaining ImpVis]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1427</id>
		<title>Basic Component Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1427"/>
		<updated>2022-07-13T09:49:41Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: /* Importing your own components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contains basic information on how to set up the Pane and Hotspot components in your visualisation code. For information on how to edit the components, see [[Editing ImpVis Components]]. The page assumes you have set up a new visualisation, as described [[Tutorial for setting up the coding environment#Creating a new visualisation|here]]. &lt;br /&gt;
[[File:Pane screenshot.png|thumb|Screenshot of the pane being implemented.]]&lt;br /&gt;
&lt;br /&gt;
== Panes ==&lt;br /&gt;
&lt;br /&gt;
[[Pane|Panes]] are clickable and draggable environments to place text and images over a visualisation. The code seen below is what's needed to produce the pane seen to the right of this text; this can also be seen on the left-hand side of [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_27.html Pane tutorial page]. &lt;br /&gt;
Code to implement the Pane seen on the right.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
def quick_sort(arr):&lt;br /&gt;
	less = []&lt;br /&gt;
	pivot_list = []&lt;br /&gt;
	more = []&lt;br /&gt;
	if len(arr) &amp;lt;= 1:&lt;br /&gt;
		return arr&lt;br /&gt;
	else:&lt;br /&gt;
		pass&lt;br /&gt;
‎&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding content to the mainstage ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example implements a simple harmonic motion (SHM) graphic on the mainstage. Firstly, if you want to copy and paste this code, check out the SHM folder contained in the GitHub repository for this tutorial document at https://github.com/Imperial-visualizations/Tutorial. This document is intended to be useful seeing the logic of setting up such a visualisation, as opposed to providing the code to be changed. But please do spend some time messing around with it!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default {&lt;br /&gt;
    props:{&lt;br /&gt;
       mag: {&lt;br /&gt;
            default: 0.005,&lt;br /&gt;
  &lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    mounted(){&lt;br /&gt;
        let vm = this;&lt;br /&gt;
        let canvas = document.querySelector('canvas');&lt;br /&gt;
        let parent = document.getElementById('parent');&lt;br /&gt;
        let x = 50 + canvas.width/2;&lt;br /&gt;
        let dx = 0;&lt;br /&gt;
&lt;br /&gt;
        canvas.width = parent.offsetWidth;&lt;br /&gt;
        canvas.height = parent.offsetHeight;&lt;br /&gt;
        &lt;br /&gt;
        let c = canvas.getContext('2d');&lt;br /&gt;
        &lt;br /&gt;
        function animate(){&lt;br /&gt;
            requestAnimationFrame(animate);&lt;br /&gt;
        &lt;br /&gt;
                   &lt;br /&gt;
            c.clearRect(0,0,canvas.width, canvas.height);&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(0,0);&lt;br /&gt;
            c.lineTo(canvas.width, 0);&lt;br /&gt;
            c.lineTo(canvas.width, canvas.height);&lt;br /&gt;
            c.lineTo(0, canvas.height);&lt;br /&gt;
            c.lineTo(0, 0);&lt;br /&gt;
            c.strokeStyle = 'black';&lt;br /&gt;
            c.stroke();&lt;br /&gt;
            &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(x, canvas.height/2);&lt;br /&gt;
            c.lineTo(canvas.width/2, canvas.height/2);&lt;br /&gt;
            c.strokeStyle = 'blue';&lt;br /&gt;
            c.lineWidth = 2;&lt;br /&gt;
            c.stroke();&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.arc(x, canvas.height/2, 20, 0, Math.PI * 2); &lt;br /&gt;
            c.fillStyle = 'orange';&lt;br /&gt;
            c.fill();&lt;br /&gt;
           &lt;br /&gt;
             x += dx;&lt;br /&gt;
            dx += - mag * (x-canvas.width/2);&lt;br /&gt;
        }&lt;br /&gt;
        animate();&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code to produce an object which performs SHM is pasted to the left of this text. This should sit in the MainStage.vue file, as we want to treat the SHM block as a component, which we can use multiple times anywhere. Specifically, the code makes a basic SHM vis using a prop for any variables I may want to control with sliders/buttons. When you run this code, you should see a ball conducting SHM on the screen.&lt;br /&gt;
&lt;br /&gt;
Sliders which control the SHM motion can be be added, to see this in action, check out the App.vue file in the SHM vis, from there, you will be able to see how interaction with the MainStage component is brought about.&lt;br /&gt;
&lt;br /&gt;
== Toggleable hotspots ==&lt;br /&gt;
[[File:Toggleable hotspot screenshot.png|thumb|600x600px|Screenshot of the implementation of the toggleable hotspot.]]&lt;br /&gt;
&lt;br /&gt;
Hotspots overlay onto the page similarly to a Pane, but are smaller, and can be stuck on the corners or edges of a page. They can be used to house text or tools used to interact with a visualisation. The code pasted here demonstrates how to produce a ''toggleable'' hotspot, which is a hotspot that can be toggled in and out of the way of the visualisation.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An interactive version of the toggleable hotspot is found on the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_28.html toggle hotspot] page of the ImpVis tutorial.&lt;br /&gt;
&lt;br /&gt;
== Fixed hotspots ==&lt;br /&gt;
Hotspots can also be fixed in position so that they ''always'' appear onscreen, as opposed to being toggleable where they can be brought on and off. For example now, to add a fixed hotspot to the code on the previous page, we could write the code as seen below. &lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
				&amp;lt;iv-fixed-hotspot position=&amp;quot;topright&amp;quot; title=&amp;quot;Fixed&amp;quot;&amp;gt;&lt;br /&gt;
                    This will go inside the fixed hotspot, so will always appear on the screen. &lt;br /&gt;
                    P.S. You must specify a title and position&lt;br /&gt;
				&amp;lt;/iv-fixed-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Fixed hotspot screenshot.png|thumb|Fixed hotspot screenshot]]&lt;br /&gt;
Notice how the hotspot overlays over the main content of the visualisation. We will later discuss how to use this feature effectively when designing the learning journey for the users of your visualisations. The screenshotted code would produce a fixed hotspot in the top right of the page. For this demonstration, I have displayed the hotspot in the bottom right for clarity. See the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_29.html tutorial page on fixed hotspots] to see this implemented online.&lt;br /&gt;
&lt;br /&gt;
== Importing your own components ==&lt;br /&gt;
Say you wanted to create your own component that does its own thing, you can import this as a separate file and use it in your visualisations. &lt;br /&gt;
[[File:Filename.png|thumb|Mainstage.vue file]]&lt;br /&gt;
In order to use the file (which we will call MainStage.vue for now), you must export it. Everything you might want to use outside of the MainStage.vue file is written in the export default code block.&lt;br /&gt;
&lt;br /&gt;
For example, we might want to create a canvas that we can display some interactive content in (check out the SHM visualisation, we'll go through some of that content here). To do this, we'd write the following pieces of code:&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default{&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line highlight=&amp;quot;17&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
				&amp;lt;iv-fixed-hotspot position=&amp;quot;topright&amp;quot; title=&amp;quot;Fixed&amp;quot;&amp;gt;&lt;br /&gt;
                    This will go inside the fixed hotspot, so will always appear on the screen. &lt;br /&gt;
                     P.S. You must specify a title and position&lt;br /&gt;
				&amp;lt;/iv-fixed-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
			&amp;lt;MainStage&amp;gt;&amp;lt;/MainStage&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
import {name} from ‘../package.json’;&lt;br /&gt;
import MainStage from ‘.components/MainStage.vue’;&lt;br /&gt;
&lt;br /&gt;
export default {&lt;br /&gt;
	name: &amp;quot;App&amp;quot;,&lt;br /&gt;
	components: {&lt;br /&gt;
		MainStage,&lt;br /&gt;
	},&lt;br /&gt;
	data(){&lt;br /&gt;
		return {&lt;br /&gt;
			projectName: name&lt;br /&gt;
		}&lt;br /&gt;
	},&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.) Place the input from mainstage into the correct part of template (where you want it to go) in App.vue &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
  	&amp;lt;div id=&amp;quot;parent&amp;quot; style=&amp;quot;height: 50%; width: 50%; padding: 50px;&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;canvas id=&amp;quot;canvas&amp;quot;&amp;gt;&amp;lt;/canvas&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default {&lt;br /&gt;
    mounted(){&lt;br /&gt;
        let canvas = document.querySelector('canvas');&lt;br /&gt;
        let parent = document.getElementById('parent');&lt;br /&gt;
&lt;br /&gt;
        canvas.width = parent.offsetWidth;&lt;br /&gt;
        canvas.height = parent.offsetHeight;&lt;br /&gt;
        &lt;br /&gt;
        let c = canvas.getContext('2d');&lt;br /&gt;
        &lt;br /&gt;
        function animate(){&lt;br /&gt;
            requestAnimationFrame(animate);&lt;br /&gt;
        &lt;br /&gt;
                   &lt;br /&gt;
            c.clearRect(0,0,canvas.width, canvas.height);&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(0,0);&lt;br /&gt;
            c.lineTo(canvas.width, 0);&lt;br /&gt;
            c.lineTo(canvas.width, canvas.height);&lt;br /&gt;
            c.lineTo(0, canvas.height);&lt;br /&gt;
            c.lineTo(0, 0);&lt;br /&gt;
            c.strokeStyle = 'black';&lt;br /&gt;
            c.stroke();&lt;br /&gt;
        }&lt;br /&gt;
        animate();&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.) Insert the code that draws a box around the edges of the canvas drawing area on the screen (that's what we currently want to do, so we can see the canvas).&lt;br /&gt;
&lt;br /&gt;
A screenshot of the result of this code is pasted below.&lt;br /&gt;
[[File:Canvas box display.7731b0f1.png|center|thumb|600x600px|Canvas box result displayed.]]&lt;br /&gt;
[[Category:Coding Guidance]]&lt;br /&gt;
[[Category:Tips Whilst Coding]]&lt;br /&gt;
[[Category:ImpVis Template]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1426</id>
		<title>Basic Component Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1426"/>
		<updated>2022-07-13T09:34:44Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: /* Importing your own components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contains basic information on how to set up the Pane and Hotspot components in your visualisation code. For information on how to edit the components, see [[Editing ImpVis Components]]. The page assumes you have set up a new visualisation, as described [[Tutorial for setting up the coding environment#Creating a new visualisation|here]]. &lt;br /&gt;
[[File:Pane screenshot.png|thumb|Screenshot of the pane being implemented.]]&lt;br /&gt;
&lt;br /&gt;
== Panes ==&lt;br /&gt;
&lt;br /&gt;
[[Pane|Panes]] are clickable and draggable environments to place text and images over a visualisation. The code seen below is what's needed to produce the pane seen to the right of this text; this can also be seen on the left-hand side of [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_27.html Pane tutorial page]. &lt;br /&gt;
Code to implement the Pane seen on the right.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
def quick_sort(arr):&lt;br /&gt;
	less = []&lt;br /&gt;
	pivot_list = []&lt;br /&gt;
	more = []&lt;br /&gt;
	if len(arr) &amp;lt;= 1:&lt;br /&gt;
		return arr&lt;br /&gt;
	else:&lt;br /&gt;
		pass&lt;br /&gt;
‎&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding content to the mainstage ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example implements a simple harmonic motion (SHM) graphic on the mainstage. Firstly, if you want to copy and paste this code, check out the SHM folder contained in the GitHub repository for this tutorial document at https://github.com/Imperial-visualizations/Tutorial. This document is intended to be useful seeing the logic of setting up such a visualisation, as opposed to providing the code to be changed. But please do spend some time messing around with it!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default {&lt;br /&gt;
    props:{&lt;br /&gt;
       mag: {&lt;br /&gt;
            default: 0.005,&lt;br /&gt;
  &lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    mounted(){&lt;br /&gt;
        let vm = this;&lt;br /&gt;
        let canvas = document.querySelector('canvas');&lt;br /&gt;
        let parent = document.getElementById('parent');&lt;br /&gt;
        let x = 50 + canvas.width/2;&lt;br /&gt;
        let dx = 0;&lt;br /&gt;
&lt;br /&gt;
        canvas.width = parent.offsetWidth;&lt;br /&gt;
        canvas.height = parent.offsetHeight;&lt;br /&gt;
        &lt;br /&gt;
        let c = canvas.getContext('2d');&lt;br /&gt;
        &lt;br /&gt;
        function animate(){&lt;br /&gt;
            requestAnimationFrame(animate);&lt;br /&gt;
        &lt;br /&gt;
                   &lt;br /&gt;
            c.clearRect(0,0,canvas.width, canvas.height);&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(0,0);&lt;br /&gt;
            c.lineTo(canvas.width, 0);&lt;br /&gt;
            c.lineTo(canvas.width, canvas.height);&lt;br /&gt;
            c.lineTo(0, canvas.height);&lt;br /&gt;
            c.lineTo(0, 0);&lt;br /&gt;
            c.strokeStyle = 'black';&lt;br /&gt;
            c.stroke();&lt;br /&gt;
            &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(x, canvas.height/2);&lt;br /&gt;
            c.lineTo(canvas.width/2, canvas.height/2);&lt;br /&gt;
            c.strokeStyle = 'blue';&lt;br /&gt;
            c.lineWidth = 2;&lt;br /&gt;
            c.stroke();&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.arc(x, canvas.height/2, 20, 0, Math.PI * 2); &lt;br /&gt;
            c.fillStyle = 'orange';&lt;br /&gt;
            c.fill();&lt;br /&gt;
           &lt;br /&gt;
             x += dx;&lt;br /&gt;
            dx += - mag * (x-canvas.width/2);&lt;br /&gt;
        }&lt;br /&gt;
        animate();&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code to produce an object which performs SHM is pasted to the left of this text. This should sit in the MainStage.vue file, as we want to treat the SHM block as a component, which we can use multiple times anywhere. Specifically, the code makes a basic SHM vis using a prop for any variables I may want to control with sliders/buttons. When you run this code, you should see a ball conducting SHM on the screen.&lt;br /&gt;
&lt;br /&gt;
Sliders which control the SHM motion can be be added, to see this in action, check out the App.vue file in the SHM vis, from there, you will be able to see how interaction with the MainStage component is brought about.&lt;br /&gt;
&lt;br /&gt;
== Toggleable hotspots ==&lt;br /&gt;
[[File:Toggleable hotspot screenshot.png|thumb|600x600px|Screenshot of the implementation of the toggleable hotspot.]]&lt;br /&gt;
&lt;br /&gt;
Hotspots overlay onto the page similarly to a Pane, but are smaller, and can be stuck on the corners or edges of a page. They can be used to house text or tools used to interact with a visualisation. The code pasted here demonstrates how to produce a ''toggleable'' hotspot, which is a hotspot that can be toggled in and out of the way of the visualisation.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An interactive version of the toggleable hotspot is found on the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_28.html toggle hotspot] page of the ImpVis tutorial.&lt;br /&gt;
&lt;br /&gt;
== Fixed hotspots ==&lt;br /&gt;
Hotspots can also be fixed in position so that they ''always'' appear onscreen, as opposed to being toggleable where they can be brought on and off. For example now, to add a fixed hotspot to the code on the previous page, we could write the code as seen below. &lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
				&amp;lt;iv-fixed-hotspot position=&amp;quot;topright&amp;quot; title=&amp;quot;Fixed&amp;quot;&amp;gt;&lt;br /&gt;
                    This will go inside the fixed hotspot, so will always appear on the screen. &lt;br /&gt;
                    P.S. You must specify a title and position&lt;br /&gt;
				&amp;lt;/iv-fixed-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Fixed hotspot screenshot.png|thumb|Fixed hotspot screenshot]]&lt;br /&gt;
Notice how the hotspot overlays over the main content of the visualisation. We will later discuss how to use this feature effectively when designing the learning journey for the users of your visualisations. The screenshotted code would produce a fixed hotspot in the top right of the page. For this demonstration, I have displayed the hotspot in the bottom right for clarity. See the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_29.html tutorial page on fixed hotspots] to see this implemented online.&lt;br /&gt;
&lt;br /&gt;
== Importing your own components ==&lt;br /&gt;
Say you wanted to create your own component that does its own thing, you can import this as a separate file and use it in your visualisations. &lt;br /&gt;
[[File:Filename.png|thumb|Mainstage.vue file]]&lt;br /&gt;
In order to use the file (which we will call MainStage.vue for now), you must export it. Everything you might want to use outside of the MainStage.vue file is written in the export default code block.&lt;br /&gt;
&lt;br /&gt;
For example, we might want to create a canvas that we can display some interactive content in (check out the SHM visualisation, we'll go through some of that content here). To do this, we'd write the following pieces of code:&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default{&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line highlight=&amp;quot;17&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
				&amp;lt;iv-fixed-hotspot position=&amp;quot;topright&amp;quot; title=&amp;quot;Fixed&amp;quot;&amp;gt;&lt;br /&gt;
                    This will go inside the fixed hotspot, so will always appear on the screen. &lt;br /&gt;
                     P.S. You must specify a title and position&lt;br /&gt;
				&amp;lt;/iv-fixed-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
			&amp;lt;MainStage&amp;gt;&amp;lt;/MainStage&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
import {name} from ‘../package.json’;&lt;br /&gt;
import MainStage from ‘.components/MainStage.vue’;&lt;br /&gt;
&lt;br /&gt;
export default {&lt;br /&gt;
	name: &amp;quot;App&amp;quot;,&lt;br /&gt;
	components: {&lt;br /&gt;
		MainStage,&lt;br /&gt;
	},&lt;br /&gt;
	data(){&lt;br /&gt;
		return {&lt;br /&gt;
			projectName: name&lt;br /&gt;
		}&lt;br /&gt;
	},&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.) Place the input from mainstage into the correct part of template (where you want it to go) in App.vue &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Canvas box.a4967d50.png|thumb|Creating canvas box]]&lt;br /&gt;
2.) Insert the code that draws a box around the edges of the canvas drawing area on the screen (that's what we currently want to do, so we can see the canvas).&lt;br /&gt;
&lt;br /&gt;
A screenshot of the result of this code is pasted below.&lt;br /&gt;
[[File:Canvas box display.7731b0f1.png|center|thumb|600x600px|Canvas box result displayed.]]&lt;br /&gt;
[[Category:Coding Guidance]]&lt;br /&gt;
[[Category:Tips Whilst Coding]]&lt;br /&gt;
[[Category:ImpVis Template]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1425</id>
		<title>Basic Component Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1425"/>
		<updated>2022-07-13T09:21:44Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: /* Importing your own components */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contains basic information on how to set up the Pane and Hotspot components in your visualisation code. For information on how to edit the components, see [[Editing ImpVis Components]]. The page assumes you have set up a new visualisation, as described [[Tutorial for setting up the coding environment#Creating a new visualisation|here]]. &lt;br /&gt;
[[File:Pane screenshot.png|thumb|Screenshot of the pane being implemented.]]&lt;br /&gt;
&lt;br /&gt;
== Panes ==&lt;br /&gt;
&lt;br /&gt;
[[Pane|Panes]] are clickable and draggable environments to place text and images over a visualisation. The code seen below is what's needed to produce the pane seen to the right of this text; this can also be seen on the left-hand side of [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_27.html Pane tutorial page]. &lt;br /&gt;
Code to implement the Pane seen on the right.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
def quick_sort(arr):&lt;br /&gt;
	less = []&lt;br /&gt;
	pivot_list = []&lt;br /&gt;
	more = []&lt;br /&gt;
	if len(arr) &amp;lt;= 1:&lt;br /&gt;
		return arr&lt;br /&gt;
	else:&lt;br /&gt;
		pass&lt;br /&gt;
‎&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding content to the mainstage ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example implements a simple harmonic motion (SHM) graphic on the mainstage. Firstly, if you want to copy and paste this code, check out the SHM folder contained in the GitHub repository for this tutorial document at https://github.com/Imperial-visualizations/Tutorial. This document is intended to be useful seeing the logic of setting up such a visualisation, as opposed to providing the code to be changed. But please do spend some time messing around with it!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default {&lt;br /&gt;
    props:{&lt;br /&gt;
       mag: {&lt;br /&gt;
            default: 0.005,&lt;br /&gt;
  &lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    mounted(){&lt;br /&gt;
        let vm = this;&lt;br /&gt;
        let canvas = document.querySelector('canvas');&lt;br /&gt;
        let parent = document.getElementById('parent');&lt;br /&gt;
        let x = 50 + canvas.width/2;&lt;br /&gt;
        let dx = 0;&lt;br /&gt;
&lt;br /&gt;
        canvas.width = parent.offsetWidth;&lt;br /&gt;
        canvas.height = parent.offsetHeight;&lt;br /&gt;
        &lt;br /&gt;
        let c = canvas.getContext('2d');&lt;br /&gt;
        &lt;br /&gt;
        function animate(){&lt;br /&gt;
            requestAnimationFrame(animate);&lt;br /&gt;
        &lt;br /&gt;
                   &lt;br /&gt;
            c.clearRect(0,0,canvas.width, canvas.height);&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(0,0);&lt;br /&gt;
            c.lineTo(canvas.width, 0);&lt;br /&gt;
            c.lineTo(canvas.width, canvas.height);&lt;br /&gt;
            c.lineTo(0, canvas.height);&lt;br /&gt;
            c.lineTo(0, 0);&lt;br /&gt;
            c.strokeStyle = 'black';&lt;br /&gt;
            c.stroke();&lt;br /&gt;
            &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(x, canvas.height/2);&lt;br /&gt;
            c.lineTo(canvas.width/2, canvas.height/2);&lt;br /&gt;
            c.strokeStyle = 'blue';&lt;br /&gt;
            c.lineWidth = 2;&lt;br /&gt;
            c.stroke();&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.arc(x, canvas.height/2, 20, 0, Math.PI * 2); &lt;br /&gt;
            c.fillStyle = 'orange';&lt;br /&gt;
            c.fill();&lt;br /&gt;
           &lt;br /&gt;
             x += dx;&lt;br /&gt;
            dx += - mag * (x-canvas.width/2);&lt;br /&gt;
        }&lt;br /&gt;
        animate();&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code to produce an object which performs SHM is pasted to the left of this text. This should sit in the MainStage.vue file, as we want to treat the SHM block as a component, which we can use multiple times anywhere. Specifically, the code makes a basic SHM vis using a prop for any variables I may want to control with sliders/buttons. When you run this code, you should see a ball conducting SHM on the screen.&lt;br /&gt;
&lt;br /&gt;
Sliders which control the SHM motion can be be added, to see this in action, check out the App.vue file in the SHM vis, from there, you will be able to see how interaction with the MainStage component is brought about.&lt;br /&gt;
&lt;br /&gt;
== Toggleable hotspots ==&lt;br /&gt;
[[File:Toggleable hotspot screenshot.png|thumb|600x600px|Screenshot of the implementation of the toggleable hotspot.]]&lt;br /&gt;
&lt;br /&gt;
Hotspots overlay onto the page similarly to a Pane, but are smaller, and can be stuck on the corners or edges of a page. They can be used to house text or tools used to interact with a visualisation. The code pasted here demonstrates how to produce a ''toggleable'' hotspot, which is a hotspot that can be toggled in and out of the way of the visualisation.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An interactive version of the toggleable hotspot is found on the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_28.html toggle hotspot] page of the ImpVis tutorial.&lt;br /&gt;
&lt;br /&gt;
== Fixed hotspots ==&lt;br /&gt;
Hotspots can also be fixed in position so that they ''always'' appear onscreen, as opposed to being toggleable where they can be brought on and off. For example now, to add a fixed hotspot to the code on the previous page, we could write the code as seen below. &lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
				&amp;lt;iv-fixed-hotspot position=&amp;quot;topright&amp;quot; title=&amp;quot;Fixed&amp;quot;&amp;gt;&lt;br /&gt;
                    This will go inside the fixed hotspot, so will always appear on the screen. &lt;br /&gt;
                    P.S. You must specify a title and position&lt;br /&gt;
				&amp;lt;/iv-fixed-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Fixed hotspot screenshot.png|thumb|Fixed hotspot screenshot]]&lt;br /&gt;
Notice how the hotspot overlays over the main content of the visualisation. We will later discuss how to use this feature effectively when designing the learning journey for the users of your visualisations. The screenshotted code would produce a fixed hotspot in the top right of the page. For this demonstration, I have displayed the hotspot in the bottom right for clarity. See the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_29.html tutorial page on fixed hotspots] to see this implemented online.&lt;br /&gt;
&lt;br /&gt;
== Importing your own components ==&lt;br /&gt;
Say you wanted to create your own component that does its own thing, you can import this as a separate file and use it in your visualisations. &lt;br /&gt;
[[File:Filename.png|thumb|Mainstage.vue file]]&lt;br /&gt;
In order to use the file (which we will call MainStage.vue for now), you must export it. Everything you might want to use outside of the MainStage.vue file is written in the export default code block.&lt;br /&gt;
&lt;br /&gt;
For example, we might want to create a canvas that we can display some interactive content in (check out the SHM visualisation, we'll go through some of that content here). To do this, we'd write the following pieces of code:&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default{&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Inserting mainstage to app.png|thumb|Inserting mainstage to app.vue]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.) Place the input from mainstage into the correct part of template (where you want it to go) in App.vue &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Canvas box.a4967d50.png|thumb|Creating canvas box]]&lt;br /&gt;
2.) Insert the code that draws a box around the edges of the canvas drawing area on the screen (that's what we currently want to do, so we can see the canvas).&lt;br /&gt;
&lt;br /&gt;
A screenshot of the result of this code is pasted below.&lt;br /&gt;
[[File:Canvas box display.7731b0f1.png|center|thumb|600x600px|Canvas box result displayed.]]&lt;br /&gt;
[[Category:Coding Guidance]]&lt;br /&gt;
[[Category:Tips Whilst Coding]]&lt;br /&gt;
[[Category:ImpVis Template]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1424</id>
		<title>Basic Component Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1424"/>
		<updated>2022-07-13T09:18:03Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: /* Fixed hotspots */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contains basic information on how to set up the Pane and Hotspot components in your visualisation code. For information on how to edit the components, see [[Editing ImpVis Components]]. The page assumes you have set up a new visualisation, as described [[Tutorial for setting up the coding environment#Creating a new visualisation|here]]. &lt;br /&gt;
[[File:Pane screenshot.png|thumb|Screenshot of the pane being implemented.]]&lt;br /&gt;
&lt;br /&gt;
== Panes ==&lt;br /&gt;
&lt;br /&gt;
[[Pane|Panes]] are clickable and draggable environments to place text and images over a visualisation. The code seen below is what's needed to produce the pane seen to the right of this text; this can also be seen on the left-hand side of [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_27.html Pane tutorial page]. &lt;br /&gt;
Code to implement the Pane seen on the right.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
def quick_sort(arr):&lt;br /&gt;
	less = []&lt;br /&gt;
	pivot_list = []&lt;br /&gt;
	more = []&lt;br /&gt;
	if len(arr) &amp;lt;= 1:&lt;br /&gt;
		return arr&lt;br /&gt;
	else:&lt;br /&gt;
		pass&lt;br /&gt;
‎&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding content to the mainstage ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example implements a simple harmonic motion (SHM) graphic on the mainstage. Firstly, if you want to copy and paste this code, check out the SHM folder contained in the GitHub repository for this tutorial document at https://github.com/Imperial-visualizations/Tutorial. This document is intended to be useful seeing the logic of setting up such a visualisation, as opposed to providing the code to be changed. But please do spend some time messing around with it!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default {&lt;br /&gt;
    props:{&lt;br /&gt;
       mag: {&lt;br /&gt;
            default: 0.005,&lt;br /&gt;
  &lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    mounted(){&lt;br /&gt;
        let vm = this;&lt;br /&gt;
        let canvas = document.querySelector('canvas');&lt;br /&gt;
        let parent = document.getElementById('parent');&lt;br /&gt;
        let x = 50 + canvas.width/2;&lt;br /&gt;
        let dx = 0;&lt;br /&gt;
&lt;br /&gt;
        canvas.width = parent.offsetWidth;&lt;br /&gt;
        canvas.height = parent.offsetHeight;&lt;br /&gt;
        &lt;br /&gt;
        let c = canvas.getContext('2d');&lt;br /&gt;
        &lt;br /&gt;
        function animate(){&lt;br /&gt;
            requestAnimationFrame(animate);&lt;br /&gt;
        &lt;br /&gt;
                   &lt;br /&gt;
            c.clearRect(0,0,canvas.width, canvas.height);&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(0,0);&lt;br /&gt;
            c.lineTo(canvas.width, 0);&lt;br /&gt;
            c.lineTo(canvas.width, canvas.height);&lt;br /&gt;
            c.lineTo(0, canvas.height);&lt;br /&gt;
            c.lineTo(0, 0);&lt;br /&gt;
            c.strokeStyle = 'black';&lt;br /&gt;
            c.stroke();&lt;br /&gt;
            &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(x, canvas.height/2);&lt;br /&gt;
            c.lineTo(canvas.width/2, canvas.height/2);&lt;br /&gt;
            c.strokeStyle = 'blue';&lt;br /&gt;
            c.lineWidth = 2;&lt;br /&gt;
            c.stroke();&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.arc(x, canvas.height/2, 20, 0, Math.PI * 2); &lt;br /&gt;
            c.fillStyle = 'orange';&lt;br /&gt;
            c.fill();&lt;br /&gt;
           &lt;br /&gt;
             x += dx;&lt;br /&gt;
            dx += - mag * (x-canvas.width/2);&lt;br /&gt;
        }&lt;br /&gt;
        animate();&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code to produce an object which performs SHM is pasted to the left of this text. This should sit in the MainStage.vue file, as we want to treat the SHM block as a component, which we can use multiple times anywhere. Specifically, the code makes a basic SHM vis using a prop for any variables I may want to control with sliders/buttons. When you run this code, you should see a ball conducting SHM on the screen.&lt;br /&gt;
&lt;br /&gt;
Sliders which control the SHM motion can be be added, to see this in action, check out the App.vue file in the SHM vis, from there, you will be able to see how interaction with the MainStage component is brought about.&lt;br /&gt;
&lt;br /&gt;
== Toggleable hotspots ==&lt;br /&gt;
[[File:Toggleable hotspot screenshot.png|thumb|600x600px|Screenshot of the implementation of the toggleable hotspot.]]&lt;br /&gt;
&lt;br /&gt;
Hotspots overlay onto the page similarly to a Pane, but are smaller, and can be stuck on the corners or edges of a page. They can be used to house text or tools used to interact with a visualisation. The code pasted here demonstrates how to produce a ''toggleable'' hotspot, which is a hotspot that can be toggled in and out of the way of the visualisation.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An interactive version of the toggleable hotspot is found on the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_28.html toggle hotspot] page of the ImpVis tutorial.&lt;br /&gt;
&lt;br /&gt;
== Fixed hotspots ==&lt;br /&gt;
Hotspots can also be fixed in position so that they ''always'' appear onscreen, as opposed to being toggleable where they can be brought on and off. For example now, to add a fixed hotspot to the code on the previous page, we could write the code as seen below. &lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
				&amp;lt;iv-fixed-hotspot position=&amp;quot;topright&amp;quot; title=&amp;quot;Fixed&amp;quot;&amp;gt;&lt;br /&gt;
                    This will go inside the fixed hotspot, so will always appear on the screen. &lt;br /&gt;
                    P.S. You must specify a title and position&lt;br /&gt;
				&amp;lt;/iv-fixed-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Fixed hotspot screenshot.png|thumb|Fixed hotspot screenshot]]&lt;br /&gt;
Notice how the hotspot overlays over the main content of the visualisation. We will later discuss how to use this feature effectively when designing the learning journey for the users of your visualisations. The screenshotted code would produce a fixed hotspot in the top right of the page. For this demonstration, I have displayed the hotspot in the bottom right for clarity. See the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_29.html tutorial page on fixed hotspots] to see this implemented online.&lt;br /&gt;
&lt;br /&gt;
== Importing your own components ==&lt;br /&gt;
Say you wanted to create your own component that does its own thing, you can import this as a separate file and use it in your visualisations. &lt;br /&gt;
[[File:Filename.png|thumb|Mainstage.vue file]]&lt;br /&gt;
In order to use the file (which we will call MainStage.vue for now), you must export it. Everything you might want to use outside of the MainStage.vue file is written in the export default code block.&lt;br /&gt;
&lt;br /&gt;
For example, we might want to create a canvas that we can display some interactive content in (check out the SHM visualisation, we'll go through some of that content here). To do this, we'd write the following pieces of code:&lt;br /&gt;
[[File:Mainstage code.png|center|thumb|Mainstage code.]]&lt;br /&gt;
[[File:Inserting mainstage to app.png|thumb|Inserting mainstage to app.vue]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.) Place the input from mainstage into the correct part of template (where you want it to go) in App.vue &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Canvas box.a4967d50.png|thumb|Creating canvas box]]&lt;br /&gt;
2.) Insert the code that draws a box around the edges of the canvas drawing area on the screen (that's what we currently want to do, so we can see the canvas).&lt;br /&gt;
&lt;br /&gt;
A screenshot of the result of this code is pasted below.&lt;br /&gt;
[[File:Canvas box display.7731b0f1.png|center|thumb|600x600px|Canvas box result displayed.]]&lt;br /&gt;
[[Category:Coding Guidance]]&lt;br /&gt;
[[Category:Tips Whilst Coding]]&lt;br /&gt;
[[Category:ImpVis Template]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1423</id>
		<title>Basic Component Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1423"/>
		<updated>2022-07-13T09:13:08Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: /* Toggleable hotspots */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contains basic information on how to set up the Pane and Hotspot components in your visualisation code. For information on how to edit the components, see [[Editing ImpVis Components]]. The page assumes you have set up a new visualisation, as described [[Tutorial for setting up the coding environment#Creating a new visualisation|here]]. &lt;br /&gt;
[[File:Pane screenshot.png|thumb|Screenshot of the pane being implemented.]]&lt;br /&gt;
&lt;br /&gt;
== Panes ==&lt;br /&gt;
&lt;br /&gt;
[[Pane|Panes]] are clickable and draggable environments to place text and images over a visualisation. The code seen below is what's needed to produce the pane seen to the right of this text; this can also be seen on the left-hand side of [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_27.html Pane tutorial page]. &lt;br /&gt;
Code to implement the Pane seen on the right.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
def quick_sort(arr):&lt;br /&gt;
	less = []&lt;br /&gt;
	pivot_list = []&lt;br /&gt;
	more = []&lt;br /&gt;
	if len(arr) &amp;lt;= 1:&lt;br /&gt;
		return arr&lt;br /&gt;
	else:&lt;br /&gt;
		pass&lt;br /&gt;
‎&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding content to the mainstage ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example implements a simple harmonic motion (SHM) graphic on the mainstage. Firstly, if you want to copy and paste this code, check out the SHM folder contained in the GitHub repository for this tutorial document at https://github.com/Imperial-visualizations/Tutorial. This document is intended to be useful seeing the logic of setting up such a visualisation, as opposed to providing the code to be changed. But please do spend some time messing around with it!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default {&lt;br /&gt;
    props:{&lt;br /&gt;
       mag: {&lt;br /&gt;
            default: 0.005,&lt;br /&gt;
  &lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    mounted(){&lt;br /&gt;
        let vm = this;&lt;br /&gt;
        let canvas = document.querySelector('canvas');&lt;br /&gt;
        let parent = document.getElementById('parent');&lt;br /&gt;
        let x = 50 + canvas.width/2;&lt;br /&gt;
        let dx = 0;&lt;br /&gt;
&lt;br /&gt;
        canvas.width = parent.offsetWidth;&lt;br /&gt;
        canvas.height = parent.offsetHeight;&lt;br /&gt;
        &lt;br /&gt;
        let c = canvas.getContext('2d');&lt;br /&gt;
        &lt;br /&gt;
        function animate(){&lt;br /&gt;
            requestAnimationFrame(animate);&lt;br /&gt;
        &lt;br /&gt;
                   &lt;br /&gt;
            c.clearRect(0,0,canvas.width, canvas.height);&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(0,0);&lt;br /&gt;
            c.lineTo(canvas.width, 0);&lt;br /&gt;
            c.lineTo(canvas.width, canvas.height);&lt;br /&gt;
            c.lineTo(0, canvas.height);&lt;br /&gt;
            c.lineTo(0, 0);&lt;br /&gt;
            c.strokeStyle = 'black';&lt;br /&gt;
            c.stroke();&lt;br /&gt;
            &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(x, canvas.height/2);&lt;br /&gt;
            c.lineTo(canvas.width/2, canvas.height/2);&lt;br /&gt;
            c.strokeStyle = 'blue';&lt;br /&gt;
            c.lineWidth = 2;&lt;br /&gt;
            c.stroke();&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.arc(x, canvas.height/2, 20, 0, Math.PI * 2); &lt;br /&gt;
            c.fillStyle = 'orange';&lt;br /&gt;
            c.fill();&lt;br /&gt;
           &lt;br /&gt;
             x += dx;&lt;br /&gt;
            dx += - mag * (x-canvas.width/2);&lt;br /&gt;
        }&lt;br /&gt;
        animate();&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code to produce an object which performs SHM is pasted to the left of this text. This should sit in the MainStage.vue file, as we want to treat the SHM block as a component, which we can use multiple times anywhere. Specifically, the code makes a basic SHM vis using a prop for any variables I may want to control with sliders/buttons. When you run this code, you should see a ball conducting SHM on the screen.&lt;br /&gt;
&lt;br /&gt;
Sliders which control the SHM motion can be be added, to see this in action, check out the App.vue file in the SHM vis, from there, you will be able to see how interaction with the MainStage component is brought about.&lt;br /&gt;
&lt;br /&gt;
== Toggleable hotspots ==&lt;br /&gt;
[[File:Toggleable hotspot screenshot.png|thumb|600x600px|Screenshot of the implementation of the toggleable hotspot.]]&lt;br /&gt;
&lt;br /&gt;
Hotspots overlay onto the page similarly to a Pane, but are smaller, and can be stuck on the corners or edges of a page. They can be used to house text or tools used to interact with a visualisation. The code pasted here demonstrates how to produce a ''toggleable'' hotspot, which is a hotspot that can be toggled in and out of the way of the visualisation.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;template&amp;gt;&lt;br /&gt;
	&amp;lt;div&amp;gt;&lt;br /&gt;
		&amp;lt;iv-title-bar&amp;gt;This is my title&amp;lt;/iv-title-bar&amp;gt;&lt;br /&gt;
		&amp;lt;iv-visualisation&amp;gt;&lt;br /&gt;
			&amp;lt;template #hotspots&amp;gt;&lt;br /&gt;
				&amp;lt;iv-pane position=&amp;quot;left&amp;quot;&amp;gt;&lt;br /&gt;
					Hi! This is a pane&lt;br /&gt;
				&amp;lt;/iv-pane&amp;gt;&lt;br /&gt;
				&amp;lt;iv-toggle-hotspot position=&amp;quot;bottom&amp;quot; title=&amp;quot;Button Title&amp;quot;&amp;gt;&lt;br /&gt;
					This will go inside the pop-out section&lt;br /&gt;
				&amp;lt;/iv-toggle-hotspot&amp;gt;&lt;br /&gt;
			&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/iv-visualisation&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An interactive version of the toggleable hotspot is found on the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_28.html toggle hotspot] page of the ImpVis tutorial.&lt;br /&gt;
&lt;br /&gt;
== Fixed hotspots ==&lt;br /&gt;
Hotspots can also be fixed in position so that they ''always'' appear onscreen, as opposed to being toggleable where they can be brought on and off. For example now, to add a fixed hotspot to the code on the previous page, we could write the code as seen below. &lt;br /&gt;
&lt;br /&gt;
[[File:Fixed hotspot code.b3b4f880.png|left|thumb|300x300px|Fixed hotspot code]]&lt;br /&gt;
[[File:Fixed hotspot screenshot.png|thumb|Fixed hotspot screenshot]]&lt;br /&gt;
Notice how the hotspot overlays over the main content of the visualisation. We will later discuss how to use this feature effectively when designing the learning journey for the users of your visualisations. The screenshotted code would produce a fixed hotspot in the top right of the page. For this demonstration, I have displayed the hotspot in the bottom right for clarity. See the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_29.html tutorial page on fixed hotspots] to see this implemented online.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Importing your own components ==&lt;br /&gt;
Say you wanted to create your own component that does its own thing, you can import this as a separate file and use it in your visualisations. &lt;br /&gt;
[[File:Filename.png|thumb|Mainstage.vue file]]&lt;br /&gt;
In order to use the file (which we will call MainStage.vue for now), you must export it. Everything you might want to use outside of the MainStage.vue file is written in the export default code block.&lt;br /&gt;
&lt;br /&gt;
For example, we might want to create a canvas that we can display some interactive content in (check out the SHM visualisation, we'll go through some of that content here). To do this, we'd write the following pieces of code:&lt;br /&gt;
[[File:Mainstage code.png|center|thumb|Mainstage code.]]&lt;br /&gt;
[[File:Inserting mainstage to app.png|thumb|Inserting mainstage to app.vue]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.) Place the input from mainstage into the correct part of template (where you want it to go) in App.vue &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Canvas box.a4967d50.png|thumb|Creating canvas box]]&lt;br /&gt;
2.) Insert the code that draws a box around the edges of the canvas drawing area on the screen (that's what we currently want to do, so we can see the canvas).&lt;br /&gt;
&lt;br /&gt;
A screenshot of the result of this code is pasted below.&lt;br /&gt;
[[File:Canvas box display.7731b0f1.png|center|thumb|600x600px|Canvas box result displayed.]]&lt;br /&gt;
[[Category:Coding Guidance]]&lt;br /&gt;
[[Category:Tips Whilst Coding]]&lt;br /&gt;
[[Category:ImpVis Template]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1422</id>
		<title>Basic Component Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Basic_Component_Tutorial&amp;diff=1422"/>
		<updated>2022-07-13T09:03:53Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: /* Adding content to the mainstage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contains basic information on how to set up the Pane and Hotspot components in your visualisation code. For information on how to edit the components, see [[Editing ImpVis Components]]. The page assumes you have set up a new visualisation, as described [[Tutorial for setting up the coding environment#Creating a new visualisation|here]]. &lt;br /&gt;
[[File:Pane screenshot.png|thumb|Screenshot of the pane being implemented.]]&lt;br /&gt;
&lt;br /&gt;
== Panes ==&lt;br /&gt;
&lt;br /&gt;
[[Pane|Panes]] are clickable and draggable environments to place text and images over a visualisation. The code seen below is what's needed to produce the pane seen to the right of this text; this can also be seen on the left-hand side of [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_27.html Pane tutorial page]. &lt;br /&gt;
Code to implement the Pane seen on the right.&lt;br /&gt;
&lt;br /&gt;
‎&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
def quick_sort(arr):&lt;br /&gt;
	less = []&lt;br /&gt;
	pivot_list = []&lt;br /&gt;
	more = []&lt;br /&gt;
	if len(arr) &amp;lt;= 1:&lt;br /&gt;
		return arr&lt;br /&gt;
	else:&lt;br /&gt;
		pass&lt;br /&gt;
‎&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding content to the mainstage ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example implements a simple harmonic motion (SHM) graphic on the mainstage. Firstly, if you want to copy and paste this code, check out the SHM folder contained in the GitHub repository for this tutorial document at https://github.com/Imperial-visualizations/Tutorial. This document is intended to be useful seeing the logic of setting up such a visualisation, as opposed to providing the code to be changed. But please do spend some time messing around with it!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot; line&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
export default {&lt;br /&gt;
    props:{&lt;br /&gt;
       mag: {&lt;br /&gt;
            default: 0.005,&lt;br /&gt;
  &lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    mounted(){&lt;br /&gt;
        let vm = this;&lt;br /&gt;
        let canvas = document.querySelector('canvas');&lt;br /&gt;
        let parent = document.getElementById('parent');&lt;br /&gt;
        let x = 50 + canvas.width/2;&lt;br /&gt;
        let dx = 0;&lt;br /&gt;
&lt;br /&gt;
        canvas.width = parent.offsetWidth;&lt;br /&gt;
        canvas.height = parent.offsetHeight;&lt;br /&gt;
        &lt;br /&gt;
        let c = canvas.getContext('2d');&lt;br /&gt;
        &lt;br /&gt;
        function animate(){&lt;br /&gt;
            requestAnimationFrame(animate);&lt;br /&gt;
        &lt;br /&gt;
                   &lt;br /&gt;
            c.clearRect(0,0,canvas.width, canvas.height);&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(0,0);&lt;br /&gt;
            c.lineTo(canvas.width, 0);&lt;br /&gt;
            c.lineTo(canvas.width, canvas.height);&lt;br /&gt;
            c.lineTo(0, canvas.height);&lt;br /&gt;
            c.lineTo(0, 0);&lt;br /&gt;
            c.strokeStyle = 'black';&lt;br /&gt;
            c.stroke();&lt;br /&gt;
            &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.moveTo(x, canvas.height/2);&lt;br /&gt;
            c.lineTo(canvas.width/2, canvas.height/2);&lt;br /&gt;
            c.strokeStyle = 'blue';&lt;br /&gt;
            c.lineWidth = 2;&lt;br /&gt;
            c.stroke();&lt;br /&gt;
           &lt;br /&gt;
            c.beginPath();&lt;br /&gt;
            c.arc(x, canvas.height/2, 20, 0, Math.PI * 2); &lt;br /&gt;
            c.fillStyle = 'orange';&lt;br /&gt;
            c.fill();&lt;br /&gt;
           &lt;br /&gt;
             x += dx;&lt;br /&gt;
            dx += - mag * (x-canvas.width/2);&lt;br /&gt;
        }&lt;br /&gt;
        animate();&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code to produce an object which performs SHM is pasted to the left of this text. This should sit in the MainStage.vue file, as we want to treat the SHM block as a component, which we can use multiple times anywhere. Specifically, the code makes a basic SHM vis using a prop for any variables I may want to control with sliders/buttons. When you run this code, you should see a ball conducting SHM on the screen.&lt;br /&gt;
&lt;br /&gt;
Sliders which control the SHM motion can be be added, to see this in action, check out the App.vue file in the SHM vis, from there, you will be able to see how interaction with the MainStage component is brought about.&lt;br /&gt;
&lt;br /&gt;
== Toggleable hotspots ==&lt;br /&gt;
[[File:Toggleable hotspot screenshot.png|thumb|600x600px|Screenshot of the implementation of the toggleable hotspot.]]&lt;br /&gt;
&lt;br /&gt;
Hotspots overlay onto the page similarly to a Pane, but are smaller, and can be stuck on the corners or edges of a page. They can be used to house text or tools used to interact with a visualisation. The code pasted here demonstrates how to produce a ''toggleable'' hotspot, which is a hotspot that can be toggled in and out of the way of the visualisation.&lt;br /&gt;
[[File:Toggleable hotspot code.png|thumb|600x600px|Code written to produce the toggleable hotspot and Pane.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An interactive version of the toggleable hotspot is found on the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_28.html toggle hotspot] page of the ImpVis tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Fixed hotspots ==&lt;br /&gt;
Hotspots can also be fixed in position so that they ''always'' appear onscreen, as opposed to being toggleable where they can be brought on and off. For example now, to add a fixed hotspot to the code on the previous page, we could write the code as seen below. &lt;br /&gt;
&lt;br /&gt;
[[File:Fixed hotspot code.b3b4f880.png|left|thumb|300x300px|Fixed hotspot code]]&lt;br /&gt;
[[File:Fixed hotspot screenshot.png|thumb|Fixed hotspot screenshot]]&lt;br /&gt;
Notice how the hotspot overlays over the main content of the visualisation. We will later discuss how to use this feature effectively when designing the learning journey for the users of your visualisations. The screenshotted code would produce a fixed hotspot in the top right of the page. For this demonstration, I have displayed the hotspot in the bottom right for clarity. See the [https://impvis.co.uk/launch/impvis-tutorial-unpublished/page_29.html tutorial page on fixed hotspots] to see this implemented online.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Importing your own components ==&lt;br /&gt;
Say you wanted to create your own component that does its own thing, you can import this as a separate file and use it in your visualisations. &lt;br /&gt;
[[File:Filename.png|thumb|Mainstage.vue file]]&lt;br /&gt;
In order to use the file (which we will call MainStage.vue for now), you must export it. Everything you might want to use outside of the MainStage.vue file is written in the export default code block.&lt;br /&gt;
&lt;br /&gt;
For example, we might want to create a canvas that we can display some interactive content in (check out the SHM visualisation, we'll go through some of that content here). To do this, we'd write the following pieces of code:&lt;br /&gt;
[[File:Mainstage code.png|center|thumb|Mainstage code.]]&lt;br /&gt;
[[File:Inserting mainstage to app.png|thumb|Inserting mainstage to app.vue]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.) Place the input from mainstage into the correct part of template (where you want it to go) in App.vue &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Canvas box.a4967d50.png|thumb|Creating canvas box]]&lt;br /&gt;
2.) Insert the code that draws a box around the edges of the canvas drawing area on the screen (that's what we currently want to do, so we can see the canvas).&lt;br /&gt;
&lt;br /&gt;
A screenshot of the result of this code is pasted below.&lt;br /&gt;
[[File:Canvas box display.7731b0f1.png|center|thumb|600x600px|Canvas box result displayed.]]&lt;br /&gt;
[[Category:Coding Guidance]]&lt;br /&gt;
[[Category:Tips Whilst Coding]]&lt;br /&gt;
[[Category:ImpVis Template]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Bloch_Sphere&amp;diff=1340</id>
		<title>Bloch Sphere</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Bloch_Sphere&amp;diff=1340"/>
		<updated>2022-02-16T00:00:57Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Contributors ==&lt;br /&gt;
&lt;br /&gt;
* ''Name and department of each person.''&lt;br /&gt;
*''Student or staff partner?''&lt;br /&gt;
* ''How is/was each person involved?''&lt;br /&gt;
* ''What rough dates did they contribute?''&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Learning Outcomes ==&lt;br /&gt;
&lt;br /&gt;
* ''Explain the motivation for your visualisation.''&lt;br /&gt;
Being able to visualize quantum states and the effects of quantum gates on them gives the learner a visual and intuitive understanding of quantum logic gates (rather than just as mathematical equations) - this is important to then be able to build more complex algorithms and quantum circuits which are the fundamental building blocks of quantum computing &lt;br /&gt;
* ''Introduce the subject of your visualisation.''&lt;br /&gt;
'''Bloch sphere'''&lt;br /&gt;
&lt;br /&gt;
# What is a qubit? Bit vs qubit  - bits are the building blocks of classical computers (only 0s and 1s)  whereas the building blocks of quantum computers are qubits (superpositions of the |0&amp;gt; and |1&amp;gt; quantum states)&lt;br /&gt;
# What is a Bloch sphere? A way of geometrically representing these quantum states as vectors of a 3d unit sphere, where |0&amp;gt; can be represented by the 0 vector  and |1&amp;gt; can be represented by the 1 vector    using bra-ket notation &lt;br /&gt;
# The general representation of these pure quantum states as α|0&amp;gt;+β|1&amp;gt;&lt;br /&gt;
# Pure vs mixed states&lt;br /&gt;
&lt;br /&gt;
where α and β are complex numbers representing the probability amplitudes i.e. the probability of getting |0&amp;gt; is |α|^2.&lt;br /&gt;
&lt;br /&gt;
* How can we represent this general form of the quantum state geometrically? - We need to introduce coordinate parameters such as φ and θ &lt;br /&gt;
** Rewrite the general quantum state form in terms of polar coordinates (using Euler's identity)&lt;br /&gt;
** Global phase - two quantum states which differ only by a factor of exp(i theta) are considered to be the same&lt;br /&gt;
** Normalization constraint (probabilities must sum to 1)&lt;br /&gt;
** To get: cos(θ) |0&amp;gt; + e^(iφ)sin(θ) |1&amp;gt;&lt;br /&gt;
** θ and φ restrictions means we get  cos(θ/2) |0&amp;gt; + e^(iφ)sin(θ/2) |1&amp;gt;&lt;br /&gt;
** Pure vs mixed states (pure states on the surface, mixed states within sphere)&lt;br /&gt;
&lt;br /&gt;
'''Quantum gates'''&lt;br /&gt;
&lt;br /&gt;
* A way of manipulating qubits which is useful for creating algorithms/quantum circuits&lt;br /&gt;
* Pauli-X gate:&lt;br /&gt;
** Matrix representation&lt;br /&gt;
** Flipping the state -&amp;gt; corresponds to 180 degree rotation about the x axis on the Bloch sphere&lt;br /&gt;
* Likewise for Pauli-Y&lt;br /&gt;
* Likewise for Pauli-Z&lt;br /&gt;
* Hadamard&lt;br /&gt;
** Matrix representation&lt;br /&gt;
** 90 degree rotation around Y-axis followed by 180 degree around X axis &lt;br /&gt;
&lt;br /&gt;
* ''Which module and year is it intended for and which setting (lecture or self study)?''&lt;br /&gt;
&lt;br /&gt;
Useful for the Quantum Information course (PHYS97080)&lt;br /&gt;
&lt;br /&gt;
Can also be used for self-study&lt;br /&gt;
*''List learning outcomes. E.g.: &amp;quot;After using this visualisation, students should be able to explain that...&amp;quot;''&lt;br /&gt;
After using this visualisation, students should be able to:&lt;br /&gt;
&lt;br /&gt;
* Represent states of qubits (pure and mixed) and their dynamics on the Bloch sphere&lt;br /&gt;
* Understand the dynamics of single qubits by quantum gates (Pauli X, Pauli Y, Pauli Z and Hadamard)&lt;br /&gt;
&lt;br /&gt;
== Design Overview ==&lt;br /&gt;
&lt;br /&gt;
* ''Once the design is agreed, describe the final outcome, how it looks, how it functions etc.''&lt;br /&gt;
* ''Include graphics.''&lt;br /&gt;
&lt;br /&gt;
== Design Justification ==&lt;br /&gt;
&lt;br /&gt;
''Optionally describe any notable decisions made for the design, e.g.''&lt;br /&gt;
&lt;br /&gt;
* ''Educational design: breaking down of concepts (scaffolding)''&lt;br /&gt;
* ''How were accessibility issues considered?''&lt;br /&gt;
* ''How was space used effectively?''&lt;br /&gt;
* ''How is the design intuitive?''&lt;br /&gt;
* ''Choice of interactive element(s) that fit in organically with the visualisation [inspiration of choice might be from lecture/in-class activity or other sources] - Sliders/Buttons/Cursor (hover/click).''&lt;br /&gt;
== Progress and Future Work ==&lt;br /&gt;
&lt;br /&gt;
* ''Is the design finalised (i.e. agreed by all partners)?''&lt;br /&gt;
* ''If applicable, which pages have been uploaded to website?''&lt;br /&gt;
* ''Any ideas for future improvements.''&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
*Link to GitHub repository for code in development:&lt;br /&gt;
*Link to visualisation on ImpVis website (when uploaded):&lt;br /&gt;
*Link to Collection on ImpVis website (when created):&lt;br /&gt;
*Any other links to resources (Miro boards / notes pages / Google Docs etc):&lt;br /&gt;
[[Category:Getting Started]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
	<entry>
		<id>https://wiki.impvis.co.uk/index.php?title=Bloch_Sphere&amp;diff=1321</id>
		<title>Bloch Sphere</title>
		<link rel="alternate" type="text/html" href="https://wiki.impvis.co.uk/index.php?title=Bloch_Sphere&amp;diff=1321"/>
		<updated>2022-02-09T12:58:05Z</updated>

		<summary type="html">&lt;p&gt;SarmpaviUthayakumar: Created page with &amp;quot;''This is a  template which you can use to help get you started on a Wiki for a new visualisation project - it serves as a dynamic 'ReadMe' file of your project. The template...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a  template which you can use to help get you started on a Wiki for a new visualisation project - it serves as a dynamic 'ReadMe' file of your project. The template is just intended as a guide and you may modify the structure to suit your project (all template instructions are in italics and do not need to be saved in your own project page).'' &lt;br /&gt;
&lt;br /&gt;
'''''Note: if you are taking part in the I-Explore module, the [[Wiki Submission Template|submission template]] will be better suited to your needs.''''' &lt;br /&gt;
&lt;br /&gt;
''When a new project is started, the 'Contributors' and 'Aims &amp;amp; Learning Outcomes' sections need to be filled out. Aim to include the rest of the information by the time the design is finalised. The page can be updated whenever the visualisation is updated - ensure to credit all contributors!''&lt;br /&gt;
&lt;br /&gt;
''To create your own project page from this template, do the following:''&lt;br /&gt;
&lt;br /&gt;
# ''In a separate browser window / tab, create a new project page with the same title as your project. Ensure to assign your page to the category 'Project pages'. Read '''[[Making Wiki Pages]]' ''for detailed instructions of how to do this.''&lt;br /&gt;
# ''Come back to this template and press 'Edit' at the top of the page.''&lt;br /&gt;
#''Select all the text on this page (not the title) and copy it.'' &lt;br /&gt;
#''Click 'Read' at the top of this page (choose 'Discard edits' in the pop up window to avoid saving any accidental edits).''&lt;br /&gt;
#''Go to your browser window with your new project page and paste the text you copied.''&lt;br /&gt;
#''Make any edits you want on your own project page (e.g. entering your name as a contributor) and press the blue button 'Save page...' at the top right of your page.''&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
&lt;br /&gt;
* ''Name and department of each person.''&lt;br /&gt;
*''Student or staff partner?''&lt;br /&gt;
* ''How is/was each person involved?''&lt;br /&gt;
* ''What rough dates did they contribute?''&lt;br /&gt;
&lt;br /&gt;
== Aims &amp;amp; Learning Outcomes ==&lt;br /&gt;
&lt;br /&gt;
* ''Explain the motivation for your visualisation.''&lt;br /&gt;
&lt;br /&gt;
* ''Introduce the subject of your visualisation.''&lt;br /&gt;
*''Which module and year is it intended for and which setting (lecture or self study)?''&lt;br /&gt;
*''List learning outcomes. E.g.: &amp;quot;After using this visualisation, students should be able to explain that...&amp;quot;''&lt;br /&gt;
&lt;br /&gt;
== Design Overview ==&lt;br /&gt;
&lt;br /&gt;
* ''Once the design is agreed, describe the final outcome, how it looks, how it functions etc.''&lt;br /&gt;
* ''Include graphics.''&lt;br /&gt;
&lt;br /&gt;
== Design Justification ==&lt;br /&gt;
&lt;br /&gt;
''Optionally describe any notable decisions made for the design, e.g.''&lt;br /&gt;
&lt;br /&gt;
* ''Educational design: breaking down of concepts (scaffolding)''&lt;br /&gt;
* ''How were accessibility issues considered?''&lt;br /&gt;
* ''How was space used effectively?''&lt;br /&gt;
* ''How is the design intuitive?''&lt;br /&gt;
* ''Choice of interactive element(s) that fit in organically with the visualisation [inspiration of choice might be from lecture/in-class activity or other sources] - Sliders/Buttons/Cursor (hover/click).''&lt;br /&gt;
== Progress and Future Work ==&lt;br /&gt;
&lt;br /&gt;
* ''Is the design finalised (i.e. agreed by all partners)?''&lt;br /&gt;
* ''If applicable, which pages have been uploaded to website?''&lt;br /&gt;
* ''Any ideas for future improvements.''&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
*Link to GitHub repository for code in development:&lt;br /&gt;
*Link to visualisation on ImpVis website (when uploaded):&lt;br /&gt;
*Link to Collection on ImpVis website (when created):&lt;br /&gt;
*Any other links to resources (Miro boards / notes pages / Google Docs etc):&lt;br /&gt;
[[Category:Getting Started]]&lt;/div&gt;</summary>
		<author><name>SarmpaviUthayakumar</name></author>
	</entry>
</feed>