Coder Social home page Coder Social logo

P5 windowResized about react-p5 HOT 2 CLOSED

gherciu avatar gherciu commented on July 24, 2024
P5 windowResized

from react-p5.

Comments (2)

thisSource avatar thisSource commented on July 24, 2024

this will work

export default (props) => {
	// colorTeal;
	// console.log('🚀 ~ file: index.js ~ line 10 ~ colorTeal', colorTeal);
	// const x = props.x;
	// const y = props.y;
	const setup = (p5, canvasParentRef) => {
		p5.createCanvas(window.innerWidth, window.innerHeight).parent(
			canvasParentRef
		);
	};

	const draw = (p5) => {
    windowResized(p5)
		p5.background('#319795');
		p5.ellipse(100, 100, 70, 70);
		// x++;
	};
	const windowResized = (p5) => {
		p5.resizeCanvas(window.innerWidth / 2, window.innerHeight / 2);
	};
	// Will only render on client-side
	return <Sketch setup={setup} draw={draw}/>;
}

from react-p5.

Gherciu avatar Gherciu commented on July 24, 2024

@jamesgrubb @thisSource I'm gonna close this issue because I tested and windowResized events works perfectly....
@jamesgrubb try to put there a console log and resize the screen and you'll see that it works.......
The only problem which I see in your code is that you are calling resizeCanvas method without p5. in front

from react-p5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.