Skip to content

Instantly share code, notes, and snippets.

@rolantin
Created January 8, 2019 02:00
Show Gist options
  • Save rolantin/f5d1153ac4daaf2f1eb19a9e799b4413 to your computer and use it in GitHub Desktop.
Save rolantin/f5d1153ac4daaf2f1eb19a9e799b4413 to your computer and use it in GitHub Desktop.
Codea vertex index
function setup()
parameter.integer("value",1,3,1,set)
end
function draw()
background(40, 40, 50)
myMesh:draw()
end
function set()
myMesh = mesh()
myMesh.vertices = {vec2(0,0),vec2(100,0),vec2(0,100),
vec2(0,100),vec2(100,100),vec2(100,0)}
if value==1 then
-- set color for whole mesh
myMesh:setColors(255,0,0)
elseif value==2 then
-- set color for whole mesh
myMesh:setColors(255,0,0)
-- then set color for each of the 6 vertices
myMesh:color(1,255,0,0)
myMesh:color(2,255,0,0)
myMesh:color(3,255,0,0)
myMesh:color(4,0,255,0)
myMesh:color(5,0,255,0)
myMesh:color(6,0,255,0)
elseif value==3 then
-- get texture image
img = readImage("Planet Cute:Icon")
-- set texture image
myMesh.texture = img --Set the image as texture
-- set texture coordinates
t={vec2(0,0),vec2(1,0),vec2(0,1),vec2(0,1),vec2(1,1),vec2(1,0)}
myMesh.texCoords=t
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment