Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
19
Task/Grayscale-image/Sidef/grayscale-image.sidef
Normal file
19
Task/Grayscale-image/Sidef/grayscale-image.sidef
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
require('Image::Imlib2')
|
||||
|
||||
func tograyscale(img) {
|
||||
var (width, height) = (img.width, img.height)
|
||||
var gimg = %s'Image::Imlib2'.new(width, height)
|
||||
for y,x in (^height ~X ^width) {
|
||||
var (r, g, b) = img.query_pixel(x, y)
|
||||
var gray = int(0.2126*r + 0.7152*g + 0.0722*b)
|
||||
gimg.set_color(gray, gray, gray, 255)
|
||||
gimg.draw_point(x, y)
|
||||
}
|
||||
return gimg
|
||||
}
|
||||
|
||||
var (input='input.png', output='output.png') = ARGV...
|
||||
var image = %s'Image::Imlib2'.load(input)
|
||||
var gscale = tograyscale(image)
|
||||
gscale.set_quality(80)
|
||||
gscale.save(output)
|
||||
Loading…
Add table
Add a link
Reference in a new issue