Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p5 costants seems to be unrecognized #9

Closed
wanbinkimoon opened this issue Jun 28, 2017 · 4 comments
Closed

p5 costants seems to be unrecognized #9

wanbinkimoon opened this issue Jun 28, 2017 · 4 comments

Comments

@wanbinkimoon
Copy link

Sorry to bother, I'm trying to use you super-helpful component BUT when I use p5 costants like PI or HALF_PI I recive un error of undefined am I the only? there is a way to fix this?

@bsaphier
Copy link
Contributor

bsaphier commented Jul 2, 2017

can you post a sample of the code you're running?

FYI: the following code is identical to those p5 constants

const PI = Math.PI;
module.exports = {
  PI:         PI,
  TAU:        PI * 2,
  TWO_PI:     PI * 2,
  HALF_PI:    PI / 2,
  QUARTER_PI: PI / 4
}

@wanbinkimoon
Copy link
Author

My concern is with the alignment options, here and example:

function Graph(p) {
  p.setup = function() {
    canvas = p.createCanvas(200, 200);
    ctx = canvas.drawingContext;
		
    p.textAlign(CENTER, CENTER);
    p.strokeCap(SQUARE);
  }
...
}
...
<P5Wrapper sketch={Graph} percentage={this.props.percentage} />

Is stuff like CENTER and SQUARE that return me errors

@bsaphier
Copy link
Contributor

bsaphier commented Jul 3, 2017

can you refer me to CENTER and SQUARE in the docs? I'm not familiar with those constants. things like TAU, PI, etc all work within the scope of the sketch function, i.e.

function sketch(p) {
    console.log(p.HALF_PI);
}

the above code would print correctly in your console

@wanbinkimoon
Copy link
Author

wanbinkimoon commented Jul 4, 2017 via email

@bsaphier bsaphier closed this as completed Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants