JSXGraph logo
JSXGraph
JSXGraph share

Share

HSV color scheme
QR code
<iframe 
    src="https://jsxgraph.org/share/iframe/hsv-color-scheme-1" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: HSV color scheme" 
    allowfullscreen
></iframe>
This code has to
<div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; ">
   <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div>
</div>

<script type = "text/javascript"> 
    /*
    This example is licensed under a 
    Creative Commons Attribution ShareAlike 4.0 International License.
    https://creativecommons.org/licenses/by-sa/4.0/
    
    Please note you have to mention 
    The Center of Mobile Learning with Digital Technology
    in the credits.
    */
    
    const BOARDID = 'board-0';

    var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-4, 4, 4, -4], keepaspectratio: true });
    var H = board.create('slider', [[-3, 3.5], [2, 3.5], [0, 1, 360]], { name: 'H', fillColor: 'black',
        strokeColor: 'black' });
    var S = board.create('slider', [[-3, 3], [2, 3], [0, 1, 1]], { name: 'S', fillColor: 'black', strokeColor: 'black' });
    var V = board.create('slider', [[-3, 2.5], [2, 2.5], [0, 1, 1]], { name: 'V', fillColor: 'black', strokeColor: 'black' });
    
    var r1 = 2;
    var r2 = 1 / 4.75;
    var lambda = 8;
    
    var c1 = board.create('curve', [
              function(t) { return r1 * Math.sin(t) + r2 * Math.sin(lambda * t); },
              function(t) { return r1 * Math.cos(t) + r2 * Math.cos(lambda * t) - 0.2; },
              0, 2 * Math.PI],
    {
        fillcolor: function() { return JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); },
        highlightFillcolor: function() { return JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); },
        strokeColor: 'black',
        strokeWidth: 3,
        gradient: 'radial',
        gradientsecondcolor: 'white'
    });
    
    var c2 = board.create('curve', [
              function(t) { return Math.sin(t); },
              function(t) { return Math.cos(t) - 0.2; },
              0, 2 * Math.PI],
    {
        fillcolor: function() { return JXG.hsv2rgb(180 + H.Value(), S.Value(), V.Value()); },
        highlightFillcolor: function() { return JXG.hsv2rgb(180 + H.Value(), S.Value(), V.Value()); },
        strokewidth: 3,
        strokeColor: 'black',
        gradient: 'linear'
    });
    var t = board.create('text', [2, -3, function() { return 'RGB=' + JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); }], { fontSize: 32 });
 </script> 
/*
This example is licensed under a 
Creative Commons Attribution ShareAlike 4.0 International License.
https://creativecommons.org/licenses/by-sa/4.0/

Please note you have to mention 
The Center of Mobile Learning with Digital Technology
in the credits.
*/

const BOARDID = 'your_div_id'; // Insert your id here!

var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-4, 4, 4, -4], keepaspectratio: true });
var H = board.create('slider', [[-3, 3.5], [2, 3.5], [0, 1, 360]], { name: 'H', fillColor: 'black',
    strokeColor: 'black' });
var S = board.create('slider', [[-3, 3], [2, 3], [0, 1, 1]], { name: 'S', fillColor: 'black', strokeColor: 'black' });
var V = board.create('slider', [[-3, 2.5], [2, 2.5], [0, 1, 1]], { name: 'V', fillColor: 'black', strokeColor: 'black' });

var r1 = 2;
var r2 = 1 / 4.75;
var lambda = 8;

var c1 = board.create('curve', [
          function(t) { return r1 * Math.sin(t) + r2 * Math.sin(lambda * t); },
          function(t) { return r1 * Math.cos(t) + r2 * Math.cos(lambda * t) - 0.2; },
          0, 2 * Math.PI],
{
    fillcolor: function() { return JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); },
    highlightFillcolor: function() { return JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); },
    strokeColor: 'black',
    strokeWidth: 3,
    gradient: 'radial',
    gradientsecondcolor: 'white'
});

var c2 = board.create('curve', [
          function(t) { return Math.sin(t); },
          function(t) { return Math.cos(t) - 0.2; },
          0, 2 * Math.PI],
{
    fillcolor: function() { return JXG.hsv2rgb(180 + H.Value(), S.Value(), V.Value()); },
    highlightFillcolor: function() { return JXG.hsv2rgb(180 + H.Value(), S.Value(), V.Value()); },
    strokewidth: 3,
    strokeColor: 'black',
    gradient: 'linear'
});
var t = board.create('text', [2, -3, function() { return 'RGB=' + JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); }], { fontSize: 32 });
<jsxgraph width="100%" aspect-ratio="1 / 1" title="HSV color scheme" description="This construction was copied from JSXGraph examples database: BTW HERE SHOULD BE A GENERATED LINKuseGlobalJS="false">
   /*
   This example is licensed under a 
   Creative Commons Attribution ShareAlike 4.0 International License.
   https://creativecommons.org/licenses/by-sa/4.0/
   
   Please note you have to mention 
   The Center of Mobile Learning with Digital Technology
   in the credits.
   */
   
   var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-4, 4, 4, -4], keepaspectratio: true });
   var H = board.create('slider', [[-3, 3.5], [2, 3.5], [0, 1, 360]], { name: 'H', fillColor: 'black',
       strokeColor: 'black' });
   var S = board.create('slider', [[-3, 3], [2, 3], [0, 1, 1]], { name: 'S', fillColor: 'black', strokeColor: 'black' });
   var V = board.create('slider', [[-3, 2.5], [2, 2.5], [0, 1, 1]], { name: 'V', fillColor: 'black', strokeColor: 'black' });
   
   var r1 = 2;
   var r2 = 1 / 4.75;
   var lambda = 8;
   
   var c1 = board.create('curve', [
             function(t) { return r1 * Math.sin(t) + r2 * Math.sin(lambda * t); },
             function(t) { return r1 * Math.cos(t) + r2 * Math.cos(lambda * t) - 0.2; },
             0, 2 * Math.PI],
   {
       fillcolor: function() { return JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); },
       highlightFillcolor: function() { return JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); },
       strokeColor: 'black',
       strokeWidth: 3,
       gradient: 'radial',
       gradientsecondcolor: 'white'
   });
   
   var c2 = board.create('curve', [
             function(t) { return Math.sin(t); },
             function(t) { return Math.cos(t) - 0.2; },
             0, 2 * Math.PI],
   {
       fillcolor: function() { return JXG.hsv2rgb(180 + H.Value(), S.Value(), V.Value()); },
       highlightFillcolor: function() { return JXG.hsv2rgb(180 + H.Value(), S.Value(), V.Value()); },
       strokewidth: 3,
       strokeColor: 'black',
       gradient: 'linear'
   });
   var t = board.create('text', [2, -3, function() { return 'RGB=' + JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); }], { fontSize: 32 });
</jsxgraph>

HSV color scheme

The HSV color scheme consists of three values: * Hue (base color): between 0 and 360 * Saturation (purity): between 0 and 1 * Value (brightness): between 0 and 1 Here, you can experiment with these values.
// Define the id of your board in BOARDID

var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-4, 4, 4, -4], keepaspectratio: true });
var H = board.create('slider', [[-3, 3.5], [2, 3.5], [0, 1, 360]], { name: 'H', fillColor: 'black',
    strokeColor: 'black' });
var S = board.create('slider', [[-3, 3], [2, 3], [0, 1, 1]], { name: 'S', fillColor: 'black', strokeColor: 'black' });
var V = board.create('slider', [[-3, 2.5], [2, 2.5], [0, 1, 1]], { name: 'V', fillColor: 'black', strokeColor: 'black' });

var r1 = 2;
var r2 = 1 / 4.75;
var lambda = 8;

var c1 = board.create('curve', [
          function(t) { return r1 * Math.sin(t) + r2 * Math.sin(lambda * t); },
          function(t) { return r1 * Math.cos(t) + r2 * Math.cos(lambda * t) - 0.2; },
          0, 2 * Math.PI],
{
    fillcolor: function() { return JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); },
    highlightFillcolor: function() { return JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); },
    strokeColor: 'black',
    strokeWidth: 3,
    gradient: 'radial',
    gradientsecondcolor: 'white'
});

var c2 = board.create('curve', [
          function(t) { return Math.sin(t); },
          function(t) { return Math.cos(t) - 0.2; },
          0, 2 * Math.PI],
{
    fillcolor: function() { return JXG.hsv2rgb(180 + H.Value(), S.Value(), V.Value()); },
    highlightFillcolor: function() { return JXG.hsv2rgb(180 + H.Value(), S.Value(), V.Value()); },
    strokewidth: 3,
    strokeColor: 'black',
    gradient: 'linear'
});
var t = board.create('text', [2, -3, function() { return 'RGB=' + JXG.hsv2rgb(H.Value(), S.Value(), V.Value()); }], { fontSize: 32 });

license

This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License.
Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.