Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vthibault/tga.js
Load and display TGA files with Javascript.
https://github.com/vthibault/tga.js
javascript tga tga-files tga-image tgareader
Last synced: about 8 hours ago
JSON representation
Load and display TGA files with Javascript.
- Host: GitHub
- URL: https://github.com/vthibault/tga.js
- Owner: vthibault
- License: mit
- Created: 2013-05-27T13:23:38.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2020-10-01T19:36:57.000Z (about 4 years ago)
- Last Synced: 2024-10-11T20:19:01.101Z (28 days ago)
- Topics: javascript, tga, tga-files, tga-image, tgareader
- Language: JavaScript
- Size: 64.5 KB
- Stars: 44
- Watchers: 5
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# tga-js
![Browser](https://img.shields.io/badge/env-browser-blue.svg)
![](https://img.shields.io/david/vthibault/tga.js.svg)
![](https://img.shields.io/snyk/vulnerabilities/github/vthibault/tga.js.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)**tga-js** is a tga file loader written in JavaScript, working in the browser environment. It provides a simple and really fast solution for loading TGA file format.
> Lot of games are using TGA files to store textures.
> So, since browsers try to bring games in the web it can be a good idea to have a TGA loader _(actually a better idea to use another smaller file format)_.---
## 🔗 Used by :
- [ThreeJS](https://threejs.org/) 3D Engine
- [BabylonJS](https://www.babylonjs.com/) 3D Engine---
## 🚀 Installation
Install with [yarn](https://yarnpkg.com):
```sh
$ yarn add tga-js
```Or install using [npm](https://npmjs.org):
```sh
$ npm i tga-js
```---
## 📖 Usage
#### Loading a remote tga file.
```js
import TgaLoader from 'tga-js';const tga = new TgaLoader();
tga.open('./assets/resource.tga', () => {
document.body.appendChild(tga.getCanvas());
});
```#### Loading a tga from buffer.
```js
import TgaLoader from 'tga-js';const tga = new TgaLoader();
// Your own function returning a buffer from cache/memory/..
const buffer = getImageBufferFromCache('resource/data');tga.load(new UInt8Array(buffer));
document.body.appendChild(tga.getCanvas());
```#### Get data-uri as output
```js
tga.getDataURL('image/png');
```