GetColor
This functions gets the material color.
Syntax
- Vec4 GetColor(number mode=Draw.DiffuseColor)
Parameters
- mode: the color to get. This can be Draw::DiffuseColor or Draw::SpecularColor.
Returns
Returns the material color.
Example
window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
directionallight = DirectionalLight:Create()
directionallight:SetRotation(45,35,0)
--Create a material
material = Material:Create()
material:SetColor(0.33,0.66,0)
--Create a model and apply the material to it
local model = Model:Sphere()
model:SetPosition(0,0,2)
model:SetMaterial(material)
while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end
--Get the material color
local color = material:GetColor()
--Modify and apply the color
color.r = Math:Mod(color.r + Time:GetSpeed()*0.01,1)
color.g = Math:Mod(color.g + Time:GetSpeed()*0.015,1)
color.b = Math:Mod(color.b + Time:GetSpeed()*0.025,1)
material:SetColor(color)
Time:Update()
world:Update()
world:Render()
context:Sync()
end