Grayscale image: Difference between revisions

Content added Content deleted
m (Fix Perl 6 -> Raku links)
No edit summary
Line 292: Line 292:


</lang>
</lang>

=={{header|Crystal}}==
{{trans||Ruby}}
Extending [[Basic_bitmap_storage#Crystal]]
<lang ruby>class RGBColour
def to_grayscale
luminosity = (0.2126*@red + 0.7152*@green + 0.0722*@blue).to_i
self.class.new(luminosity, luminosity, luminosity)
end
end

class Pixmap
def to_grayscale
gray = self.class.new(@width, @height)
@width.times do |x|
@height.times do |y|
gray[x,y] = self[x,y].to_grayscale
end
end
gray
end
end</lang>


=={{header|D}}==
=={{header|D}}==