This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c LightestOperation) Result(images []containers.ImageContainer) (image.Image, error) { | |
if len(images) == 0 { | |
return nil, nil | |
} else if len(images) == 1 { | |
return images[0].GetImage(), nil | |
} | |
firstImage := images[0].GetImage() | |
bounds := firstImage.Bounds() | |
lightest := image.NewRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ImageContainer interface { | |
GetImage() image.Image | |
} | |
type FileImageContainer struct { | |
Filename string | |
} | |
func (f FileImageContainer) GetImage() image.Image { | |
file, _ := os.Open(f.filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c LightestOperation) Result(images []image.Image) (image.Image, error) { | |
firstImage := images[0] | |
bounds := firstImage.Bounds() | |
lightest := image.NewRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy())) | |
draw.Draw(lightest, bounds, firstImage, bounds.Min, draw.Src) | |
for _, currentImage := range images { | |
if currentImage.Bounds() != bounds { | |
return nil, errors.New("The images have different size!") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c LightestOperation) lightest(color1, color2 color.RGBA) color.Color { | |
if c.luminance(color1) > c.luminance(color2) { | |
return color1 | |
} else { | |
return color2 | |
} | |
} | |
func (c LightestOperation) luminance(someColor color.Color) uint32 { | |
r, g, b, _ := someColor.RGBA() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"bold_folder_labels": true, | |
"fade_fold_buttons": false, | |
"font_face": "Fira Mono", | |
"font_size": 12, | |
"highlight_line": true, | |
"highlight_modified_tabs": true, | |
"ignored_packages": | |
[ | |
"Vintage" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
datetime=`date +%Y-%m-%d\ %H:%M:%S` | |
my_ip=`curl -s ifconfig.me` | |
exit_code=$? | |
if [ $exit_code == 0 ]; then | |
echo $datetime [ONLINE] $my_ip | |
else | |
echo $datetime [OFFLINE] Exit code: $exit_code |