Anonymous avatar Anonymous committed 2222781

finished Lines demo

Comments (0)

Files changed (1)

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

 
     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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.