scale() and "number is not a function"
in
Processing with Other Languages
•
2 years ago
All,
I am attempting to scale my entire sketch based on the width and height of the corresponding sketch's canvas and it seems like it should be straight-forward; I calculate the XY scale and return the value as a float. I can print this value with a println, but as soon as I attempt to scale using this value (or
any value, to be exact), I receive the following JavaScript error:
- Uncaught TypeError: number is not a function
I'd love to know what I am doing wrong.
This is a small snippet of my
draw function:
- void draw(){
- scale((float)getScaleXY(1024)); // TypeError!
- scale(1.2); // TypeError!
- // Display current mouse over information in the status area of raster
- printStatus();
- // Fetches and displays data
- sample(min,max);
- }
- // I have a jQuery method that calls procesingInstance.scaleSketch(), which has the same issue
- void scaleSketch() {
- println("Proposed ScaleXY: " + getScaleXY(1024)); // Works!
- float newScale = getScaleXY(1024);
- scale((float)newScale); // TypeError!
- }
JavaScript:
- // Handle resize of window
- $(window).resize(function(){
- var containerWidth = $("#container").width();
- var containerHeight = $("#container").height();
- if (!processingInstance) {
- processingInstance = Processing.getInstanceById('canvas');
- }
- processingInstance.size(containerWidth, containerHeight);
- processingInstance.scaleSketch();
- });
Thank you!
1