From b5b9efc28bb65fa3a53db8867310ac42d00f2bc6 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 20 Apr 2020 14:25:51 -0400 Subject: Inital commit --- lua/vgui/dtiltedlabel.lua | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lua/vgui/dtiltedlabel.lua (limited to 'lua/vgui') diff --git a/lua/vgui/dtiltedlabel.lua b/lua/vgui/dtiltedlabel.lua new file mode 100644 index 0000000..a0aaf7d --- /dev/null +++ b/lua/vgui/dtiltedlabel.lua @@ -0,0 +1,39 @@ +local PANEL = {} +local base = vgui.GetControlTable("DLabel") +setmetatable(PANEL,{__index=base}) + +--Function stolen from the lua wiki +function draw.TextRotated( text, x, y, color, font, ang ) + render.PushFilterMag( TEXFILTER.ANISOTROPIC ) + render.PushFilterMin( TEXFILTER.ANISOTROPIC ) + surface.SetFont( font ) + surface.SetTextColor( color ) + surface.SetTextPos( 0, 0 ) + local textWidth, textHeight = surface.GetTextSize( text ) + local rad = -math.rad( ang ) + x = x - ( math.cos( rad ) * textWidth / 2 + math.sin( rad ) * textHeight / 2 ) + y = y + ( math.sin( rad ) * textWidth / 2 + math.cos( rad ) * textHeight / 2 ) + local m = Matrix() + m:SetAngles( Angle( 0, ang, 0 ) ) + m:SetTranslation( Vector( x, y, 0 ) ) + cam.PushModelMatrix( m ) + surface.DrawText( text ) + cam.PopModelMatrix() + render.PopFilterMag() + render.PopFilterMin() +end +function PANEL:Paint(w,h) + local x,y = self:LocalToScreen(0,0) + print("x",x,"y",y) + draw.TextRotated(self:GetText(),0,y,Color(0,0,0,255),"DermaDefault",-45) +end +function PANEL:GetHeaderHeight() + return 0--10 * #(self.Header:GetText()) +end +function PANEL:Init() + + --self.Header = vgui.Create( "DButton", self ) + --self.Header.DoClick = function() self:DoClick() end + --self.Header.DoRightClick = function() self:DoRightClick() end +end +vgui.Register("DTiltedLabel", PANEL, "DLabel") -- cgit v1.2.3-70-g09d2