1. Kurt Staufenberg
  2. jcod

Commits

Chuck Adams  committed 2222781

finished Lines demo

  • Participants
  • Parent commits 66c84ae
  • Branches default

Comments (0)

Files changed (1)

File src/main/java/net/fishbulb/jcod/demo/Lines.java

View file
 
     BlendMode[] allModes = new BlendMode[]{
             None, Set, Multiply, Lighten, Darken, Screen, ColorDodge, ColorBurn, Add,
-            AddWithSourceAlpha, Burn, Overlay, AlphaTCOD,
+            AddAlpha, Alpha, AlphaLerp, Burn, Overlay,
     };
 
     Iterator<BlendMode> modes = Iterators.cycle(allModes);
         console.setDefaultForeground(Color.WHITE);
         console.setBlendFunction(None);
         backdrop = new Console(width, height);
-        Color col = new Color(1, 1, 1, 1);
+        Color col = new Color(1, 1, 1, currentAlpha);
         for (int x = 0; x < width; x++) {
             for (int y = 0; y < height; y++) {
                 col.r = ((float) x / (width - 1));
         if ((now - lastUpdate) < updateMillis) return;
         lastUpdate = now;
 
+        switch (currentMode) {
+            case Alpha: case AddAlpha: case AlphaLerp:
+                currentAlpha = (float) ((1.0+cos((double)now / 1000 *2))/2.0);
+                break;
+            default:
+                currentAlpha = 1.0f;
+        }
+
         // blit the background
         backdrop.blit(0, 0, width, height, console, 0, 0, 1, 1);
 
         // render the gradient
         int recty = (int) ((height - 2) * (1.0 + cos((double) now / 1000)) / 2.0);
-        Color col = new Color(1, 1, 1, 1);
+        Color col = new Color(1, 1, 1, currentAlpha);
         for (int x = 0; x < width; x++) {
             col.r = (float) x / width;
             col.g = (float) x / width;
         int yd = (int) (height / 2 - sinAngle * width / 2);
 
         // render the line
+        lineColor.a = currentAlpha;
         bresenham(xo, yo, xd, yd, listener);
 
         // print the current flag