Skip to content

Unlock custom brushes, natural fill effects and intuitive hatching in p5.js

6.4 KB
Raw Blame
<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Pastel Hatching Test</title>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
    <script src="../../dist/p5.brush.js"></script>
    <script src="./p5_first_frame_profiler.js"></script>
    <style>
      :root {
        --paper: #f3eee2;
        --ink: #22313f;
        --muted: #52616e;
        --line: #d4c8b8;
        --panel: rgba(255, 252, 245, 0.86);
        --accent: #153e5c;
      }

      * { box-sizing: border-box; }

      body {
        margin: 0;
        color: var(--ink);
        background:
          radial-gradient(circle at top left, rgba(21, 62, 92, 0.08), transparent 24%),
          linear-gradient(180deg, #f7f2e7 0%, #ece3d3 100%);
        font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
      }

      main {
        width: min(920px, calc(100vw - 24px));
        margin: 0 auto;
        padding: 18px 0 24px;
        display: grid;
        justify-items: center;
      }

      main > * { width: 100%; }

      .nav {
        margin-bottom: 14px;
        font: 11px/1.2 Menlo, Monaco, "Courier New", monospace;
        display: flex;
        gap: 12px;
      }

      .nav a {
        color: var(--accent);
        text-decoration: none;
      }

      .nav a:hover { text-decoration: underline; }
      .nav .sep { color: #8a9aa8; }

      h1 {
        margin: 0 0 8px;
        font-size: clamp(24px, 3.6vw, 34px);
        letter-spacing: -0.04em;
      }

      p {
        margin: 0 0 8px;
        max-width: 760px;
        color: var(--muted);
        line-height: 1.45;
        font-size: 13px;
      }

      .workspace {
        margin-top: 18px;
        display: grid;
        grid-template-columns: 260px minmax(0, 1fr);
        gap: 18px;
        align-items: start;
      }

      button {
        border: 1px solid var(--line);
        border-radius: 999px;
        padding: 7px 12px;
        background: rgba(255, 252, 245, 0.95);
        color: var(--accent);
        font: 11px/1.2 Menlo, Monaco, "Courier New", monospace;
        cursor: pointer;
      }

      button:hover {
        background: #fff;
      }

      .panel {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
      }

      #controls {
        padding: 14px 16px;
        display: grid;
        gap: 12px;
        align-self: start;
      }

      .top-row {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
        justify-content: space-between;
        font: 11px/1.4 Menlo, Monaco, "Courier New", monospace;
      }

      .seed {
        display: flex;
        align-items: center;
        gap: 8px;
      }

      .seed strong {
        color: var(--accent);
        font-weight: 600;
      }

      .control-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        align-items: center;
        font: 11px/1.4 Menlo, Monaco, "Courier New", monospace;
      }

      label {
        display: grid;
        gap: 6px;
      }

      .slider-row {
        display: flex;
        align-items: center;
        gap: 8px;
      }

      input[type="range"] {
        flex: 1;
        min-width: 0;
      }

      .val {
        min-width: 34px;
        color: var(--accent);
        text-align: right;
      }

      select {
        border: 1px solid var(--line);
        border-radius: 6px;
        background: #fbf8f0;
        color: var(--ink);
        font: inherit;
        padding: 6px 8px;
      }

      .checkbox-row {
        display: flex;
        align-items: center;
        gap: 8px;
      }

      #canvas-host {
        padding: 10px;
        display: grid;
        justify-content: center;
        width: 100%;
        overflow: hidden;
      }

      canvas {
        display: block;
        border-radius: 6px;
        max-width: 100%;
        max-height: min(78vh, 760px);
        height: auto !important;
      }

      @media (max-width: 820px) {
        .workspace {
          grid-template-columns: 1fr;
        }
      }
    </style>
  </head>
  <body>
    <main>
      <div class="nav">
        <a href="../index.html">All tests</a>
        <span class="sep">·</span>
        <a href="../standalone/pastel_hatching_test.html">Standalone →</a>
      </div>
      <h1>Pastel Hatching Test</h1>
      <p>
        Minimal global-mode sketch with a custom crayon brush, scaled built-in brushes, and a single centered rectangle for trying pastel hatching ideas.
      </p>
      <div class="workspace">
        <div id="controls" class="panel">
          <div class="top-row">
            <div class="seed">
              <span>Seed</span>
              <strong id="seedVal">000000</strong>
            </div>
            <button id="refresh-seed" type="button">Refresh Seed</button>
          </div>

          <div class="control-grid">
            <label>
              Brush
              <select id="brushType">
                <option value="pastel">pastel</option>
                <option value="crayon">crayon</option>
                <option value="HB">HB</option>
                <option value="pen">pen</option>
              </select>
            </label>

            <label>
              Precision
              <div class="slider-row">
                <input type="range" id="precision" min="0" max="1" step="0.01" value="0.3" />
                <span class="val" id="precisionVal">0.3</span>
              </div>
            </label>

            <label>
              Strength
              <div class="slider-row">
                <input type="range" id="strength" min="0" max="1" step="0.01" value="0.6" />
                <span class="val" id="strengthVal">0.6</span>
              </div>
            </label>

            <label>
              Gradient
              <div class="slider-row">
                <input type="range" id="gradient" min="0" max="1" step="0.01" value="0.1" />
                <span class="val" id="gradientVal">0.1</span>
              </div>
            </label>

            <label class="checkbox-row">
              <input type="checkbox" id="outline" />
              Outline
            </label>
          </div>
        </div>

        <div id="canvas-host" class="panel"></div>
      </div>
    </main>
    <script src="./pastel_hatching_test.js"></script>
  <script src="../test-nav.js"></script>
  </body>
</html>