Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
how to fill text color with the same preload image color in p5js

I want to set/fill my text(avg 450 words) color with the same color of preload image to my canvas in P5js / JS. Is anybody can help me with how to do that?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You want to get the colour of an image and then fill with that colour so the text will be the same colour.

Here's a link to the documentation for the get() method which is what you're looking for.

In order to do this, we use the get(x, y) method to get the pixel at a specific location, this returns us an RGBA value which we can use to fill.

I've put together a really simple example to demonstrate this:

let img;
function preload() {
  img = loadImage('img.jpg');
}

function setup() {
  createCanvas(400, 400);
  image(img, 0, 0);
  let c = get(0, 0);
  fill(c);
}

function draw() {
  background(0);
  image(img, 0, 0);
  textSize(20);
  text('I am the same colour', 100, 350);
}

I'm just grabbing the very first pixel and filling with that. Here's a link to a p5.js sketch so you can see it running.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda