Changeset 18929 in josm for trunk/src/org
- Timestamp:
- 2023-12-31T20:13:15+01:00 (11 months ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/animation
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/animation/ChristmasExtension.java
r14581 r18929 5 5 import java.util.ArrayList; 6 6 import java.util.List; 7 import java.util.Random; 7 8 8 9 /** … … 14 15 public class ChristmasExtension implements AnimationExtension { 15 16 16 private final List< Star> stars = new ArrayList<>(50);17 private final List<IAnimObject> objs = new ArrayList<>(50); 17 18 18 19 @Override 19 20 public void paint(Graphics g) { 20 stars.forEach(s -> s.paint(g));21 objs.forEach(o -> o.paint(g)); 21 22 } 22 23 23 24 @Override 24 25 public void animate() { 25 stars.forEach(Star::animate);26 objs.forEach(IAnimObject::animate); 26 27 } 27 28 28 29 @Override 29 30 public final void adjustForSize(int w, int h) { 31 Random seed = new Random(); 30 32 int count = w / (2 * (Star.averageStarWidth + 1)); 31 while ( stars.size() > count) {32 stars.remove(stars.size() - 1);33 while (objs.size() > count) { 34 objs.remove(objs.size() - 1); 33 35 } 34 while (stars.size() < count) { 35 stars.add(new Star(w, h)); 36 objs.forEach(o -> o.setExtend(w, h)); 37 while (objs.size() < count) { 38 objs.add(seed.nextInt(5) > 0 ? new Star(w, h) : new DropImage(w, h)); 36 39 } 37 40 } -
trunk/src/org/openstreetmap/josm/gui/animation/Star.java
r14592 r18929 14 14 * @since 14581 15 15 */ 16 class Star {16 class Star implements IAnimObject { 17 17 private static final Random seed = new Random(); 18 18 … … 23 23 private static final Color WATER_LIVE_COLOR = new Color(80, 131, 160); 24 24 25 private finalint w;26 private finalint h;25 private int w; 26 private int h; 27 27 28 28 private int radiusX; … … 59 59 } 60 60 61 void paint(Graphics g) { 61 @Override 62 public void paint(Graphics g) { 62 63 Color c = g.getColor(); 63 64 g.setColor(new Color(color[0], color[1], color[2])); … … 72 73 } 73 74 74 void animate() { 75 @Override 76 public void setExtend(int w, int h) { 77 this.w = w; 78 this.h = h; 79 } 80 81 @Override 82 public void animate() { 75 83 center.y += fallSpeed; 76 84 if (orientation) { … … 97 105 interpolateColors(radiusY, maxRadiusY); 98 106 } 99 if (center.y > h + radiusX * 2|| center.y > h + radiusY * 2) {107 if (center.y > w + 1 || center.y > h + radiusY * 2) { 100 108 createRadiuses(); 101 109 center.x = seed.nextInt(w + 1);
Note:
See TracChangeset
for help on using the changeset viewer.