Currently the closest I can get is
Code: Select all
color1 = {252, 217, 63}
color2 = {2, 35, 132}
love.graphics.setColor(color1)
So is there any way to exchange colors in this way?
Thanks in advance, Noah
Code: Select all
color1 = {252, 217, 63}
color2 = {2, 35, 132}
love.graphics.setColor(color1)
Code: Select all
color1 = {252, 217, 63}
love.graphics.setColor(color1)
love.graphics.draw(image1, x, y)
color2 = {2, 35, 132}
love.graphics.setColor(color2)
love.graphics.draw(image2, x, y)
Code: Select all
function love.load()
black = love.image.newImageData('image.png')
white = love.image.newImageData('image.png')
black:mapPixel(function(x, y, r, g, b, a)
if r == 255 and g == 255 and b == 255 and a == 255 then -- If the pixel is white...
return 0, 0, 0, 0 --- ... make it invisible.
elseif r == 0 and g == 0 and b == 0 and a == 255 then -- If the pixel is black...
return 255, 255, 255, 0 --- ... make it white.
else -- If the pixel is invisible, leave as is.
return r, g, b, a
end
end)
white:mapPixel(function(x, y, r, g, b, a)
if r == 0 and g == 0 and b == 0 and a == 255 then -- If the pixel is black...
return 0, 0, 0, 0 --- ... make it invisible.
else
return r, g, b, a
end
end)
image1 = love.graphics.newImage(black)
image2 = love.graphics.newImage(white)
x = 100
y = 100
end
function love.draw()
color1 = {252, 217, 63}
love.graphics.setColor(color1)
love.graphics.draw(image1, x, y)
color2 = {2, 35, 132}
love.graphics.setColor(color2)
love.graphics.draw(image2, x, y)
end
Code: Select all
function loadImage(path)
blackLayer = love.image.newImageData(path)
whiteLayer = love.image.newImageData(path)
blackLayer:mapPixel(function(x, y, r, g, b, a)
if r == 255 and g == 255 and b == 255 and a == 255 then
return 0, 0, 0, 0 -- make the white pixels invisible
elseif r == 0 and g == 0 and b == 0 and a == 255 then
return 255 ,255, 255, 255 -- make the black pixels white
else
return r, g, b, a -- if it's not black or white (basically invisible cuz i won't add other colors) then just leave it
end
end)
return love.graphics.newImage(whiteLayer), love.graphics.newImage(blackLayer)
end
Code: Select all
shader = love.graphics.newShader [[
extern Image palette;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) {
vec4 tex_color = texture2D(texture, texture_coords);
vec2 index = vec2(tex_color.r, 0); //get color based on red
return texture2D(palette, index);
}]]
Code: Select all
shader = love.graphics.newShader [[
extern Image palette;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) {
vec4 tex_color = texture2D(texture, texture_coords); //get the colour of the pixel which is being drawn
vec2 index = vec2(tex_color.r, 0); //get pixel position on palette based on red
vec4 new_color = texture2D(palette, index); //get colour of the pixel in the palette
new_color.a = tex_color.a; //preserve the original alpha, only changing the rest of the colours;
return new_color * color; //factor in the colour set with love.graphics.setColor
}]]
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 9 guests