def highlight_calibration_color1color2(img, c, draw): draw.rectangle( screenPercToPixels(img.width, img.height, c["calibration.pct.color1"]), fill=orange, ) draw.rectangle( screenPercToPixels(img.width, img.height, c["calibration.pct.color2"]), fill=orange, )
def highlight_calibration_das(img, c, draw): for rect in splitRect(c["calibration.pct.das.current_piece_das"], 2): draw.rectangle(screenPercToPixels(img.width, img.height, rect), fill=green) for rect in splitRect(c["calibration.pct.das.instant_das"], 2): draw.rectangle(screenPercToPixels(img.width, img.height, rect), fill=red) draw.rectangle( screenPercToPixels( img.width, img.height, c["calibration.pct.das.current_piece"] ), fill=blue, )
def highlight_calibration_preview(img, c, draw): draw.rectangle( screenPercToPixels(img.width, img.height, c["calibration.pct.preview"]), fill=blue, ) pixelWidth = c["calibration.pct.preview"][2] / 31.0 pixelHeight = c["calibration.pct.preview"][3] / 15.0 blockWidth = pixelWidth * 7 blockHeight = pixelHeight * 7 t1 = ( c["calibration.pct.preview"][0] + 4 * pixelWidth, c["calibration.pct.preview"][1], blockWidth, blockHeight, ) t2 = ( c["calibration.pct.preview"][0] + 12 * pixelWidth, c["calibration.pct.preview"][1], blockWidth, blockHeight, ) t3 = ( c["calibration.pct.preview"][0] + 20 * pixelWidth, c["calibration.pct.preview"][1], blockWidth, blockHeight, ) t4 = ( c["calibration.pct.preview"][0] + 12 * pixelWidth, c["calibration.pct.preview"][1] + pixelHeight * 8, blockWidth, blockHeight, ) for rect in [t1, t2, t3, t4]: draw.rectangle(screenPercToPixels(img.width, img.height, rect), fill=orange) for o in calculateOffsets(): rect = (o[0], o[1], pixelWidth, pixelHeight) draw.rectangle(screenPercToPixels(img.width, img.height, rect), fill="red")
def highlight_calibration_field(img, c, draw): fieldPerc = c["calibration.pct.field"] for x in range(10): for y in range(20): blockPercX = lerp(fieldPerc[0], fieldPerc[0] + fieldPerc[2], x / 10.0 + 1 / 20.0) blockPercY = lerp(fieldPerc[1], fieldPerc[1] + fieldPerc[3], y / 20.0 + 1 / 40.0) rect = (blockPercX - 0.01, blockPercY - 0.01, 0.02, 0.02) draw.rectangle(screenPercToPixels(img.width, img.height, rect), fill=red)
def highlight_calibration_blackwhite(img, c, draw): draw.rectangle( screenPercToPixels(img.width, img.height, c["calibration.pct.black_n_white"]), fill=orange, )
def highlight_calibration(img, c): poly = Image.new("RGBA", (img.width, img.height)) draw = ImageDraw.Draw(poly) scorePerc, linesPerc, levelPerc = ( c["calibration.pct.score"], c["calibration.pct.lines"], c["calibration.pct.level"], ) for rect in splitRect(linesPerc, 3): # lines draw.rectangle(screenPercToPixels(img.width, img.height, rect), fill=red) for rect in splitRect(scorePerc, 6): # score draw.rectangle(screenPercToPixels(img.width, img.height, rect), fill=green) for rect in splitRect(levelPerc, 2): draw.rectangle(screenPercToPixels(img.width, img.height, rect), fill=blue) # level if c["calibration.dynamic_black_n_white"]: highlight_calibration_blackwhite(img, c, draw) if c["calibration.capture_field"]: highlight_calibration_field(img, c, draw) if c["calibration.dynamic_colors"]: highlight_calibration_color1color2(img, c, draw) if c["stats.enabled"]: if c["stats.capture_method"] == "TEXT": # pieces for value in generate_stats( c["calibration.game_coords"], c["calibration.pct.stats"], c["calibration.pct.score"][3], False, ).values(): draw.rectangle(screenPercToPixels(img.width, img.height, value), fill=orange) else: # c["stats.capture_method"] == "FIELD": stats2_percentages = c.stats2_percentages for x in range(4): for y in range(2): blockPercX = lerp( stats2_percentages[0], stats2_percentages[0] + stats2_percentages[2], x / 4.0 + 1 / 8.0, ) blockPercY = lerp( stats2_percentages[1], stats2_percentages[1] + stats2_percentages[3], y / 2.0 + 1 / 4.0, ) rect = (blockPercX - 0.01, blockPercY - 0.01, 0.02, 0.02) draw.rectangle(screenPercToPixels(img.width, img.height, rect), fill=blue) if c["calibration.capture_preview"]: highlight_calibration_preview(img, c, draw) if c["calibration.flash_method"] == "BACKGROUND": draw.rectangle( screenPercToPixels(img.width, img.height, c["calibration.pct.flash"]), fill=yellow, ) if c["calibration.capture_das"]: highlight_calibration_das(img, c, draw) img.paste(poly, mask=poly) del draw