
package com.annimon.jecp.demo.screens;

import com.annimon.jecp.JecpGraphics;
import com.annimon.jecp.JecpRandom;
import com.annimon.jecp.demo.DynamicLine;

/**
 * Lines animation demo.
 * @author aNNiMON
 */
public class LinesScreen extends Screen {
    
    private static final int LINES_COUNT = 5;
    
    private final DynamicLine[] lines;

    public LinesScreen(int width, int height) {
        super(width, height);
        lines = new DynamicLine[LINES_COUNT];
        for (int i = 0; i < LINES_COUNT; i++) {
            lines[i] = new DynamicLine(
                    JecpRandom.rand(width), JecpRandom.rand(height),
                    JecpRandom.rand(width), JecpRandom.rand(height));
        }
    }
    
    public void onPaint(JecpGraphics g) {
        super.onPaint(g);
        for (int i = 0; i < LINES_COUNT; i++) {
            lines[i].onPaint(g);
        }
    }

    public void onUpdate() {
        for (int i = 0; i < lines.length; i++) {
            lines[i].onUpdate(width, height);
        }
        sleep(5);
    }
    
}

@@ -37,16 +37,46 @@
 ens;%0D%0A%0D%0A
+import com.annimon.jecp.Fps;%0D%0A
 import c
@@ -143,16 +143,47 @@
 andom;%0D%0A
+import com.annimon.jecp.Keys;%0D%0A
 import c
@@ -243,16 +243,38 @@
 imation 
+and FPS-class methods 
 demo.%0D%0A 
@@ -391,32 +391,106 @@
 UNT = 5;%0D%0A    %0D%0A
+    private boolean fpsLimiter;%0D%0A    private long fpsLimiterDelay;%0D%0A    %0D%0A
     private fina
@@ -587,32 +587,91 @@
 idth, height);%0D%0A
+        fpsLimiter = false;%0D%0A        fpsLimiterDelay = 5;%0D%0A
         lines = 
@@ -995,24 +995,60 @@
 phics g) %7B%0D%0A
+        Fps.startMeasuringDelay();%0D%0A
         supe
@@ -1152,24 +1152,340 @@
 %0A        %7D%0D%0A
+        g.setColor(0xFFFFFFFF);%0D%0A        g.drawString(%22Fps limiter is %22 + (fpsLimiter ? %22on%22 : %22off%22) + %22. Press up to change state.%22, 0, 0);%0D%0A        g.drawString(%22Fps: %22 + Fps.getFps(), 0, g.getTextHeight());%0D%0A        %0D%0A        if (fpsLimiter) fpsLimiterDelay = Fps.getDelay();%0D%0A        else fpsLimiterDelay = 2;%0D%0A
     %7D%0D%0A%0D%0A   
@@ -1633,17 +1633,31 @@
   sleep(
-5
+fpsLimiterDelay
 );%0D%0A    
@@ -1659,17 +1659,207 @@
 %0A    %7D%0D%0A
+%0D%0A
     
+public void onKeyPressed(int key) %7B%0D%0A        super.onKeyPressed(key);%0D%0A        final int dpad = Keys.convertToDpad(key);%0D%0A        if (dpad == Keys.DPAD_UP) fpsLimiter = !fpsLimiter;%0D%0A    %7D
 %0D%0A%7D%0D%0A

Add Fps demo to Lines screen