Skip to content

Commit

Permalink
Now use clock.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerjimbo committed Apr 15, 2018
1 parent a4df578 commit 964a1ec
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Jimbo/Graphics/MonoMatrixDemo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017 Jim Darby.
* Copyright (C) 2018 Jim Darby.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -42,7 +42,8 @@ public static void run (MonoMatrix m) throws InterruptedException, IOException
final int max_y = limits.getY ();
final Double on = new Double (1);
final Double off = new Double (0);

final Clock <Integer> clock = Clock.isClockable(m) ? new Clock <> (m) : null;

for (int y = 0; y <= max_y; ++y)
for (int x = 0; x <= max_x; ++x)
{
Expand All @@ -66,12 +67,15 @@ public static void run (MonoMatrix m) throws InterruptedException, IOException
final double distance = Math.sqrt (x*x + y*y);
final double fraction = 1 - distance / max_distance;
final double value = Math.sin ((fraction + phase / 100.0) * 2 * Math.PI);
final Double pixel = new Double (0.5 + 0.5 * value);
final Double pixel = 0.5 + 0.5 * value;
final Point p = new Point (x, y);

m.setPixel (p, pixel);
}

if (clock != null)
clock.filter();

m.show ();

phase += 1;
Expand Down

0 comments on commit 964a1ec

Please sign in to comment.