3. Using Circuit Builder¶
3.1 Overview¶
The QuICScript Circuit Builder is built using HTML, Javascript, and CSS.
The core files are as follows:
├──index.html
└──assets/
├──index-xxxxxxxx.js
└──index-xxxxxxxx.css
index.html
- Point your web server toindex.html
to serve- This file maybe edited to change the default circuit layout.See 3.2 Change Gate Style and Palette for more information.
index-xxxxxxxx.js
- Logic for Circuit Builderindex-xxxxxxxx.css
- Styling for Circuit Builder
Note
Do not modify the js
and css
files directly as it may break the application. They are bundled assets through the build process.
xxxxxxxx - Are hashed values of the file, will be different if there’s updates to the file.
3.2 Change Gate Style and Palette¶
3.2.1 Change Gate Style¶
Update in index.html under <style>
tag.
<style>
div.gate {
/* Change Gate background color here: Default (#f3f4f6) */
background-color: #98CFEC;
}
</style>
Note
Any CSS styling works, including removing border border: none;
3.2.2 Change Gate Palette¶
Update in index.html under <script>
tag.
<script>
/** Update Gates present in the palette: Default ["H", "X", "Y", "Z", "C", "N", "P", "T", "I", "s", "U", "d", "m"] */
/** Do check the documentation for allowed gates */
const gates = ["H", "X", "Y", "Z", "C", "P", "T", "I", "s", "U", "m"];
</script>
Note
Check out 2. Using QuICScript for available gates.
3.3 Add New Circuit¶
Description¶
URL Params follows Query String.
Using URL Params allows user to insert default parameters into the system for configurations.
Usage¶
Single Parameter <url>?<param>=<data>
Multiple Parameter (Separated with &) <url>?<param>=<data>&<param>=<data>
Warning
Make sure <param>
follow exactly to Available Params. Any invalid param/data will not reflect in the builder.
Parameters¶
quicscript
- Quicscript Stringqubits
- Number of qubitscolumns
- Number of columnsqibo
- Enable/Disable of Qibo Featuretype
- Type of outputinput
- Enable/Disable of Input Feature
Query string parameter |
Type |
Description |
Constraint |
Default |
Example |
---|---|---|---|---|---|
|
string |
(qubits are calculated)
|
0 \(<\) qubits \(\leq\) 20 |
— |
|
|
integer |
Number of qubits |
0 \(<\) qubits \(\leq\) 20 |
|
|
|
integer |
Gate depth |
— |
|
|
|
boolean |
Enable/Disable Qibo Feature |
|
|
|
|
string |
Type of output |
|
|
|
|
boolean |
Enable quicscript input |
|
|
quicscript |
qubits |
columns |
Remarks |
Example |
---|---|---|---|---|
not-in-use |
not-in-use |
not-in-use |
Default configuration |
|
use |
not-in-use |
not-in-use |
Set Bell State |
|
use |
use |
use |
3-qubit QFT circuit with 6 columns |
|
not-in-use |
use |
use |
Empty 5-qubit circuit with gate depth of 10 |
Note
In this example we are using https://pqcee.github.io/quicscript-dev-react/
as the base URL, do replace it with where you are hosting the website application
3.4 Embed Circuit Builder in Website¶
Follow these steps:
Basic Embedding
To embed the link
https://pqcee.github.io/quicscript-dev-react/
in an HTML file using an iframe:<iframe src="https://pqcee.github.io/quicscript-dev-react/?qibo=true&input=false" title="iFrame example" width="50%" height="600" allow="fullscreen"> </iframe>
Note
This code embeds the page, allows full-screen, enables qibo, disables input field, and adjusts the width and height.*
Adjusting
<iframe ...>
Parameters:Width: The width of the frame in CSS pixels. Default is 300.
Height: The height of the frame in CSS pixels. Default is 150.
Allow fullscreen:
To enable fullscreen mode for the iframe, add the
allow="fullscreen"
attribute.Optional Parameters:
See 3.3 Add New Circuit for more information on the URL parameters you can modify to create custom configurations.