នៅក្នងគំនូរ 2D នៅលើធាតុ canvas យើងអាចបង្កើត ពណ៌ប្រដេញ (gradient) បានគ្រប់បែបយ៉ាង សំរាប់ដាក់អោយរូបនិងអត្ថបទគ្រប់ប្រភេទ។ យ៉ាងណាម៉ិញ ពណ៌ប្រដេញមាន ២ ប្រភេទគឺ ពណ៌ប្រដេញត្រង់ (linear gradient) និង ពណ៌ប្រដេញមូល (radial/circular gradient) ។ នៅក្នុងការបង្កើតពណ៌ប្រដេញត្រង់ យើងត្រូវយកវិធីមានស្រាប់ឈ្មោះ createLinearGradient(x,y,x1,y1) មកប្រើ ដោយធ្វើដូចខាងក្រោមនេះ៖
ស្រដៀងគ្នាដែរ នៅក្នុងការបង្កើតពណ៌ប្រដេញមូល យើងចាំបាច់ត្រូវយកវិធីមានស្រាប់ឈ្មោះ reateRadialGradient(x,y,r,x1,y1,r1) មកប្រើដោយធ្វើដូចខាងក្រោមនេះ៖
Colors, Styles, and Shadows
| Method | Description |
|---|---|
| createLinearGradient() | Creates a linear gradient (to use on canvas content) |
| createPattern() | Repeats a specified element in the specified direction |
| createRadialGradient() | Creates a radial/circular gradient (to use on canvas content) |
| addColorStop() | Specifies the colors and stop positions in a gradient object |
| fillStyle | Sets or returns the color, gradient, or pattern used to fill the drawing |
| strokeStyle | Sets or returns the color, gradient, or pattern used for strokes |
| shadowColor | Sets or returns the color to use for shadows |
| shadowBlur | Sets or returns the blur level for shadows |
| shadowOffsetX | Sets or returns the horizontal distance of the shadow from the shape |
| shadowOffsetY | Sets or returns the vertical distance of the shadow from the shape |














