From the course: JavaScript: Modern Browser APIs
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Parameters with CSS Paint API - JavaScript Tutorial
From the course: JavaScript: Modern Browser APIs
Parameters with CSS Paint API
- [Instructor] Okay, let's pick up where we left off on our last example by adding the ability to customize the image that gets drawn by using CSS custom properties. So, here in my editor, I'm going to open up the CSS start html and CSS paint start JS files, and you can see this is where we left off. So, what I need to do first is define two custom properties in my style sheet that are going to represent the thickness and color of the lines. So, I'm going to use dash dash cross thickness, and I'll give that a value of two, and then I'll define cross color, which will be red. Then in my painter class definition, I have to define a static method that declares what properties my class uses. So, I'll write a static getter, and it's called input properties. This method is going to return an array that identifies the name of the properties that I want to access from CSS. So, the first one is dash dash cross thickness, and the second one is, dash dash cross color. Then, I just need to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Native overlays with the Dialog API5m 54s
-
(Locked)
Integrating with native notifications7m 21s
-
(Locked)
Detecting network conditions7m 44s
-
(Locked)
Using page visibility3m 44s
-
(Locked)
Going full screen with content4m 39s
-
(Locked)
Using full-screen events and styling4m 40s
-
(Locked)
Dynamic images with CSS Paint API6m 35s
-
(Locked)
Parameters with CSS Paint API3m 45s
-
(Locked)
-