There are two common ways.
- Without a shader. Split a sprite to the two parts. First of them will contain elements which must be drawed "as is", without changes (won't be colorized). And second part will contain elements which must be colorized (the elements must be white/grayscale).
In your example first part will contain green and black elements and second part will contain fuchsia element (but it must be white)
Drawing will be like this:
var color = c_fuchsia;
draw_sprite_ext(sprite_index, 0, x, y, image_xscale, image_yscale, image_angle, c_white, 1);
draw_sprite_ext(sprite_index, 1, x, y, image_xscale, image_yscale, image_angle, color, 1);
- Using simple shader.
Pass new color to your shader. Shader must check the color of the drawing pixel and change it to new color, if need.
If you have no experience with shaders, then see Demos -> Advanced -> Simple Shader Examples
(Shader Demo 5, Simple Colour Swapping) in GMS. But instead comparsion like this:
if ((col.r == 1.0) && (col.g == 0.0) && (col.b == 1.0))
use something like this:
if ((col.r > 0.99) && (col.g < 0.01) && (col.b > 0.99))
Shaders provide many ways and abilities (just one color, skins, palettes, etc).
P.S. Also you may use one of shaders from Marketplace: Retro Palette Swapper, Palette Based Drawing (but both are paid)