Warning, /games/libkmahjongg/tilesets/CompareTilesetsSVGs.cmake is written in an unsupported language. File is not indexed.
0001 # SPDX-FileCopyrightText: 2023 Friedrich W. H. Kossebau <kossebau@kde.org> 0002 # 0003 # SPDX-License-Identifier: BSD-3-Clause 0004 0005 set(id ${ID}) 0006 set(render_tool ${RENDERELEMENT}) 0007 set(rcompare_tool ${COMPARE}) 0008 set(old_file ${OLD_FILE}) 0009 set(new_file ${NEW_FILE}) 0010 set(work_dir "${WORKING_DIR}/${id}/check") 0011 0012 if (NOT EXISTS "${old_file}") 0013 message(FATAL_ERROR "Old file ${old_file} does not exist") 0014 endif() 0015 if (NOT EXISTS "${new_file}") 0016 message(FATAL_ERROR "New file ${new_file} does not exist") 0017 endif() 0018 0019 # generate list of card element ids 0020 set(tile_ids) 0021 0022 # Unselected tiles 0023 foreach(i RANGE 1 4) 0024 list(APPEND tile_ids "TILE_${i}") 0025 endforeach() 0026 0027 # Selected tiles 0028 foreach(i RANGE 1 4) 0029 list(APPEND tile_ids "TILE_${i}_SEL") 0030 endforeach() 0031 0032 # now faces 0033 foreach(i RANGE 1 9) 0034 list(APPEND tile_ids "CHARACTER_${i}") 0035 endforeach() 0036 foreach(i RANGE 1 9) 0037 list(APPEND tile_ids "BAMBOO_${i}") 0038 endforeach() 0039 foreach(i RANGE 1 9) 0040 list(APPEND tile_ids "ROD_${i}") 0041 endforeach() 0042 foreach(i RANGE 1 4) 0043 list(APPEND tile_ids "SEASON_${i}") 0044 endforeach() 0045 foreach(i RANGE 1 4) 0046 list(APPEND tile_ids "WIND_${i}") 0047 endforeach() 0048 foreach(i RANGE 1 3) 0049 list(APPEND tile_ids "DRAGON_${i}") 0050 endforeach() 0051 foreach(i RANGE 1 4) 0052 list(APPEND tile_ids "FLOWER_${i}") 0053 endforeach() 0054 0055 # ensure working dir 0056 make_directory(${work_dir}) 0057 0058 # compare rendering for each card type 0059 foreach(t ${tile_ids}) 0060 # generate PNG for original 0061 set(old_png_file "${t}_old.png") 0062 execute_process( 0063 COMMAND ${render_tool} ${old_file} ${t} 200 200 ${old_png_file} 0064 WORKING_DIRECTORY ${work_dir} 0065 ) 0066 # generate PNG for modified 0067 set(new_png_file "${t}_new.png") 0068 execute_process( 0069 COMMAND ${render_tool} ${new_file} ${t} 200 200 ${new_png_file} 0070 WORKING_DIRECTORY ${work_dir} 0071 ) 0072 0073 # compare 0074 execute_process( 0075 COMMAND ${rcompare_tool} 0076 -metric MAE 0077 ${old_png_file} 0078 ${new_png_file} 0079 /dev/null # no use for difference image 0080 WORKING_DIRECTORY ${work_dir} 0081 OUTPUT_VARIABLE compare_output 0082 ERROR_VARIABLE compare_output 0083 ) 0084 string(REGEX MATCH "^[0-9]*(\\.[0-9]*)?" compare_result "${compare_output}") 0085 if("${compare_result}" STRGREATER 0) 0086 message(STATUS "Difference for ${id}, element ${t}: ${compare_result}") 0087 endif() 0088 endforeach()