This is a JavaScript library designed for creating programs in CodeHS.
The library is used in JavaScript Graphics programs in CodeHS. To use the library in an online IDE, visit codehs.com/ide.
There are several options for using the library outside of CodeHS. If a <canvas> element is present on the page, the library will use it, otherwise it will create its own.
To use the library via CDN, create an HTML program with the following
<script>
tag after any <canvas>
element
you wish to draw to:
<canvas width="500" height="500"></canvas>
<script src="https://unpkg.com/chs-js-lib@latest/dist/chs.iife.js" type="text/javascript"></script>
<script type="text/javascript">
var c = new Circle(300);
add(c);
</script>
The library will automatically load, and any <script>
s
previous to it will have access to its methods.
Note that only script tags after the script importing the library.
A script tag with type="module"
can import directly from the
library. This is more advanced usage.
<script type="module">
import {Circle, Graphics} from "https://unpkg.com/chs-js-lib@latest/dist/chs.mjs";
const graphics = new Graphics();
graphics.add(new Circle(50));
</script>