simulated_resolution = v2(1920, 1080) function coords_to_screenwriter(coord1, coord2) local x_left, x_right, y_top, y_bottom, width, height x_left = math.min(coord1.x, coord2.x) x_right = math.max(coord1.x, coord2.x) y_top = math.min(coord1.y, coord2.y) y_bottom = math.max(coord1.y, coord2.y) width = x_right - x_left height = y_bottom - y_top return coords_partial_to_screenwriter(v2(x_left, x_top), v2(width, height), 1) end function coords_partial_to_screenwriter(pos_px, scale_px, anchor) local x_px, y_px, x, y, width, height if anchor == 1 then --top left x_px = pos_px.x + scale_px.x / 2 y_px = pos_px.y - scale_px.y / 2 elseif anchor == 2 then --top right x_px = pos_px.x - scale_px.x / 2 y_px = pos_px.y - scale_px.y / 2 elseif anchor == 3 then --bottom right x_px = pos_px.x - scale_px.x / 2 y_px = pos_px.y + scale_px.y / 2 elseif anchor == 4 then --bottom left x_px = pos_px.x + scale_px.x / 2 y_px = pos_px.y + scale_px.y / 2 else --center x_px = pos_px.x y_px = pos_px.y end x = x_px / simulated_resolution.x * 2 - 1 y = y_px / simulated_resolution.y * 2 - 1 width = scale_px.x / simulated_resolution.x * 2 height = scale_px.y / simulated_resolution.y * 2 return v2(x, y), v2(width, height) end local bgcolor = '000000' local bgopacity = '000000' local menu_options = menu.add_feature('session info', 'parent') local options_textshadow = menu.add_feature('text shadow', 'toggle', menu_options.id) local options_disablebg = menu.add_feature('disable background', 'toggle', menu_options.id) local options_bgcolor = menu.add_feature('background color', 'action', menu_options.id, function(f) local resp, str = input.get('background color', bgcolor, 6, 2) while (resp ~= 0) do system.wait(0) end local r = Regex('^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$') local m = r:search(str) if m.count > 0 then str = m.matches[1] if (str:len() == 3) then str = str:sub(1,1)..str:sub(1,1)..str:sub(2,2)..str:sub(2,2)..str:sub(3,3)..str:sub(3,3) end bgcolor = str ui.notify_above_map(str, 'set background color to #' .. str, 140) end end) local options_opacity = menu.add_feature('background opacity', 'action_value_i', menu_options.id) options_opacity.min_i = 0 options_opacity.max_i = 100 options_opacity.value_i = 100 menu.create_thread(function() while true do local base = v2(320, 20) if (not(options_disablebg.on)) then local pos, scale = coords_partial_to_screenwriter(base, v2(200, 200), 4) local opacity = string.format('%x', math.floor(options_opacity.value_i * 2.55)) while opacity:len() < 2 do opacity = '0'..opacity end print('0x'..opacity..bgcolor) scriptdraw.draw_rect(pos, scale, tonumber('0x'..opacity..bgcolor)) end local textFlags = 0 if options_textshadow.on then textFlags = 2 end --scriptdraw.draw_text(scale, v2(0, 0), v2(1, 1), 1, 0XFFFFFFFF, textFlags) system.wait(0) end end, nil)