Advertisement
Guest User

skyline0489.py

a guest
Jan 3rd, 2024
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.34 KB | None | 0 0
  1. import colorsys
  2. import math
  3. from PIL import Image, ImageDraw, ImageFont
  4.  
  5. buildings = [
  6.     (( 455, 750), "Large Crane"),
  7.     (( 525, 795), "Small Crane"),
  8.     (( 665, 655), "Two Tequesta Point"),
  9.     (( 765, 720), "The Palace Condominium (?)"),
  10.     (( 835, 610), "Three Tequesta Point"),
  11.     (( 920, 700), "???"),
  12.     (( 960, 630), "Echo Brickell (?)"),
  13.     ((1085, 590), "Four Seasons"),
  14.     ((1115, 700), "Fortune House Hotel"),
  15.     ((1170, 640), "???"),
  16.     ((1180, 820), "Terminal F"),
  17.     ((1235, 635), "???"),
  18.     ((1360, 630), "Citigroup Center"),
  19.     ((1415, 685), "???"),
  20.     ((1475, 670), "???"),
  21.     ((1510, 630), "Met 1"),
  22.     ((1545, 565), "Southeast Financial Center"),
  23.     ((1620, 670), "???"),
  24.     ((1650, 640), "Wells Fargo Center"),
  25.     ((1930, 695), "Flagler on the River"),
  26.     ((1972, 745), "FAA Miami ATCT (MIA)"),
  27.     ((2050, 695), "The Loft 2"),
  28.     ((2080, 710), "Miami-Dade County Courthouse"),
  29.     ((2145, 635), "Vizcayne Towers"),
  30.     ((2195, 670), "Stephen P. Clark Government Center"),
  31.     ((2285, 750), "???"),
  32.     ((2430, 635), "Marina Blue"),
  33.     ((2515, 675), "Ten Museum Park"),
  34.     ((2600, 625), "Marquis Miami"),
  35.     ((2930, 650), "Marriott Miami Biscayne Bay"),
  36.     ((2980, 590), "Opera Tower"),
  37.     ((3035, 685), "Bay Parc Apartments"),
  38.     ((3085, 610), "The Grand"),
  39.     ((3180, 755), "LoanDepot Park"),
  40.     ((3250, 630), "1800 Club"),
  41.     ((3340, 575), "Quantum on the Bay Condominium"),
  42.     ((3345, 755), "1000 Venetian Way"),
  43.     ((3460, 795), "Venetian Isle Condominium"),
  44.     ((3490, 725), "???"),
  45.     ((3570, 755), "22 Skyview Apartments (?)"),
  46.     ((3625, 790), "Uptown Lofts"),
  47.     ((3705, 745), "22 Biscayne Bay"),
  48.     ((3790, 730), "New Wave Condominiums"),
  49. ]
  50.  
  51. font_size = 16
  52. font = ImageFont.truetype("Menlo-Regular.ttf", font_size)
  53.  
  54. def draw_marker(xy, height, name, rgb):
  55.     x, y = xy
  56.     draw.line((x, y, x, y - height), fill=rgb)
  57.     w, h = get_textsize(name, font)
  58.     tx = min(max(x - w/2, 4), 3840 - 4 - w)
  59.     ty = y - height - 4 - font_size
  60.     draw.text((tx, ty), name, fill=rgb, font=font)
  61.  
  62. def get_textsize(text, font):
  63.     l, t, r, b = draw.textbbox((0, 0), text, font=font)
  64.     return r - l, b - t
  65.  
  66. def hue_to_rgb(hue):
  67.     rgb = colorsys.hsv_to_rgb(hue / 360, 1, 0.75)
  68.     return tuple([int(x * 255) for x in rgb])
  69.  
  70. image = Image.open("skyline0489.png")
  71. draw = ImageDraw.Draw(image)
  72. for i, (xy, name) in enumerate(buildings):
  73.     height = 32 if name in (
  74.         "The Loft 2"
  75.     ) else 96 if name in (
  76.         "Miami-Dade County Courthouse", "Vizcayne Towers",
  77.         "Stephen P. Clark Government Center", "22 Biscayne Bay"
  78.     ) else 128 if name in (
  79.     ) else 192 if name in (
  80.         "Bay Parc Apartments", "Venetian Isle Condominium"
  81.     ) else 64
  82.     rgb = hue_to_rgb(i / len(buildings) * 360)
  83.     draw_marker(xy, height, name, rgb)
  84. image.save("skyline0489annotated.png")
  85.  
  86.  
  87. image = Image.open("../gtaforums/GTAMappingv0.034.png")
  88. draw = ImageDraw.Draw(image)
  89. scale = 556/1000
  90. src_x, src_y = (5455, 3480)
  91. fov = 54.1
  92. yaw = 198
  93. for i, ((x, y), name) in enumerate(buildings):
  94.     rgb = hue_to_rgb(i / len(buildings) * 360)
  95.     distance = 6000 if name in (
  96.         "FAA Miami ATCT (MIA)"
  97.     ) or (
  98.         name == "???" and buildings[i - 1][1] == "Stephen P. Clark Government Center"
  99.     ) else 2500 if name in (
  100.         "Large Crane", "Small Crane", "Terminal F"
  101.     ) else 2100 if name in (
  102.         "1000 Venetian Way", "Venetian Isle Condominium"
  103.     ) else 4000
  104.     angle = yaw - fov / 2 + (3840 - x) / 3840 * fov
  105.     print(f"{angle:.1f} {name}")
  106.     dst_x = src_x + math.cos(math.radians(angle)) * distance * scale
  107.     dst_y = src_y - math.sin(math.radians(angle)) * distance * scale
  108.     draw.line((src_x, src_y, dst_x, dst_y), fill=rgb)
  109.     w, h = get_textsize(name, font)
  110.     draw.rectangle((
  111.         dst_x - w - 8, dst_y - font_size / 2 - 2,
  112.         dst_x, dst_y + font_size / 2 + 2
  113.     ), fill=(255, 255, 255), outline=rgb)
  114.     draw.text((dst_x - 4 - w, dst_y - font_size / 2 - 2), name, fill=rgb, font=font)
  115. src_x, src_y = 4095, 5052
  116. fov = 45
  117. yaw = 155
  118. rgb = (0, 255, 0)
  119. for i, angle in enumerate((yaw - fov / 2, yaw + fov / 2)):
  120.     distance = [3000, 4000][i]
  121.     dst_x = src_x + math.cos(math.radians(angle)) * distance * scale
  122.     dst_y = src_y - math.sin(math.radians(angle)) * distance * scale
  123.     draw.line((src_x, src_y, dst_x, dst_y), fill=rgb)
  124. image = image.crop((1800, 2900, 5800, 5900))
  125. draw = ImageDraw.Draw(image)
  126.  
  127. rgb = 255, 255, 255
  128. for src, dst in (
  129.     ((2510, 485), (2510, 505)),   # Venetian Isle Condominium
  130.     ((2645, 525), (2645, 545)),   # 1000 Venetian
  131.     ((2200, 570), (2200, 620)),   # The Grand
  132.     ((2185, 705), (2200, 675)),   # Marriott Miami
  133.     ((2015, 835), (2105, 810)),   # Marquis Miami
  134.     ((2015, 870), (2105, 842)),   # Ten Museum Park
  135.     ((2015, 905), (2105, 875)),   # Marina Blue
  136.     (None, (2105, 990)),          # Vizcayne Towers
  137.     ((1715, 2040), (1800, 1640)), # Four Seasons
  138.     ((1635, 1970), (1805, 1620)), # Fortune House
  139.     ((1825, 1205), (1985, 1000)), # SPC Government Center
  140.     ((2355, 1525), (2275, 1485)), # Tequesta
  141.     ((2355, 1570), (2275, 1570)), # Tequesta
  142.     ((215, 2645), (215, 1955)),   # Prison Shot
  143. ):
  144.     if src:
  145.         draw.line((src, dst), fill=rgb)
  146.     x, y = dst
  147.     draw.rectangle((x- 5, y - 5, x + 5, y + 5), fill=rgb)
  148.  
  149. image.save("skyline0489map.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement