Skip to content

Commit

Permalink
Merge pull request #3 from jiro4989/feature/add-sample
Browse files Browse the repository at this point in the history
Add example code #1
  • Loading branch information
SolitudeSF authored Dec 14, 2019
2 parents ceab6df + 0cb564a commit eba6013
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ nimcache
!tests/image.jpg
tests/t*
!tests/t*.nim
examples/*
!examples/*.nim
!examples/*.nims
!examples/sample.png
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ To have some boilerplate for recreative programming with images.
- [x] Vertically, Horizontally
- [ ] Radial
- Documentation

## Examples
See [examples](./examples) directory.
1 change: 1 addition & 0 deletions examples/config.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
switch("path", "$projectDir/../src")
11 changes: 11 additions & 0 deletions examples/flip.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import imageman

let img = loadImage[ColorRGBU]("sample.png")

block:
let img2 = img.flippedHoriz()
img2.savePNG("out_flip_horiz.png")

block:
let img2 = img.flippedVert()
img2.savePNG("out_flip_vert.png")
5 changes: 5 additions & 0 deletions examples/resize.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import imageman

let img = loadImage[ColorRGBU]("sample.png")
let img2 = img.resizedBicubic(512, 512)
img2.savePNG("out_resize_bicubic.png")
Binary file added examples/sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions imageman.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ srcDir = "src"

requires "nim >= 0.20.0"
requires "stb_image >= 2.2"

task examples, "Run examples":
withDir "examples":
let srcs = ["resize.nim", "flip.nim"]
for src in srcs:
echo "Run: " & src & " example"
exec "nim c -r --hints:off --verbosity:0 " & src

0 comments on commit eba6013

Please sign in to comment.