# Color from mesh to another mesh

I was trying to make some composite mesh by combining meshes into one bigger mesh, ran into issues with the colors (didn’t even get to textures yet)
here I isolated the problem into its simplest form.
this is probably just some limitation for meshes that I’ll have to work around but I thought I’d mention it… maybe it is a bug?

``````-- color from mesh to mesh bug
--the issue: when I try to take colors from one mesh and use them in another mesh they changed to (0,0,0,0)

function setup()
parameter.integer("meshToDraw",1,2,1)
local p1,p2,p3 = vec2(0,0), vec2(WIDTH/2,HEIGHT), vec2(WIDTH,0)
local c1,c2,c3 = color(255, 0, 0), color(0, 255, 0), color(80, 0, 255)
m1 = mesh()
m1.vertices = {p1,p2,p3}
m1.colors = {c1,c2,c3}
m2 = mesh()
m2.vertices = m1.vertices --use vertices from m1
m2.colors = m1.colors     --use colors from m1
--tried to print like this but it throws an error:
--print("m1 colors: "..m1.colors[1]..", "..m1.colors[2]..", "..m1.colors[3])
print("m1 colors: ") print(m1.colors[1]) print(m1.colors[2]) print(m1.colors[3]) -- exist but values range from 0-1 instead of 0-255
print("m2 colors: ") print(m2.colors[1]) print(m2.colors[2]) print(m2.colors[3]) -- all are (0,0,0,0) ?!
meshes = {m1,m2}
end

function draw()
background(0)
meshes[meshToDraw]:draw()
end
``````

Version: 3.9.8 (443)

mesh converts these to normalized vectors from 0-1, so just do 255 * m1.colors[1]

also to print with concatenation you have to wrap implicit statements
–print("m1 colors: “…(m1.colors[1])…”, “…(m1.colors[2])…”, "…(m1.colors[3]))