Join Joe Marini for an in-depth discussion in this video Using patterns, part of Learning HTML Canvas.
- [Instructor] Just like with shadows,…the canvas element makes it easy to draw using patterns.…In fact all of the drawing operations that use fill…and strokeStyles can take patterns…as well as gradients, which we'll see in a bit,…as settings to draw with.…You can create patterns from images, video frames,…or even another canvas element.…If you specify a video,…then the current playback frame is used as the pattern.…It's not the full, live video.…The canvas will grab the current frame…and just use it as the pattern.…Patterns can be set to repeat in the x, y, or both axes.…
To create pattern function is used to create a pattern…and it takes a couple of arguments.…The first is the source element to create the pattern from…and the second argument specifies the repeat options…for the pattern, which you can see there.…Okay, so let's hop over to the code…and here in my editor,…I've got patterns_start open.…So first let's try creating a pattern from an image…and here in the images folder,…you can see I've got this image of a classic car,…
- Canvas examples
- Drawing shapes, arcs, paths, and curves
- Drawing text
- Drawing shadows, patterns, and gradients
- Using clipping paths
- Displaying images and video
- Transforming objects with scaling and rotation
- Manipulating raw pixels
- Applying transitions
- Creating animations
Skill Level Intermediate
1. Overview of Canvas
2. Basic Canvas Drawing Techniques
3. Complex Canvas Drawing
4. Advanced Drawing APIs
5. Practical Examples
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.