SneakySquid icon

Mesh Gradients

SneakySquid | PRO | 02/21/25 01:36:33 PM UTC (Edited) | 0 ⭐ | 6852 👁️ | Never ⏰ | []
Lua |

1.04 KB

|

None

|

0 👍

/

0 👎

local vgui_white = Material("vgui/white")
 
function draw.GradientV(x, y, w, h, col_a, col_b)
    render.SetMaterial(vgui_white)
 
    mesh.Begin(MATERIAL_QUADS, 1)
        mesh.Position(Vector(x, y, 0))
        mesh.Color(col_a:Unpack())
        mesh.AdvanceVertex()
 
        mesh.Position(Vector(x + w, y, 0))
        mesh.Color(col_a:Unpack())
        mesh.AdvanceVertex()
 
        mesh.Position(Vector(x + w, y + h, 0))
        mesh.Color(col_b:Unpack())
        mesh.AdvanceVertex()
 
        mesh.Position(Vector(x, y + h, 0))
        mesh.Color(col_b:Unpack())
        mesh.AdvanceVertex()
    mesh.End()
end
 
function draw.GradientH(x, y, w, h, col_a, col_b)
    render.SetMaterial(vgui_white)
 
    mesh.Begin(MATERIAL_QUADS, 1)
        mesh.Position(Vector(x + w, y, 0))
        mesh.Color(col_b:Unpack())
        mesh.AdvanceVertex()
 
        mesh.Position(Vector(x + w, y + h, 0))
        mesh.Color(col_b:Unpack())
        mesh.AdvanceVertex()
 
        mesh.Position(Vector(x, y + h, 0))
        mesh.Color(col_a:Unpack())
        mesh.AdvanceVertex()
 
        mesh.Position(Vector(x, y , 0))
        mesh.Color(col_a:Unpack())
        mesh.AdvanceVertex()
    mesh.End()
end
 

Comments

  • SneakySquid icon
    02/21/25 01:36:50 PM UTC
    Lua |

    0 B

    |

    0 👍

    /

    0 👎

    hook.Add("HUDPaint", "gradient examples", function()
        draw.GradientH(50, 50, 300, 300, color_white, Color(0, 0, 0, 0))
        draw.GradientV(50, 350, 300, 300, color_black, Color(0, 0, 0, 0))
    end)
    
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎