Skip to content

Commit c20e64d

Browse files
committed
Integrate proofreading for Chapter 19
1 parent 41d828c commit c20e64d

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

19_paint.txt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ canvas—it contains the current picture as well as the selected color
149149
property).
150150

151151
(((class attribute)))(((CSS)))We wrap the canvas and the controls in
152-
`<div>` elements with classes to be able to add some styling, such as
152+
`<div>` elements with classes so we can add some styling, such as
153153
a gray border around the picture.
154154

155155
== Tool selection ==
@@ -158,7 +158,7 @@ a gray border around the picture.
158158
tag))))The first control we add is the `<select>` element that
159159
allows the user to pick a drawing ((tool)). As with `controls`, we
160160
will use an object to collect the various tools so that we do not
161-
have to hard-code them all in one place and we can add more tools later.
161+
have to hard-code them all in one place and can add more tools later.
162162
This object associates the names of the tools with the function that
163163
should be called when they are selected and the canvas is clicked.
164164

@@ -187,7 +187,7 @@ controls.tool = function(cx) {
187187

188188
(((preventDefault method)))(((selection)))(((option (HTML
189189
tag))))(((mousedown event)))The tool field is populated with
190-
`<option>` elements for all tools that have been defined and a
190+
`<option>` elements for all tools that have been defined, and a
191191
`"mousedown"` handler on the canvas element takes care of calling the
192192
function for the current tool, passing it both the ((event object))
193193
and the drawing ((context)) as arguments. It also calls
@@ -197,7 +197,7 @@ not cause the browser to select parts of the page.
197197
(((relativePos function)))(((event object)))(((getBoundingClientRect
198198
method)))(((clientX property)))(((clientY property)))The most basic
199199
tool is the ((line tool)), which allows the user to draw lines with
200-
the ((mouse)). To be able to put the line ends in the right place, we
200+
the ((mouse)). To put the line ends in the right place, we
201201
need to be able to find the canvas-relative ((coordinates)) that a
202202
given mouse event corresponds to. The `getBoundingClientRect` method,
203203
briefly mentioned in link:13_dom.html#boundingRect[Chapter 13], can
@@ -287,8 +287,8 @@ mouse's old and new position, using whatever `strokeStyle` and
287287
through to `trackDrag`. The normal way to run tools won't pass a third
288288
argument, so when using the line tool, that argument will hold
289289
`undefined`, and nothing happens at the end of the mouse drag. The
290-
argument is there to allow us to implement the erase tool on top of
291-
the line tool with very little additional code.
290+
argument is there to allow us to implement the erase tool on top of
291+
the line tool with very little additional code.
292292

293293
// include_code
294294

@@ -311,7 +311,7 @@ color is overlaid on the existing color at that spot. If the ((color)) is
311311
opaque, it will simply replace the old color, but if it is
312312
partially transparent, the two will be mixed.
313313

314-
The erase tool sets `globalCompositeOperation` to
314+
The erase tool sets `globalCompositeOperation` to
315315
`"destination-out"`, which has the effect of erasing the pixels we
316316
touch, making them transparent again.
317317

@@ -408,7 +408,7 @@ simple HTML document:
408408
data:text/html,<h1 style="color:red">Hello!</h1>
409409
----
410410

411-
Such URLs are useful for various tasks, such as including small
411+
Data URLs are useful for various tasks, such as including small
412412
images directly in a ((style sheet)) file. They also allow us to link
413413
to files that we created on the client side, in the browser, without
414414
first moving them to some server.
@@ -602,7 +602,7 @@ base the font size on the current brush size. The minimum size is 7
602602
pixels because text smaller than that is unreadable.
603603

604604
(((spray paint tool)))(((random number)))Another indispensable tool
605-
for drawing amateurish computer graphics is the spray paint tool.
605+
for drawing amateurish computer graphics is the spray paint tool.
606606
This one draws dots in random locations under the ((brush)) as long as
607607
the mouse is held down, creating denser or less dense speckling
608608
based on how fast or slow the mouse moves.
@@ -812,14 +812,14 @@ pixelAt(cx, 10, 10);
812812
// → [255, 0, 0, 255]
813813
----
814814

815-
The arguments to `getImageData` indicate the starting x and y
816-
coordinates of the rectangle we want to retrieve, followed by its
815+
The arguments to `getImageData` indicate the starting x- and
816+
y-coordinates of the rectangle we want to retrieve, followed by its
817817
width and height.
818818

819819
(((transparent)))Ignore transparency during this exercise and look
820820
only at the first three values for a given pixel. Also, do not worry
821821
about updating the color field when the user picks a color. Just make
822-
sure that the drawing context's `fillStyle` and `strokeStyle` get set
822+
sure that the drawing context's `fillStyle` and `strokeStyle` are set
823823
to the color under the mouse cursor.
824824

825825
(((rgb (CSS))))Remember that these properties accept any color that
@@ -874,8 +874,8 @@ to a tricky problem. Make sure you have plenty of time and
874874
((patience)) before starting to work on this exercise, and do not get
875875
discouraged by initial failures.
876876

877-
(((bucket fill)))A flood fill tool colors the pixel under the mouse
878-
and the whole group of pixels around it that have the same color. For
877+
(((bucket fill)))A flood fill tool colors the pixel under the mouse
878+
and the surrounding pixels of the same color. For
879879
the purpose of this exercise, we will consider such a group to include
880880
all pixels that can be reached from our starting pixel by moving in
881881
single-pixel horizontal and vertical steps (not diagonal), without
@@ -898,7 +898,7 @@ out pixel data from the resulting array. The pixels are organized in
898898
this array in a similar way to the ((grid)) elements in
899899
link:07_elife.html#grid[Chapter 7], one row at a time, except that
900900
each pixel is represented by four values. The first value for the
901-
pixel at (x,y) is at position (x + y × width) × 4.
901+
pixel at (_x_,_y_) is at position (_x_ + _y_ × width) × 4.
902902

903903
(((alpha)))(((transparent)))Do include the fourth (alpha) value this
904904
time since we want to be able to tell the difference between empty
@@ -917,12 +917,12 @@ you finish your current walk.
917917

918918
(((performance)))(((optimization)))In a normal-sized picture, there are
919919
a _lot_ of pixels. Thus, you must take care to do the minimal amount
920-
of work required or your program will take a very long to run. For
920+
of work required or your program will take a very long time to run. For
921921
example, every walk must ignore pixels seen by previous walks so that
922922
it does not redo work that has already been done.
923923

924924
(((fillRect method)))I recommend calling `fillRect` for individual
925-
pixels when a pixel that should be colored is found and keeping some
925+
pixels when a pixel that should be colored is found, and keeping some
926926
data structure that tells you about all the pixels that have already
927927
been looked at.
928928

0 commit comments

Comments
 (0)