mirror of
https://github.com/Winded/RagdollMover.git
synced 2025-03-04 03:13:36 -05:00
Distance color changes
+ Gradient function to easily generate linearly-interpolated color gradients with NUM_GRADIENT_POINTS parameter - The color to use is automatically evaluated using the number of gradient points and the distance, allowing one to generalize beyond two gradient points - Darker colors
This commit is contained in:
parent
e81fd36d8f
commit
24cdf226b6
@ -998,7 +998,22 @@ local COLOR_BLUE = RGM_Constants.COLOR_BLUE
|
||||
local COLOR_BRIGHT_YELLOW = RGM_Constants.COLOR_BRIGHT_YELLOW
|
||||
local OUTLINE_WIDTH = RGM_Constants.OUTLINE_WIDTH
|
||||
|
||||
local BONETYPE_COLORS = { { RGM_Constants.COLOR_GREEN, RGM_Constants.COLOR_DARKGREEN }, { RGM_Constants.COLOR_CYAN, RGM_Constants.COLOR_DARKCYAN }, { RGM_Constants.COLOR_YELLOW, RGM_Constants.COLOR_DARKYELLOW }, { RGM_Constants.COLOR_RED, RGM_Constants.COLOR_DARKRED } }
|
||||
local function gradient(startPoint, endPoint, points)
|
||||
local colors = {}
|
||||
for i = 0, points-1 do
|
||||
colors[i+1] = startPoint:Lerp(endPoint, i / points)
|
||||
end
|
||||
return colors
|
||||
end
|
||||
|
||||
local NUM_GRADIENT_POINTS = 2
|
||||
|
||||
local BONETYPE_COLORS = {
|
||||
gradient(RGM_Constants.COLOR_GREEN, RGM_Constants.COLOR_DARKGREEN, NUM_GRADIENT_POINTS),
|
||||
gradient(RGM_Constants.COLOR_CYAN, RGM_Constants.COLOR_DARKCYAN, NUM_GRADIENT_POINTS),
|
||||
gradient(RGM_Constants.COLOR_YELLOW, RGM_Constants.COLOR_DARKYELLOW, NUM_GRADIENT_POINTS),
|
||||
gradient(RGM_Constants.COLOR_RED, RGM_Constants.COLOR_DARKRED, NUM_GRADIENT_POINTS)
|
||||
}
|
||||
|
||||
function DrawBoneName(ent, bone, name)
|
||||
if not name then
|
||||
@ -1118,7 +1133,6 @@ function AdvBoneSelectRender(ent, bonenodes)
|
||||
if not maxdist or maxdist < dist then maxdist = dist end
|
||||
bonedistances[i] = dist
|
||||
end
|
||||
maxdist = maxdist - mindist
|
||||
|
||||
local selectedBones = {}
|
||||
for i = 0, ent:GetBoneCount() - 1 do
|
||||
@ -1142,7 +1156,9 @@ function AdvBoneSelectRender(ent, bonenodes)
|
||||
table.insert(selectedBones, {name, i})
|
||||
else
|
||||
if nodesExist and bonenodes[ent][i] and bonenodes[ent][i].Type then
|
||||
surface.SetDrawColor(BONETYPE_COLORS[bonenodes[ent][i].Type][( ( bonedistances[i] - mindist ) < maxdist * 0.5 ) and 1 or 2]:Unpack())
|
||||
local fraction = ( bonedistances[i] - mindist ) / (maxdist - mindist)
|
||||
fraction = math.max(1, math.ceil(fraction * NUM_GRADIENT_POINTS))
|
||||
surface.SetDrawColor(BONETYPE_COLORS[bonenodes[ent][i].Type][fraction]:Unpack())
|
||||
else
|
||||
surface.SetDrawColor(COLOR_RGMGREEN:Unpack())
|
||||
end
|
||||
|
@ -1,13 +1,13 @@
|
||||
RGM_Constants = {
|
||||
COLOR_RED = Color(200, 0, 0, 255),
|
||||
COLOR_DARKRED = Color(90, 0, 0, 255),
|
||||
COLOR_DARKRED = Color(50, 0, 0, 255),
|
||||
COLOR_GREEN = Color(0, 200, 0, 255),
|
||||
COLOR_DARKGREEN = Color(0, 90, 0, 255),
|
||||
COLOR_DARKGREEN = Color(0, 50, 0, 255),
|
||||
COLOR_BLUE = Color(0, 0, 200, 255),
|
||||
COLOR_CYAN = Color(0, 200, 200, 255),
|
||||
COLOR_DARKCYAN = Color(0, 90, 90, 255),
|
||||
COLOR_DARKCYAN = Color(0, 50, 50, 255),
|
||||
COLOR_YELLOW = Color(200, 200, 0, 255),
|
||||
COLOR_DARKYELLOW = Color(90, 90, 0, 255),
|
||||
COLOR_DARKYELLOW = Color(50, 50, 0, 255),
|
||||
COLOR_BRIGHT_YELLOW = Color(255, 255, 0, 255),
|
||||
COLOR_WHITE = Color(255, 255, 255, 255),
|
||||
COLOR_BLACK = Color(0, 0, 0, 255),
|
||||
|
Loading…
Reference in New Issue
Block a user