🔮 Simple Watermark
Простенькая lua на недо-ватермарку в левом верхнем углу экрана с пояснением каждой строки кода
local gizmos = eh_singleton(eh_runtime_gizmos) -- getting gizmos
local transfusion_speed = 0.6 -- default bottom transfusion speed
local default_pos = Vector2(0, 0) -- default watermark position
local text_style = GUIStyle() -- creating style
local style_state = GUIStyleState() -- creating stylestate
style_state.textColor = Color.white -- setting default color
text_style.normal = style_state -- setting normal stylestate
text_style.alignment = TextAnchor.MiddleCenter -- setting text alignment
text_style.fontSize = 15 -- setting fontsize
local watermark_text = "emptyhack |" .. " additional text" -- watermark text (u can put here anything)
local rect = Rect(default_pos, gui_style_extensions.calc_text_size(text_style, watermark_text) + Vector2(32, 12)) -- creaing background rect (added additional 2, 2 cuz default font offsets) also added offsets
local text_rect = Rect(Vector2(default_pos.x + 15, default_pos.y + 5), gui_style_extensions.calc_text_size(text_style, watermark_text)) -- creating text rect with gaps
local bottom_rect = Rect(default_pos.x, default_pos.y + rect.height, rect.width, rect.height * 0.1) -- creating bottom rect
events.add("OnGUI", function() -- setting up event
if(Event.current.type == EventType.Repaint) then -- invoking code only on drawing event
gizmos.push_image(-1, rect, Texture2D.whiteTexture, Color32(25, 25, 25, 100), 0, 1) -- drawing background
local bottom_color = hsba_color(Mathf.PingPong(Time.time * transfusion_speed, 1), Mathf.PingPong(Time.time * transfusion_speed, 1), 1).to_color() -- LGBT+ color
gizmos.push_image(-1, bottom_rect, Texture2D.whiteTexture, bottom_color, 0, 1) -- drawing bottom
gizmos.push_text(-2, text_rect, watermark_text, Color.white, Color.black, 1, text_outline.shadow, text_style) -- drawing text
end
end)
Last updated