Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Adding an "Erase" button to Simple Drawing App - How-To

I've been looking around to find a way to add a button to my Simple Drawing App project in the jQuery Basics course, to no avail. I tried a little bit on my own, but all I could do was append a button to the end of the div containing the canvas.

Where do I go next?

I appreciate your time.

2 Answers

My suggestion would be to create a button with the color of the canvas. Then use a slider to set the line width, the size of the eraser if you like. You can set it like this context.lineWidth = x;, where x is the value on the slider.

How do I get different brush textures other than lineWidth? Would I have to download a plugin?