I'm trying to make a thick crosshair, but they are so tiny :(
You could use [url=http://wiki.garrysmod.com/page/surface/DrawPoly]surface.DrawPoly[/url] to create a thicker non-horizontal/vertical line. Otherwise you should just use [url=http://wiki.garrysmod.com/page/surface/DrawRect]surface.DrawRect[/url] to do the same thing.
can you give me an example?
Just threw this together for you, hope it can help out.
[img]http://puu.sh/cfpHX/45d2ea82f0.jpg[/img]
LEFT: Used surface.DrawPoly (4 separate tables)
RIGHT: Used surface.DrawRect
[lua]local PANEL = {}
function PANEL:Init()
local W, H = ScrW(), ScrH()
self:SetSize( 128*2, 64 )
self:SetPos( W/2-self:GetWide()/2, H/2-self:GetTall()/2+200 )
end
function PANEL:Paint()
surface.SetDrawColor( color_white )
surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
surface.SetDrawColor( color_black )
surface.DrawOutlinedRect( 0, 0, self:GetWide(), self:GetTall() )
surface.DrawRect( self:GetWide()/2-1, 0, 2, self:GetTall() )
--surface.DrawRect( 0, self:GetTall()/2-1, self:GetWide(), 2 )
--surface.DrawRect( self:GetWide()/4-1, 0, 2, self:GetTall() )
--surface.DrawRect( 3*self:GetWide()/4-1, 0, 2, self:GetTall() )
-- Draw Left Side
local X, Y = self:GetWide()/4, self:GetTall()/2
local t1 = {
{ x = X-14, y = Y-10 },
{ x = X-10, y = Y-10 },
{ x = X-2, y = Y-2 },
{ x = X-6, y = Y-2 },
}
local t2 = {
{ x = X+10, y = Y-10 },
{ x = X+14, y = Y-10 },
{ x = X+6, y = Y-2 },
{ x = X+2, y = Y-2 },
}
local t3 = {
{ x = X-6, y = Y+2 },
{ x = X-2, y = Y+2 },
{ x = X-10, y = Y+10 },
{ x = X-14, y = Y+10 },
}
local t4 = {
{ x = X+2, y = Y+2 },
{ x = X+6, y = Y+2 },
{ x = X+14, y = Y+10 },
{ x = X+10, y = Y+10 },
}
draw.NoTexture()
surface.SetDrawColor( color_black )
surface.DrawPoly( t1 )
surface.DrawPoly( t2 )
surface.DrawPoly( t3 )
surface.DrawPoly( t4 )
-- Draws Right Side
X = X*3
surface.DrawRect( X-16, Y-1, 10, 2 )
surface.DrawRect( X+6, Y-1, 10, 2 )
surface.DrawRect( X-1, Y-16, 2, 10 )
surface.DrawRect( X-1, Y+6, 2, 10 )
end
-- I was messing around with a pointshop skin...
vgui.Register('DPointShopMenu', PANEL)[/lua]
There may be better methods can't think of anything else at the moment, other that using rotations.
You can achieve a thicker line by just using a for loop and some maths. It completely avoids having to use long tables and is probably more efficient to boot. Create a custom function for it, it isn't too hard. I think I have one I made not to long ago, I'll see if I can find it.
add 1 + incrementvar to x and y in a loop, like what Fortune said
Why not just use multiple of the lines 1 pixel apart?
I'd also recommend defining the local tables outside of the paint-function. No need to recreate the tables each frame.
Something like this could be used to update them if the screen-size changes: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_hooks/playerchangedresolution/lua/autorun/client/cl_gm_playerchangedresolution.lua[/url]
Example of how it works:
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_hooks/playerchangedresolution/example_usage.lua[/url]
For it to work with a created panel though, you'd need to do a hook.Add inside the Init so it'd control the particular vgui element. But, the example is shown for huds.
Sorry, you need to Log In to post a reply to this thread.