Add formatter to remove decimals on points

Let's call it the flooring function
This commit is contained in:
Hans5958 2022-05-17 19:56:46 +07:00
parent 904100fc45
commit 57060905de
2 changed files with 22 additions and 2 deletions

View file

@ -325,6 +325,24 @@ def extend_entries_to_whiteout(entry: dict):
return entry
def floor_points(entry: dict):
"""
Floors points on path and center, removing the decimal count.
"""
for period in entry["path"]:
for points in entry["path"][period]:
points[0] = math.floor(points[0])
points[1] = math.floor(points[1])
for period in entry["center"]:
points = entry["center"][period]
points[0] = math.floor(points[0])
points[1] = math.floor(points[1])
return entry
def validate(entry: dict):
"""
Validates the entry. Catch errors and tell warnings related to the entry.
@ -410,6 +428,8 @@ def print_(*args, **kwargs):
entry = sort_image_keys(entry)
print_("Extending entries to whiteout...")
entry = extend_entries_to_whiteout(entry)
print_("Flooring points...")
entry = floor_points(entry)
# This is the slow part. Use it when necessary by uncommenting.
# print_("Updating center...")

View file

@ -1187,7 +1187,7 @@
{"id": "twpyua", "name": "Map of Iran", "description": "The map of Iran with a heart in the middle of it", "links": {}, "path": {"1-166, T": [[86, 277], [90, 282], [97, 283], [99, 287], [99, 293], [101, 296], [101, 299], [102, 302], [100, 307], [91, 307], [90, 305], [89, 305], [88, 306], [81, 306], [78, 300], [77, 295], [75, 291], [74, 290], [74, 285], [72, 280], [74, 280], [77, 281], [80, 279], [83, 279], [83, 277]]}, "center": {"1-166, T": [88, 293]}},
{"id": "twpyr8", "name": "Ambiorix statue", "description": "The Gallian chief of the Belgian tribe who resisted against Julius Ceasar's invasion in his conquest of Gaul. This statue located in Tongeren is dedicated to this national hero.", "links": {"website": ["https://en.wikipedia.org/wiki/Ambiorix"], "subreddit": ["belgium", "Belgium2", "BELGICA", "placeBE"]}, "path": {"109-166, T": [[1303, 1603], [1288, 1643], [1292, 1669], [1309, 1672], [1320, 1663], [1330, 1628], [1312, 1596]]}, "center": {"109-166, T": [1308, 1638]}},
{"id": "twpyl6", "name": "De Sterrennacht (The Starry Night)", "description": "The Starry Night is an oil-on-canvas painting by the Dutch Post-Impressionist painter Vincent van Gogh. Painted in June 1889, it depicts the view from the east-facing window of his asylum room at Saint-Rémy-de-Provence, just before sunrise, with the addition of an imaginary village.", "links": {"website": ["https://en.wikipedia.org/wiki/The_Starry_Night"], "subreddit": ["PlaceNL"]}, "path": {"56-166, T": [[1449, 1], [1449, 35], [1516, 35], [1516, 1]]}, "center": {"56-166, T": [1483, 18]}},
{"id": "twpyje", "name": "Flag of Germany", "description": "The flag of Germany was build after the second expanision. There were some griefs but the Germans defended it.", "links": {"subreddit": ["placeDE"], "discord": ["placede"]}, "path": {"109-166, T": [[0, 1121], [448, 1121], [447, 1128], [510, 1130], [551, 1131], [551, 1101], [553, 1100], [553, 1126], [556, 1131], [566, 1130], [570, 1124], [578, 1130], [585, 1128], [590, 1124], [593, 1128], [644, 1129], [644, 1134], [657, 1134], [670, 1124], [686, 1125], [688, 1134], [687, 1124], [805, 1122], [1000, 1122], [1006, 1132], [1016, 1133], [1029, 1132], [1041, 1130], [1043, 1122], [1065, 1123], [1197, 1122], [1309, 1124], [1365, 1125], [1524, 1126], [1525, 1129], [1544, 1128], [1646, 1126], [1707, 1128], [1726, 1129], [1751, 1132], [1764, 1129], [1767, 1122], [1792, 1122], [1999, 1120], [2000, 1172], [-0, 1172]]}, "center": {"109-166, T": [992, 1148]}},
{"id": "twpyje", "name": "Flag of Germany", "description": "The flag of Germany was build after the second expanision. There were some griefs but the Germans defended it.", "links": {"subreddit": ["placeDE"], "discord": ["placede"]}, "path": {"109-166, T": [[0, 1121], [448, 1121], [447, 1128], [510, 1130], [551, 1131], [551, 1101], [553, 1100], [553, 1126], [556, 1131], [566, 1130], [570, 1124], [578, 1130], [585, 1128], [590, 1124], [593, 1128], [644, 1129], [644, 1134], [657, 1134], [670, 1124], [686, 1125], [688, 1134], [687, 1124], [805, 1122], [1000, 1122], [1006, 1132], [1016, 1133], [1029, 1132], [1041, 1130], [1043, 1122], [1065, 1123], [1197, 1122], [1309, 1124], [1365, 1125], [1524, 1126], [1525, 1129], [1544, 1128], [1646, 1126], [1707, 1128], [1726, 1129], [1751, 1132], [1764, 1129], [1767, 1122], [1792, 1122], [1999, 1120], [2000, 1172], [0, 1172]]}, "center": {"109-166, T": [992, 1148]}},
{"id": "twpycp", "name": "Calamity Box", "description": "The Calamity Box from Amphibia is a grey chest with gold linings and has pink, green, and blue gemstones within. It also has a gold insignia, as well as a wind-up toy handle on its right side.", "links": {"website": ["https://amphibia.fandom.com"], "subreddit": ["Amphibia"]}, "path": {"109-166, T": [[445, 1399], [446, 1419], [472, 1420], [473, 1417], [475, 1416], [475, 1411], [472, 1411], [472, 1404], [471, 1401], [469, 1399]]}, "center": {"109-166, T": [459, 1409]}},
{"id": "twpy8z", "name": "Knockout City", "description": "A simple representation for the game showing K O City from multiple community members!", "links": {"subreddit": ["KnockoutCity"]}, "path": {"56-166, T": [[1826, 658], [1842, 658], [1842, 666], [1832, 666], [1832, 664], [1826, 664]]}, "center": {"56-166, T": [1835, 662]}},
{"id": "twpy7q", "name": "Ancient Persian griffin column", "description": "Example of columns developed in the Achaemenid architecture of ancient Persia", "links": {}, "path": {"1-166, T": [[56, 283], [51, 283], [44, 291], [40, 287], [35, 284], [32, 285], [31, 290], [34, 291], [37, 296], [31, 297], [31, 299], [37, 300], [40, 304], [40, 362], [37, 364], [37, 368], [51, 369], [51, 364], [47, 362], [48, 303], [51, 300], [57, 299], [57, 297], [51, 297], [54, 291], [57, 291], [56, 287]]}, "center": {"1-166, T": [44, 320]}},
@ -4172,7 +4172,7 @@
{"id": "tx875t", "name": "pepeD", "description": "PepeD is an animated BetterTTV extension Twitch emote of pixel art animation of Pepe the Frog dancing by turning left and right and raising and lowering his left and right arms. After the emoji was enabled by a number of popular streamers, it became a popular way of expressing approval of the music which is being played, or expressing joy.", "links": {}, "path": {"109-166, T": [[1773, 1604], [1773, 1597], [1786, 1597], [1786, 1604]]}, "center": {"109-166, T": [1780, 1601]}},
{"id": "tx8707", "name": "Borb", "description": "The fourth and final location of Borb, a character from Painting With Borb, a show by Animator and Streamer Tomthinks", "links": {"website": ["https://www.twitch.tv/tomthinks"], "subreddit": ["place_borbpaints"]}, "path": {"109-166, T": [[1285, 1201], [1285, 1219], [1274, 1219], [1274, 1215], [1273, 1215], [1272, 1214], [1272, 1211], [1270, 1211], [1270, 1210], [1269, 1210], [1269, 1209], [1264, 1209], [1263, 1209], [1262, 1211], [1262, 1201]]}, "center": {"109-166, T": [1276, 1209]}},
{"id": "tx86qc", "name": "Los Carry (LC)", "description": "A group of friends from Portugal :)", "links": {}, "path": {"109-166, T": [[1974, 1250], [1974, 1256], [1968, 1256], [1968, 1250], [1974, 1250], [1968, 1250], [1968, 1256], [1974, 1256], [1974, 1250], [1974, 1256], [1968, 1256], [1968, 1250]]}, "center": {"109-166, T": [1971, 1253]}},
{"id": "tx86fp", "name": "Flag of Ukraine", "description": "The flag of Ukraine, covered in Ukranian art such as President Zelenskyy, the Tryzub, St. Sophia's Cathedral, and more.\n\nIn the first few hours of r/place, the internet worked together without coordination to create a Ukrainian flag that spanned the entire of the original canvas, a show of solidarity with Ukraine in the Russo-Ukrainian War. Originally, the flag didn't have any art on it, which drew criticism from smaller creators who were having their works erased.\n\nr/placeukraine was unable to get control of the flag until it was reduced in size, at which point they were able to inscribe the subreddit's name along with muralizing the flag with various Ukrainian cultural icons and tributes promoting peace.", "links": {"website": ["https://en.wikipedia.org/wiki/Ukraine"], "subreddit": ["placeukraine"]}, "path": {"1-166, T": [[-0, 177], [27, 177], [27, 169], [221, 169], [221, 171], [433, 171], [433, 252], [-0, 252]]}, "center": {"1-166, T": [216, 211]}},
{"id": "tx86fp", "name": "Flag of Ukraine", "description": "The flag of Ukraine, covered in Ukranian art such as President Zelenskyy, the Tryzub, St. Sophia's Cathedral, and more.\n\nIn the first few hours of r/place, the internet worked together without coordination to create a Ukrainian flag that spanned the entire of the original canvas, a show of solidarity with Ukraine in the Russo-Ukrainian War. Originally, the flag didn't have any art on it, which drew criticism from smaller creators who were having their works erased.\n\nr/placeukraine was unable to get control of the flag until it was reduced in size, at which point they were able to inscribe the subreddit's name along with muralizing the flag with various Ukrainian cultural icons and tributes promoting peace.", "links": {"website": ["https://en.wikipedia.org/wiki/Ukraine"], "subreddit": ["placeukraine"]}, "path": {"1-166, T": [[0, 177], [27, 177], [27, 169], [221, 169], [221, 171], [433, 171], [433, 252], [0, 252]]}, "center": {"1-166, T": [216, 211]}},
{"id": "tx86e2", "name": "Red Vox", "description": "This is a band from New York City that was founded by Vinny from Vinesauce, Mike, Joe, and Bill. Both Vinny and Mike have a spot on the mural.", "links": {"website": ["https://www.redvoxband.com/"], "subreddit": ["Redvox", "Vinesauce"]}, "path": {"109-166, T": [[95, 1109], [99, 1110], [100, 1109], [99, 1108], [106, 1108], [107, 1106], [108, 1105], [108, 1103], [107, 1102], [107, 1100], [106, 1100], [106, 1099], [104, 1098], [102, 1097], [99, 1097], [98, 1098], [97, 1098], [96, 1099], [95, 1099], [94, 1101], [94, 1102], [93, 1103], [93, 1105], [95, 1110]]}, "center": {"109-166, T": [100, 1103]}},
{"id": "tx86d4", "name": "Flag of Wales", "description": "Y Ddraig Goch (The Red Dragon) is the national flag of Wales, United Kingdom.", "links": {"website": ["https://en.wikipedia.org/wiki/Wales"], "subreddit": ["ukplace"]}, "path": {"1-166, T": [[608, 556], [608, 552], [614, 552], [614, 556]]}, "center": {"1-166, T": [611, 554]}},
{"id": "tx86ad", "name": "Chuck", "description": "Chuck is the partial owner of Sneed's Feed and Seed. After selling the store to Chuck, he mostly hangs out with Chuck on the porch.", "links": {"subreddit": ["sneedposting"]}, "path": {"56-166, T": [[1764, 893], [1756, 893], [1756, 890], [1755, 890], [1754, 891], [1753, 891], [1753, 890], [1753, 889], [1753, 888], [1752, 887], [1752, 881], [1751, 881], [1750, 880], [1749, 880], [1749, 877], [1750, 876], [1751, 875], [1752, 874], [1753, 874], [1754, 873], [1759, 873], [1760, 874], [1761, 875], [1763, 876], [1765, 876], [1765, 877], [1764, 878], [1762, 878], [1761, 879], [1761, 880], [1762, 880], [1762, 882], [1763, 882], [1764, 885], [1764, 886], [1763, 886], [1763, 888], [1764, 888], [1763, 890], [1762, 891], [1763, 892], [1764, 892]]}, "center": {"56-166, T": [1757, 883]}},