Skip to content

Commit

Permalink
add typescript example
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmarinacci committed Oct 18, 2023
1 parent 063dfc9 commit 62f16c2
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 0 deletions.
Binary file added examples/import_example_ts/out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions examples/import_example_ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions examples/import_example_ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "import_example_ts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"pureimage": "^0.4.13"
},
"devDependencies": {
"typescript": "^5.2.2"
},
"scripts": {
"build": "tsc",
"test": "node build/basic.js"
},
"author": "",
"license": "ISC"
}
14 changes: 14 additions & 0 deletions examples/import_example_ts/src/basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as PImage from "pureimage";
import * as fs from "fs";
const img1 = PImage.make(100, 100);
const ctx = img1.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 100, 100);

PImage.encodePNGToStream(img1, fs.createWriteStream("out.png"))
.then(() => {
console.log("wrote out the png file to out.png");
})
.catch((e) => {
console.log("there was an error writing", e);
});
6 changes: 6 additions & 0 deletions examples/import_example_ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"outDir": "./build"
},
"include": ["src"]
}

0 comments on commit 62f16c2

Please sign in to comment.