Skip to content

Commit

Permalink
Merge pull request #2827 from Damus666/american-spelling-cleanup
Browse files Browse the repository at this point in the history
Cleanup codebase, docs and examples with American spelling
  • Loading branch information
oddbookworm authored Apr 27, 2024
2 parents 3072e52 + 70ae2c6 commit e404dbc
Show file tree
Hide file tree
Showing 18 changed files with 189 additions and 191 deletions.
2 changes: 1 addition & 1 deletion docs/reST/ref/color.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
| :sl:`returns a Color where the r,g,b components have been multiplied by the alpha.`
| :sg:`premul_alpha() -> Color`
Returns a new Color where each of the red, green and blue colour
Returns a new Color where each of the red, green and blue color
channels have been multiplied by the alpha channel of the original
color. The alpha channel remains unchanged.

Expand Down
2 changes: 1 addition & 1 deletion docs/reST/ref/pygame.rst
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ available. Must be set before calling :func:`pygame.display.set_mode()`.
This makes pygame use the SDL2 blitter for all alpha
blending. The SDL2 blitter is sometimes faster than
the default blitter but uses a different formula so
the final colours may differ. Must be set before
the final colors may differ. Must be set before
:func:`pygame.init()` is called.

|
Expand Down
14 changes: 7 additions & 7 deletions docs/reST/ref/surface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1003,14 +1003,14 @@
blend mode flag of the blit() method. Surfaces which have called this method will only look
correct after blitting if the BLEND_PREMULTIPLED special flag is used.

It is worth noting that after calling this method, methods that return the colour of a pixel
such as get_at() will return the alpha multiplied colour values. It is not possible to fully
reverse an alpha multiplication of the colours in a surface as integer colour channel data
It is worth noting that after calling this method, methods that return the color of a pixel
such as get_at() will return the alpha multiplied color values. It is not possible to fully
reverse an alpha multiplication of the colors in a surface as integer color channel data
is generally reduced by the operation (e.g. 255 x 0 = 0, from there it is not possible to reconstruct
the original 255 from just the two remaining zeros in the colour and alpha channels).
the original 255 from just the two remaining zeros in the color and alpha channels).

If you call this method, and then call it again, it will multiply the colour channels by the alpha channel
twice. There are many possible ways to obtain a surface with the colour channels pre-multiplied by the
If you call this method, and then call it again, it will multiply the color channels by the alpha channel
twice. There are many possible ways to obtain a surface with the color channels pre-multiplied by the
alpha channel in pygame, and it is not possible to tell the difference just from the information in the pixels.
It is completely possible to have two identical surfaces - one intended for pre-multiplied alpha blending and
one intended for normal blending. For this reason we do not store state on surfaces intended for pre-multiplied
Expand All @@ -1022,7 +1022,7 @@

In general pre-multiplied alpha blitting is faster then 'straight alpha' blitting and produces
superior results when blitting an alpha surface onto another surface with alpha - assuming both
surfaces contain pre-multiplied alpha colours.
surfaces contain pre-multiplied alpha colors.

There is a `tutorial on premultiplied alpha blending here. <tutorials/en/premultiplied-alpha>`

Expand Down
2 changes: 1 addition & 1 deletion docs/reST/ref/transform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Instead, always begin with the original image and scale to the desired size.)

palette_colors - if true we average the colors in palette, otherwise we
average the pixel values. This is useful if the surface is actually
greyscale colors, and not palette colors.
grayscale colors, and not palette colors.

Note, this function currently does not handle palette using surfaces
correctly.
Expand Down
2 changes: 1 addition & 1 deletion docs/reST/tutorials/en/chimp-explanation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ also needs to know the size of font we want to create.
We then render that font into a new surface. The `render` function creates
a new surface that is the appropriate size for our text. In this case
we are also telling render to create antialiased text (for a nice smooth
look) and to use a dark grey color.
look) and to use a dark gray color.

Next we need to find the centered position of the text on our display.
We create a "Rect" object from the text dimensions, which allows us to
Expand Down
44 changes: 21 additions & 23 deletions examples/glcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,24 +258,24 @@ def init_gl_modern(display_size):
uniform mat4 view;
uniform mat4 projection;
uniform vec4 colour_mul;
uniform vec4 colour_add;
uniform vec4 color_mul;
uniform vec4 color_add;
in vec4 vertex_colour; // vertex colour in
in vec4 vertex_color; // vertex color in
in vec3 vertex_position;
out vec4 vertex_color_out; // vertex colour out
out vec4 vertex_color_out; // vertex color out
void main()
{
vertex_color_out = (colour_mul * vertex_colour) + colour_add;
vertex_color_out = (color_mul * vertex_color) + color_add;
gl_Position = projection * view * model * vec4(vertex_position, 1.0);
}
"""

fragment_code = """
#version 150
in vec4 vertex_color_out; // vertex colour from vertex shader
in vec4 vertex_color_out; // vertex color from vertex shader
out vec4 fragColor;
void main()
{
Expand Down Expand Up @@ -319,9 +319,7 @@ def init_gl_modern(display_size):
# ------------------------------------------

# Cube Data
vertices = zeros(
8, [("vertex_position", float32, 3), ("vertex_colour", float32, 4)]
)
vertices = zeros(8, [("vertex_position", float32, 3), ("vertex_color", float32, 4)])

vertices["vertex_position"] = [
[1, 1, 1],
Expand All @@ -334,7 +332,7 @@ def init_gl_modern(display_size):
[-1, -1, -1],
]

vertices["vertex_colour"] = [
vertices["vertex_color"] = [
[0, 1, 1, 1],
[0, 0, 1, 1],
[0, 0, 0, 1],
Expand Down Expand Up @@ -409,7 +407,7 @@ def init_gl_modern(display_size):

offset = ctypes.c_void_p(vertices.dtype["vertex_position"].itemsize)

loc = GL.glGetAttribLocation(program, "vertex_colour")
loc = GL.glGetAttribLocation(program, "vertex_color")
GL.glEnableVertexAttribArray(loc)
GL.glVertexAttribPointer(loc, 4, GL.GL_FLOAT, False, stride, offset)

Expand Down Expand Up @@ -443,19 +441,19 @@ def init_gl_modern(display_size):
)
GL.glUniformMatrix4fv(shader_data["constants"]["projection"], 1, False, eye(4))

# This colour is multiplied with the base vertex colour in producing
# This color is multiplied with the base vertex color in producing
# the final output
shader_data["constants"]["colour_mul"] = GL.glGetUniformLocation(
program, "colour_mul"
shader_data["constants"]["color_mul"] = GL.glGetUniformLocation(
program, "color_mul"
)
GL.glUniform4f(shader_data["constants"]["colour_mul"], 1, 1, 1, 1)
GL.glUniform4f(shader_data["constants"]["color_mul"], 1, 1, 1, 1)

# This colour is added on to the base vertex colour in producing
# This color is added on to the base vertex color in producing
# the final output
shader_data["constants"]["colour_add"] = GL.glGetUniformLocation(
program, "colour_add"
shader_data["constants"]["color_add"] = GL.glGetUniformLocation(
program, "color_add"
)
GL.glUniform4f(shader_data["constants"]["colour_add"], 0, 0, 0, 0)
GL.glUniform4f(shader_data["constants"]["color_add"], 0, 0, 0, 0)

# Set GL drawing data
# -------------------
Expand Down Expand Up @@ -490,8 +488,8 @@ def draw_cube_modern(shader_data, filled_cube_indices, outline_cube_indices, rot
GL.glDisable(GL.GL_BLEND)
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glEnable(GL.GL_POLYGON_OFFSET_FILL)
GL.glUniform4f(shader_data["constants"]["colour_mul"], 1, 1, 1, 1)
GL.glUniform4f(shader_data["constants"]["colour_add"], 0, 0, 0, 0.0)
GL.glUniform4f(shader_data["constants"]["color_mul"], 1, 1, 1, 1)
GL.glUniform4f(shader_data["constants"]["color_add"], 0, 0, 0, 0.0)
GL.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, shader_data["buffer"]["filled"])
GL.glDrawElements(
GL.GL_TRIANGLES, len(filled_cube_indices), GL.GL_UNSIGNED_INT, None
Expand All @@ -500,8 +498,8 @@ def draw_cube_modern(shader_data, filled_cube_indices, outline_cube_indices, rot
# Outlined cube
GL.glDisable(GL.GL_POLYGON_OFFSET_FILL)
GL.glEnable(GL.GL_BLEND)
GL.glUniform4f(shader_data["constants"]["colour_mul"], 0, 0, 0, 0.0)
GL.glUniform4f(shader_data["constants"]["colour_add"], 1, 1, 1, 1.0)
GL.glUniform4f(shader_data["constants"]["color_mul"], 0, 0, 0, 0.0)
GL.glUniform4f(shader_data["constants"]["color_add"], 1, 1, 1, 1.0)
GL.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, shader_data["buffer"]["outline"])
GL.glDrawElements(GL.GL_LINES, len(outline_cube_indices), GL.GL_UNSIGNED_INT, None)

Expand Down
4 changes: 2 additions & 2 deletions src_c/_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ rgb_to_hsv(const void *src, void *dst, int length, unsigned long source,
min = MIN(MIN(r, g), b);
delta = max - min;
v = max; /* value (similar to luminosity) */
if (!delta) { /* grey, zero hue and saturation */
if (!delta) { /* gray, zero hue and saturation */
s = 0;
h = 0;
}
Expand Down Expand Up @@ -733,7 +733,7 @@ rgb_to_hsv(const void *src, void *dst, int length, unsigned long source,
min = MIN(MIN(r, g), b);
delta = max - min;
v = max; /* value (similar to luminosity) */
if (!delta) { /* grey, zero hue and saturation */
if (!delta) { /* gray, zero hue and saturation */
s = 0;
h = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src_c/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ rle_line(Uint8 *src, Uint8 *dst, int w, int bpp)
/*
* Save a surface to an output stream in TGA format.
* 8bpp surfaces are saved as indexed images with 24bpp palette, or with
* 32bpp palette if colourkeying is used.
* 32bpp palette if colorkeying is used.
* 15, 16, 24 and 32bpp surfaces are saved as 24bpp RGB images,
* or as 32bpp RGBA images if alpha channel is used.
*
Expand Down Expand Up @@ -1618,7 +1618,7 @@ SaveTGA_RW(SDL_Surface *surface, SDL_RWops *out, int rle)
}
}

/* Temporarily remove colourkey and alpha from surface so copies are
/* Temporarily remove colorkey and alpha from surface so copies are
opaque */
SDL_SetSurfaceAlphaMod(surface, SDL_ALPHA_OPAQUE);
if (have_surf_colorkey)
Expand Down
2 changes: 1 addition & 1 deletion src_c/mask.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ mask_from_surface(PyObject *self, PyObject *args, PyObject *kwargs)
palette_colors - this only affects surfaces with a palette
if true we look at the colors from the palette,
otherwise we threshold the pixel values. This is useful if
the surface is actually greyscale colors, and not palette colors.
the surface is actually grayscale colors, and not palette colors.
*/

Expand Down
6 changes: 3 additions & 3 deletions src_c/simd_blitters_avx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1450,13 +1450,13 @@ blit_blend_premultiplied_avx2(SDL_BlitInfo *info)
*/

/* blend on A half, at 16bit size, starts here.
* overall target blend (with colours and alpha represented
* overall target blend (with colors and alpha represented
* as values between 0 and 1) is:
*
* result = source.RGB + (dest.RGB * (1 - source.A))
*
* Optimised and rearranged for values between 0 and 255
* the blend formula for a single colour channel is:
* the blend formula for a single color channel is:
*
* (sC + dC - ((dC + 1) * sA >> 8))
*/
Expand All @@ -1480,7 +1480,7 @@ blit_blend_premultiplied_avx2(SDL_BlitInfo *info)

mm256_dstA = _mm256_sub_epi16(mm256_src_shuff, mm256_dstA);
/* this is the final subtraction completing the original
* colour channel blend formula. We now have blended
* color channel blend formula. We now have blended
* channel values sitting in the same 16 bit, 00 padded
* arrangement of pixels as we did prior to the blend.
*/
Expand Down
12 changes: 6 additions & 6 deletions src_c/simd_transform_avx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ grayscale_avx2(SDL_Surface *src, SDL_Surface *newsurf)
* for this operation in isolation.
* 4. pack pixels back together from A & B while adding with a
* horizontal add (e.g. adds A+R and G+B in a ARGB layout)
* 5. shift and add to make final grey pixel colour in 0th
* 5. shift and add to make final gray pixel color in 0th
* 8Bit channel in each 'pixel'
* 6. shuffle again to push the grey from the 0th channel into every
* 6. shuffle again to push the gray from the 0th channel into every
* channel of every pixel.
* 7. add the alpha channel back in.
*/
Expand Down Expand Up @@ -147,8 +147,8 @@ grayscale_avx2(SDL_Surface *src, SDL_Surface *newsurf)
// Do the 'percentage multiplications' with the weights
// with accuracy correction so values like 255 * '255'
// (here effectively 1.0) = 255 and not 254.
// For our greyscale this should mean 255 white stays 255 white
// after greyscaling.
// For our grayscale this should mean 255 white stays 255 white
// after grayscaling.
mm256_dstA =
_mm256_mullo_epi16(mm256_srcA, mm256_shuffled_weights_A);
mm256_dstA = _mm256_add_epi16(mm256_dstA, mm256_two_five_fives);
Expand All @@ -160,12 +160,12 @@ grayscale_avx2(SDL_Surface *src, SDL_Surface *newsurf)
mm256_dstB = _mm256_srli_epi16(mm256_dstB, 8);

// Add up weighted R+G+B into the first channel of each of the 8
// pixels. This is the grey value we want in all our colour
// pixels. This is the gray value we want in all our color
// channels.
mm256_dst = _mm256_hadd_epi16(mm256_dstA, mm256_dstB);
mm256_dst =
_mm256_add_epi16(mm256_dst, _mm256_srli_epi32(mm256_dst, 16));
// Shuffle the grey value from ther first channel of each pixel
// Shuffle the gray value from ther first channel of each pixel
// into every channel of each pixel
mm256_dst = _mm256_shuffle_epi8(mm256_dst, mm256_shuff_mask_gray);

Expand Down
6 changes: 3 additions & 3 deletions src_c/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -2477,7 +2477,7 @@ average_surfaces(SDL_Surface **surfaces, size_t num_surfaces,
palette_colors - if true we average the colors in palette, otherwise we
average the pixel values. This is useful if the surface is
actually greyscale colors, and not palette colors.
actually grayscale colors, and not palette colors.
*/

Expand Down Expand Up @@ -2553,7 +2553,7 @@ average_surfaces(SDL_Surface **surfaces, size_t num_surfaces,
PG_FORMAT_BytesPerPixel(destformat) == 1) &&
(format->palette) && (destformat->palette) && (!palette_colors)) {
/*
This is useful if the surface is actually greyscale colors,
This is useful if the surface is actually grayscale colors,
and not palette colors.
*/
for (y = 0; y < height; y++) {
Expand Down Expand Up @@ -2645,7 +2645,7 @@ average_surfaces(SDL_Surface **surfaces, size_t num_surfaces,
palette_colors - if true we average the colors in palette, otherwise we
average the pixel values. This is useful if the surface is
actually greyscale colors, and not palette colors.
actually grayscale colors, and not palette colors.
*/
static PyObject *
Expand Down
6 changes: 3 additions & 3 deletions src_py/surfarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ def map_array(surface, array):
format to control the conversion.
Note: arrays do not need to be 3D, as long as the minor axis has
three elements giving the component colours, any array shape can be
used (for example, a single colour can be mapped, or an array of
colours). The array shape is limited to eleven dimensions maximum,
three elements giving the component colors, any array shape can be
used (for example, a single color can be mapped, or an array of
colors). The array shape is limited to eleven dimensions maximum,
including the three element minor axis.
"""
if array.ndim == 0:
Expand Down
Loading

0 comments on commit e404dbc

Please sign in to comment.