• draw.SimpleText for Chatbox
    1 replies, posted
Hi there, I’m in the process of creating a chat box, however I want to display the chat lines using draw.SimpleText so that I can make it look more professional and use outlined text in some instances. My problem is that I need to integrate the ability to use different colors on one line. What would be the most efficient way to do this, assuming that every time a chat message comes through, it is added to a table.
Really, you should be using [URL="https://wiki.garrysmod.com/page/Category:RichText"]RichText[/URL] for this instead of SimpleText. [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/InsertColorChange]Panel:InsertColorChange[/url] [editline]23rd July 2017[/editline] You could do it without a panel element if you want though, but not with any of the standard draw functions. You'd have to do a bit of dodgy custom stuff [URL="https://github.com/MysteryPancake/GMod-Rainbows"]like I did to draw rainbow text[/URL]: [CODE] local function DrawRainbowText( multiplier, text, font, x, y ) surface.SetFont( font ) for i = 1, #text do local col = HSVToColor( i * multiplier % 360, 1, 1 ) surface.SetTextColor( col ) local w, h = surface.GetTextSize( string.sub( text, 1, i - 1 ) ) surface.SetTextPos( x + w, y ) local letter = string.sub( text, i, i ) surface.DrawText( letter ) end end [/CODE]
Sorry, you need to Log In to post a reply to this thread.