Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you use SVG, you can easily create the shapes with a function like:</p> <pre><code>/** * @param {SVGPathElement} aShape a SVG path element * @param {number} radius the radius of the plectrum's arc * @param {string} fillColor color in "#rrggbb" format */ function drawPlectrum(aShape, radius, fillColor) { // Creating a string which defines a path in SVG // M = moveto, A = line to, etc. See http://www.w3.org/TR/SVG/paths.html var ss="M "+parseInt(0)+" "+parseInt(0)+" "; // moveto 0, 0 ss+="L "+parseInt(0)+" "+parseInt(radius)+" "; // lineto 0, R ss+="A "+parseInt(radius)+" "+parseInt(radius)+" 0 0 0 "+parseInt(radius)+" "+parseInt(2*radius)+" ";// elliptic curve to R, 2*R ss+="A "+parseInt(radius)+" "+parseInt(radius)+" 0 0 0 "+parseInt(2*radius)+" "+parseInt(radius)+" ";// elliptic curve to 2*R, R ss+="A "+parseInt(radius)+" "+parseInt(radius)+" 0 0 0 "+parseInt(radius)+" "+parseInt(0)+" "; // elliptic curve to R, 0 ss+="Z"; // closepath // The d attribute of the path element holds the line information // In XML the element will essentially be &lt;path d="*the created string*"&gt; aShape.setAttribute("d", ss); // Give the color aShape.setAttribute("fill", fillColor); } </code></pre> <p>Successive drawings looks something like this:</p> <pre><code> // Note that 3 different path elements are used to overlap the plectrums drawPlectrum(node, 100, "#aaaaaa"); drawPlectrum(node2, 75, "#33dd33"); drawPlectrum(node3, 50, "#3333dd"); </code></pre> <p><strong>Edit 1:</strong> Added more comments in the code for better understandibility</p> <p><img src="https://i.stack.imgur.com/6L3W3.gif" alt="plectrum"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload