jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.27k stars 454 forks source link

[Question] Why Two.makeRoundedRectangle returns Two.Rectangle #686

Closed zhangzheheng12345 closed 1 year ago

zhangzheheng12345 commented 1 year ago

Just want to ask why Two.makeRoundedRectangle returns Two.Rectangle but not Two.RoundedRectangle? And how to create a rounded rectangle whose radius can be changed?

jonobr1 commented 1 year ago

Looks like only the documentation is incorrect. The code does return a Two.RoundedRectangle. You can modify the radius property like in this Codepen to change the radius.

jonobr1 commented 1 year ago

This commit fixes the documentation. It will take a few days for the docs on the website to reflect these changes. Thanks for posting!

zhangzheheng12345 commented 1 year ago

Yeah in the codepen it works well, but in my project, it seems just not work. Neither can I pass the build process (tsup, while generating .d.ts file) or make the code editor with no error marks. My Two.js version is v0.8.10. And if I find a place to upload images, I'll put up my screen shots.

zhangzheheng12345 commented 1 year ago

Photos here:

jonobr1 commented 1 year ago

Thanks for sharing. The types for TypeScript are generated from the documentation, so the types are incorrect throwing errors in your project. If you want to remedy the issue immediately, use the github version of the repository instead of npm. You can use it like so:

npm install --save https://github.com/jonobr1/two.js
zhangzheheng12345 commented 1 year ago

OK I got it. Thank you for solving my problem. I'll use github version first and really hope this can be solved soon in the next npm version. Issue closed.

jonobr1 commented 1 year ago

Yes, this will be fixed in the next NPM version. Thanks again for posting!