Решение Фортрана.
Из домашнего каталога Linux создайте подкаталог /mygamma/
Каталог mygamma содержит шесть файлов: 2 сценария программы Фортран: contrastdown.f90
and contrastup.f90
, их исполняемые файлы gammadown
и gammaup
, и файл shebang, xgammasave
который сохраняет текущее значение xgamma в текстовый файл.xgammaval.txt
Файл xgammasave выглядит так:
#!/bin/bash xgamma |& tee ~/mygamma/xgammaval.txt
contrastup.f90
Файл выглядит следующим образом :
program contrastup character(len=20):: string,string2,string3 ! variable type declarations real(kind(1.0)) :: x call system('/home/my_name/mygamma/xgammasave') ! write the xgamma value to a file open(unit=2,file='/home/my_name/mygamma/xgammaval.txt',action='read',status='old') read(unit=2,fmt=*)string,string2,string3 ! read the file read(string3,*)x ! make a real from a string x=x/1.2 ! change the contrast if (x .le. 0.1) goto 10 ! xgamma value can not be less than 0.1 write(string,*)x ! make a string from a real string2='xgamma -gamma ' // trim(string) ! concatenate 2 strings call system(string2) ! pass the string to the command line 10 close(unit=2) end program contrastup
а также contrastdown.f90
program contrastdown character(len=20):: string,string2,string3 ! variable type declarations real(kind(1.0)) :: x call system('/home/my_name/mygamma/xgammasave') ! write xgamma value to a file open(unit=2,file='/home/my_name/mygamma/xgammaval.txt',action='read',status='old') read(unit=2,fmt=*)string,string2,string3 ! read the record read(string3,*)x ! make a real from a string x=x*1.2 ! change the contrast if (x .ge. 10.0) goto 10 ! xgamma value can not be greater than 10.0 write(string,*)x ! make a string from a real string2='xgamma -gamma ' // trim(string) ! concatenate two strings call system(string2) ! pass the string to the command line 10 close(unit=2) end program contrastdown
Создайте исполняемые файлы Фортрана gammaup
и gammadown
:
~/mygamma $ gfortran contrastup.f90 -o gammaup ~/mygamma $ gfortran contrastdown.f90 -o gammadown
В зависимости от разновидности Linux, в Центре управления> Сочетания клавиш, в разделе «Пользовательские сочетания клавиш» выберите «Добавить», в поле имени введите имя сочетания клавиш «Повышение гаммы», а в командной строке введите /home/my_name/mygamma/gammaup
и аналогично «Низкий контраст». ключ с командой/home/my_name/mygamma/gammadown
На моем ноутбуке FnF6и FnF5по умолчанию находятся клавиши яркости вверх / вниз, теперь над ними вновь определены ShiftF6и ShiftF5клавиши контрастности вверх / вниз. Винтажные черно-белые фильмы теперь красиво смотрятся на глянцевом экране :)
Может ли решение Fortran быть Code Golf
меньше строк.