Skip to content

friendly error system not catching overwritten p5 functions when variables declared with let or const #4255

@belezyc

Description

@belezyc

Most appropriate sub-area of p5.js?

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

Details about the bug:

  • p5.js version: p5.js v0.10.2 January 15, 2020
  • Web browser and version: Google Chrome | 79.0.3945.117 (Build officiel) (64 bits) (cohort: Stable)
  • Operating System: Windows 10
  • Steps to reproduce this:
    Description: I'm would like to zoomIn the canvas. With p5 web editor it is working fine
  1. index.html extract, create a section to receive the p5 canvas and at bottom of body, include p5.min.js:

    <script type="text/javascript" src="./p5.js"></script>
  2. In function draw() call function scale() to rescale de canvas content (which consiste of a simple ellipse before and after the scale):
    function draw() {
    background(220, 180, 200);
    // Set ellipse in middle of screen middle of screen
    ellipse(width/2, height/2, 80, 80);
    scale(0.5);
    // Set ellipse in middle of screen middle of screen after scale
    ellipse(width/2, height/2, 80, 80);
    }

Error message is:
sketch.js:30 Uncaught TypeError: scale is not a function
at draw (sketch.js:30)
at p5._main.default.redraw (p5.js:66218)
at _draw (p5.js:58914)

  draw @ sketch.js:30
  _main.default.redraw @ p5.js:66218
  _draw @ p5.js:58914
  requestAnimationFrame (async)    
  _draw @ p5.js:58937
  requestAnimationFrame (async)    
  _draw @ p5.js:58937
  _start @ p5.js:58785
  p5 @ p5.js:59125
  _globalInit @ p5.js:58352
  load (async)    
  25.../core/main @ p5.js:58365
  o @ p5.js:34
  (anonymous) @ p5.js:38
  16../color/color_conversion @ p5.js:52635
  o @ p5.js:34
  r @ p5.js:51
  (anonymous) @ p5.js:55
  (anonymous) @ p5.js:18
  (anonymous) @ p5.js:20

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions