1.13.1 • Published 10 days ago

pokemon3d-image-resolver v1.13.1

Weekly downloads
-
License
ISC
Repository
-
Last release
10 days ago

🚀 Pokemon Image Resolver 🚀

🎮 Video Game Developed Using This Package

This package has been used in the development of the video game Nevomon. Check out the game here

🌐 Language

The names of the Pokémon used in this package are in English.

🖼️ Example Results

Here is an example of the results for the front-normal, front-shiny, back-normal, and back-shiny versions of Aerodactyl:

📦 Installation

npm install pokemon3d-image-resolver

🛠 Usage

Retrieve a Specific Image

  1. Import necessary functions and types :
import { getPokemon, PokemonData } from "pokemon3d-image-resolver";
  1. Set the parameters :
const myPokemon: PokemonData = {
  name: "pikachu",
  version: "front-shiny",
};
  1. Retrieve the image :
const imageData = await getPokemon(myPokemon);
if (imageData) {
  console.log("Votre image Pokemon en base64 :", imageData);
} else {
  console.log("Image Pokemon introuvable.");
}

Retrieve All Versions of a Pokemon

import { getAllPokemonVersions } from "pokemon3d-image-resolver";

const pikachuImages = await getAllPokemonVersions("pikachu");
console.log(pikachuImages["front-shiny"]); // Ceci affichera l'image "front-shiny" de Pikachu en base64, ou `null` si elle n'est pas trouvée.

🖼️ Use of the base64 String in an img Tag

Once you have retrieved the base64 string of your Pokémon image, you can use it directly in an HTML img tag:

<img src="data:image/gif;base64,CHAINE_BASE64_ICI" alt="Pokemon Image" />

Using JavaScript or others, this would be:

const base64Image = await getPokemon({
  name: "pikachu",
  version: "front-shiny",
});
const imgElement = `<img src="${base64Image}" alt="Image de Pikachu" />`;

🔍 Available Versions

  • front-normal : Image standard de face
  • back-normal : Image standard de dos
  • front-shiny : Image shiny de face
  • back-shiny : Image shiny de dos

❓ Problems or Suggestions

If you encounter any issues or have suggestions, feel free to open a ticket.

Example Code and Usage on Express, to Help You.

nom init -y
npm install express
npm install pokemon3d-image-resolver
const {
  getPokemon,
  getAllPokemonVersions,
} = require("pokemon3d-image-resolver");
const express = require("express");
const app = express();
const PORT = 3000;

// ==== Appelez getAllPokemonVersions avec le name du pokemon provenant de l'URL ==== \\
app.get("/getAll/:name", async (req, res) => {
  const { name } = req.params;

  try {
    const versions = await getAllPokemonVersions(name);

    res.write("<h1>Versions de Pokemon</h1>");
    for (const version in versions) {
      if (versions[version]) {
        res.write(`<h2>${version}</h2>`);
        res.write(`<img src="${versions[version]}" alt="${version}" />`);
      }
    }

    res.end();
  } catch (error) {
    console.error(`Failed to get versions for ${name}:`, error);
    res.status(500).send("Internal server error");
  }
});

// ==== Appelez getPokemon avec le name du pokemon provenant de l'URL ==== \\
app.get("/:name", async (req, res) => {
  const { name } = req.params;

  try {
    const pokemon = await getPokemon({ name: name, version: "front-normal" }); // Utilisation du paramètre "name" plutôt que "Pikachu" en dur.

    res.write("<h1>Pokemon</h1>");
    res.write(`<h2>${name}</h2>`);
    if (pokemon) {
      res.write(`<img src="${pokemon}" alt="${name}" />`);
    } else {
      res.write(`<p>Image non trouvée pour ${name}.</p>`);
    }

    res.end();
  } catch (error) {
    console.error(`Failed to get image for ${name}:`, error);
    res.status(500).send("Internal server error");
  }
});

📝 Licence

ISC

1.13.1

10 days ago

1.13.0

5 months ago

1.12.0

6 months ago

1.11.0

6 months ago

1.10.0

6 months ago

1.0.9

6 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.0

7 months ago