Skip to content

stroke() is not a function #4723

@diivi

Description

@diivi

Most appropriate sub-area of p5.js?

  • [X ] Color
  • [X ] Core/Environment/Rendering
  • Data
  • Dom
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Other (specify if possible)

Details about the bug:

  • p5.js version: 0.7.3
  • Web browser and version : Google Chrome | 84.0.4147.105
  • Operating System: Windows
  • Steps to reproduce this:
  <div class="options">
    <ul>
        <li>
            <label for="color">Color:</label>
            <input type="color" id="color" value="#ffffff" onchange="update(this.value)"/>
        </li>
        <li>
            <label for="weight">Stroke:</label>
            <input type="number" id="weight" min="2" max="200" value="3" onchange="updatestr(this.value)"/>
        </li>
        <li>
            <button id="clear">clear</button>
        </li>
    </ul>
</div>
function update(clr){
  window.colorr = clr;
}
function updatestr(str){
  window.stroke = parseInt(str);
  console.log(stroke)
}
function mouseDragged() {

  strokeWeight(stroke);
  stroke(colorr);
  line(mouseX, mouseY, pmouseX, pmouseY);
  // Make a little object with mouseX and mouseY
  let data = {
    x: mouseX,
    y: mouseY,
    px:pmouseX,
    py:pmouseY,
    clr:colorr,
    str:stroke
  };
  // Send that object to the socket
  socket.emit('mouse',data);
}
stroke is not a function
    at mouseDragged

When I added the on update function to the number input element, I could not change the stroke color of the p5 line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions