You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Obtaining crisp lines requires understanding how paths are stroked. In the images below, the grid represents the canvas coordinate grid. The squares between gridlines are actual on-screen pixels. In the first grid image below, a rectangle from (2,1) to (5,5) is filled. The entire area between them (light red) falls on pixel boundaries, so the resulting filled rectangle will have crisp edges.
@@ -545,7 +545,7 @@ The first is a background gradient. As you can see, we assigned two colors at th
545
545
546
546
In the second gradient, we didn't assign the starting color (at position 0.0) since it wasn't strictly necessary, because it will automatically assume the color of the next color stop. Therefore, assigning the black color at position 0.5 automatically makes the gradient, from the start to this stop, black.
@@ -600,7 +600,7 @@ In this case, we've offset the starting point slightly from the end point to ach
600
600
601
601
The last color stop in each of the four gradients uses a fully transparent color. If you want to have a nice transition from this to the previous color stop, both colors should be equal. This isn't very obvious from the code because it uses two different CSS color methods as a demonstration, but in the first gradient `#019F62 = rgb(1 159 98 / 100%)`.
@@ -648,7 +648,7 @@ The first gradient is positioned in the center of the first rectangle and moves
648
648
649
649
The second gradient is also positioned at the center of it's second rectangle. This one has multiple color stops, alternating from black to white at each quarter of the rotation. This gives us the checkered effect.
We will look at the `font` property and `fillText` method in the next chapter about [drawing text](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text).
Copy file name to clipboardExpand all lines: files/en-us/web/api/canvas_api/tutorial/compositing/index.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ In the first few lines of code, we draw a black rectangle the size of the canvas
101
101
102
102
Everything that's drawn after creating the clipping path will only appear inside that path. You can see this clearly in the linear gradient that's drawn next. After this a set of 50 randomly positioned and scaled stars is drawn, using the custom `drawStar()` function. Again the stars only appear inside the defined clipping path.
Copy file name to clipboardExpand all lines: files/en-us/web/api/canvas_api/tutorial/transformations/index.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ So far this is pretty similar to what we've done in previous sections. However o
82
82
83
83
When the second `restore()` statement is called, the original state (the one we set up before the first call to `save`) is restored and the last rectangle is once again drawn in black.
0 commit comments