Skip to content

Commit

Permalink
Release 0.1.1, major improvements to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyettinger committed Jun 7, 2020
1 parent d64222e commit 0ed018a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
49 changes: 45 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,64 @@ A typical Gradle dependency on anim8 looks like this (in the core module's depen
```groovy
dependencies {
//... other dependencies are here, like libGDX
api 'com.github.tommyettinger:anim8-gdx:0.1.0'
api 'com.github.tommyettinger:anim8-gdx:0.1.1'
}
```

You can also get a specific commit using JitPack, by following the instructions on
[JitPack's page for anim8](https://jitpack.io/#tommyettinger/anim8-gdx/09eaf9d640).

Although a .gwt.xml file is present in the sources jar (`api 'com.github.tommyettinger:anim8-gdx:0.1.1:sources'`), using
any file-writing on GWT is a challenge that I haven't tackled yet. There is always a method available that can write to
an OutputStream, for any of the animated formats here, using:
```java
void write(OutputStream output, Array<Pixmap> frames, int fps)
```
This may be enough to write to a `ByteArrayOutputStream`, and use that somehow on GWT.

# Quirks
The default dithering algorithm used here is a variant on Thomas Knoll's pattern dither, which has been out-of-patent
since November 2019. Used verbatim, pattern dither forms a square grid of lighter or darker pixels where a color isn't
matched exactly. The first change here affects **Quirk Number One**: with pattern dither, some diagonal streaks may
appear due to how the square grid has been skewed to obscure that artifact. The second change relates to **Quirk Number
Two**: some partial gamma correction seems to significantly reduce the appearance of coarse dithering artifacts, but
also tends to bias the lightness balance toward brighter colors, sometimes partly washing out some details. You can set
the dithering algorithm to an alternative ordered dither, a variant on Jorge Jimenez' Gradient Interleaved Noise, using:
`setDitherAlgorithm(Dithered.DitherAlgorithm.GRADIENT_NOISE)`. This still has some diagonal lines that appear in it, but
they aren't usually as noticeable; there is however **Quirk Number Three**: with gradient noise dither, some smooth
gradients in the source image have rough sections where they move briefly away from the right color before correcting
their path. Gradient noise dither also tends to be, well, noisier. There's also the `Dithered.DitherAlgorithm.NONE`
algorithm, but it's only reasonable for some art styles that don't look good with any dither.

# Samples
Some .gif animations, using 255 colors:

![Yellow Gif](images/AnimatedGif-yellow.gif)
Pattern dither:
![Flashy Gif, pattern dither](images/AnimatedGif-flashy-pattern.gif)

Gradient dither:
![Flashy Gif, gradient dither](images/AnimatedGif-flashy-pattern.gif)

![Green Gif](images/AnimatedGif-green.gif)
Pattern dither:
![Contrast Gif, pattern dither](images/AnimatedGif-contrast-pattern.gif)

Gradient dither:
![Contrast Gif, gradient dither](images/AnimatedGif-contrast-pattern.gif)

Pattern dither:
![Green Gif, pattern dither](images/AnimatedGif-green-pattern.gif)

Gradient dither:
![Green Gif, gradient dither](images/AnimatedGif-green-gradient.gif)

No dither:
![Green Gif, no dither](images/AnimatedGif-green-none.gif)

And some .png animations, using full color:

![Yellow Full-Color PNG](images/AnimatedPNG-yellow.png)
![Flashy Full-Color PNG](images/AnimatedPNG-flashy.png)

![Contrast Full-Color PNG](images/AnimatedPNG-contrast.png)

![Green Full-Color PNG](images/AnimatedPNG-green.png)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply from: 'publish.gradle'
sourceCompatibility = 1.7

def projectName = 'anim8-gdx'
version '0.1.1-SNAPSHOT'
version '0.1.1'
group 'com.github.tommyettinger'

//api "com.github.tommyettinger:anim8-gdx:0.1.0"
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/com/github/tommyettinger/ShaderCaptureDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public void create() {
"}\n" +
"void main() {\n" +
"// vec3 xyz = vec3(gl_FragCoord.xy, tm);\n" +
" vec2 distort = acos(1.5 * (v_texCoords - 0.5)) * pow(PHI, -2.75 + distance(v_texCoords, vec2(0.5, 0.5))) * 300.0;\n" +
" vec3 xyz = vec3(distort.x, (distort.y + 10.0) * sin(tm * (3.14159265 * 0.02)) * 0.3, (distort.y + 10.0) * cos(tm * (3.14159265 * 0.02)) * 0.3);\n" +
" vec2 distort = acos(1.5 * (v_texCoords - 0.5)) * pow(PHI, -2.75 + distance(v_texCoords, vec2(0.5, 0.75))) * 300.0;\n" +
" vec3 xyz = vec3(distort.x, (distort.y + 4.0) * sin(tm * (3.14159265 * 0.02)) * 0.3, (distort.y + 7.0) * cos(tm * (3.14159265 * 0.02)) * 0.3);\n" +
" vec3 alt = xyz * 0.009 - xyz.yzx * 0.005 + xyz.zxy * 0.003;\n" +
" \n" +
" float yt = (alt.y * PHI + alt.z - alt.x) * 0.5 * (swayRandomized(123.456 + seed, alt.x * 0.2123) + 1.5);\n" +
Expand Down Expand Up @@ -121,7 +121,7 @@ public void create() {
}
batch.setShader(shader);

long state = 0x1234567890AL;
long state = 0x123456789L;
// SquidLib's DiverRNG.randomize()
seed = ((((state = (state ^ (state << 41 | state >>> 23) ^ (state << 17 | state >>> 47) ^ 0xD1B54A32D192ED03L) * 0xAEF17502108EF2D9L) ^ state >>> 43 ^ state >>> 31 ^ state >>> 23) * 0xDB4F0B9175AE2165L) >>> 36) * 0x1.5bf0a8p-16f;
startTime -= (state ^ state >>> 11) & 0xFFFFL;
Expand Down Expand Up @@ -191,6 +191,7 @@ public void renderPNG8() {
pixmaps.add(ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
}
PNG8 png8 = new PNG8();
//png8.setDitherAlgorithm(Dithered.DitherAlgorithm.GRADIENT_NOISE);
png8.setCompression(7);
png8.write(Gdx.files.local("images/PNG8-" + startTime + ".png"), pixmaps, 16);
}
Expand All @@ -208,6 +209,7 @@ public void renderGif() {
pixmaps.add(ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
}
AnimatedGif gif = new AnimatedGif();
//gif.setDitherAlgorithm(Dithered.DitherAlgorithm.GRADIENT_NOISE);
gif.write(Gdx.files.local("images/AnimatedGif-" + startTime + ".gif"), pixmaps, 16);
}

Expand Down

0 comments on commit 0ed018a

Please sign in to comment.