Garry's Mod Wiki

DColorCube:OnUserChanged

  DColorCube:OnUserChanged( table color )

Description

Function which is called when the color cube slider is moved (through user input). Meant to be overridden.

Arguments

1 table color
The new color, uses Color.

Example

Creates a color cube which controls the blue saturation and value of a ball image.

-- Frame MainFrame = vgui.Create("DFrame") MainFrame:SetSize(320, 200) MainFrame:Center() MainFrame:SetTitle("Choose the saturation and value") -- Image of a ball local ball_img = vgui.Create("DImage", MainFrame) ball_img:SetPos(20, 45) ball_img:SetSize(128, 128) ball_img:SetImage("sprites/sent_ball") -- Color cube local color_cube = vgui.Create("DColorCube", MainFrame) color_cube:SetPos(160, 40) color_cube:SetSize(150, 150) -- Set color to blue color_cube:SetColor(Color(0, 0, 255)) -- Called when slider is moved by user function color_cube:OnUserChanged(col) -- Update ball color ball_img:SetImageColor(col) end
Output: