Quellcode durchsuchen

Use u8 RGBA values for Color4

Daniele Bartolini vor 9 Jahren
Ursprung
Commit
be1e896681

+ 7 - 7
samples/01-physics/core/editors/level_editor/level_editor.lua

@@ -2,12 +2,12 @@ require "core/editors/level_editor/camera"
 require "core/editors/level_editor/class"
 
 Colors = {
-	grid          = function() return Color4(0.4, 0.4, 0.4, 1.0) end,
-	grid_disabled = function() return Color4(0.4, 0.4, 0.4, 0.4) end,
-	axis_x        = function() return Color4(0.85, 0, 0, 1.0) end,
-	axis_y        = function() return Color4(0, 0.85, 0, 1.0) end,
-	axis_z        = function() return Color4(0, 0, 0.85, 1.0) end,
-	axis_selected = function() return Color4(0.85, 0.85, 0, 1.0) end,
+	grid          = function() return Color4(102, 102, 102, 255) end,
+	grid_disabled = function() return Color4(102, 102, 102, 102) end,
+	axis_x        = function() return Color4(217,   0,   0, 255) end,
+	axis_y        = function() return Color4(  0, 217,   0, 255) end,
+	axis_z        = function() return Color4(  0,   0, 217, 255) end,
+	axis_selected = function() return Color4(217, 217,   0, 255) end,
 }
 
 function log(msg)
@@ -59,7 +59,7 @@ function draw_grid(lines, tm, center, size, axis, color)
 	end
 
 	local cr, cg, cb, ca = Quaternion.elements(color)
-	local color_transparent = Color4(cr, cg, cb, 0)
+	local color_transparent = Quaternion.from_elements(cr, cg, cb, 0)
 
 	for i = -10, 10 do
 		local abs_i = math.abs(i)

+ 5 - 6
src/lua/lua_api.cpp

@@ -924,12 +924,11 @@ static int quaternionbox_tostring(lua_State* L)
 static int color4_ctor(lua_State* L)
 {
 	LuaStack stack(L);
-	Color4 c;
-	c.x = stack.get_float(1 + 1);
-	c.y = stack.get_float(2 + 1);
-	c.z = stack.get_float(3 + 1);
-	c.w = stack.get_float(4 + 1);
-	stack.push_color4(c);
+	u8 r = (u8)stack.get_int(1 + 1);
+	u8 g = (u8)stack.get_int(2 + 1);
+	u8 b = (u8)stack.get_int(3 + 1);
+	u8 a = (u8)stack.get_int(4 + 1);
+	stack.push_color4(from_rgba(r, g, b, a));
 	return 1;
 }