canvas.setWindowTitle("Image Render Demo");
System.out.println("created");
final Image campfire = canvas.getImageFactory().createImage(
ModeChangeDemo.class.getResource("/sprites/campfire.png"), false);
final Image animLeftImage = canvas.getImageFactory().createImage(
ModeChangeDemo.class.getResource("/sprites/Crono - Walk (Left) 44x68.png"), false);
final Image animFrontImage = canvas.getImageFactory().createImage(
ModeChangeDemo.class.getResource("/sprites/Crono - Walk (Front) 40x70.png"), false);
final Image animBackImage = canvas.getImageFactory().createImage(
ModeChangeDemo.class.getResource("/sprites/Crono - Walk (Back) 36x70.png"), false);
final Image leftImage = canvas.getImageFactory().createImage(
ModeChangeDemo.class.getResource("/sprites/Crono (Left).png"), false);
final Image frontImage = canvas.getImageFactory().createImage(
ModeChangeDemo.class.getResource("/sprites/Crono (Front).png"), false);
final Image backImage = canvas.getImageFactory().createImage(
ModeChangeDemo.class.getResource("/sprites/Crono (Back).png"), false);
final Image grass = canvas.getImageFactory().createImage(
ModeChangeDemo.class.getResource("/sprites/grass.png"), false);
final Shape circle = ShapeFactory.createCircle(30, 25);
final Shape circularArc = ShapeFactory.createCircularArc(30, -135, 135, 25);
// final Shape ellipse = ShapeFactory.createEllipse(75, 25, 25);
final Shape ellipse = ShapeFactory.createRoundedRectangle(120, 70, 25);
final Shape ellipsoidalArc = ShapeFactory.createEllipsoidalArc(75, 25, 45, 315, 25);
// final Shape rectangle = ShapeFactory.createRectangle(75, 25, false, false);
List<Vector2f> rectOut = new ArrayList<Vector2f>();
rectOut.add(new Vector2f(40, 10));
rectOut.add(new Vector2f(-40, 10));
rectOut.add(new Vector2f(-40, -10));
rectOut.add(new Vector2f(40, -10));
List<Vector2f> rectIn = new ArrayList<Vector2f>();
rectIn.add(new Vector2f(20, 5));
rectIn.add(new Vector2f(-20, 5));
rectIn.add(new Vector2f(-20, -5));
rectIn.add(new Vector2f(20, -5));
List<List<Vector2f>> rectIns = new ArrayList<List<Vector2f>>();
rectIns.add(rectIn);
final Shape rectangle = ShapeCreator.create(rectOut, rectIns);
final Image dark = canvas.getImageFactory().createImage(128, 128, true);
final Image darktest = canvas.getImageFactory().createImage(128, 128, true);
// final Image dark = canvas.getImageFactory().createBufferedImage(128, 128, BufferTypes.RGBA_4Byte);
final Image gradient = canvas.getImageFactory().createBufferedImage(256, 256, BufferTypes.RGBA_4Byte);
final Image light = canvas.getImageFactory().createBufferedImage(128, 128, BufferTypes.RGBA_4Byte);
ResourceManager rm = canvas.getResourceManager();
rm.cacheImage(dark);
rm.cacheImage(campfire);
rm.cacheImage(animLeftImage);
rm.cacheImage(animFrontImage);
rm.cacheImage(animBackImage);
rm.cacheImage(leftImage);
rm.cacheImage(frontImage);
rm.cacheImage(backImage);
rm.cacheImage(grass);
final Animation<Frame> animLeft = new AnimationImpl<Frame>();
animLeft.addFrame(new FrameImpl(animLeftImage, 160000000, 0, 0, 44, 68));
animLeft.addFrame(new FrameImpl(animLeftImage, 160000000, 45, 0, 44, 68));
animLeft.addFrame(new FrameImpl(animLeftImage, 160000000, 90, 0, 44, 68));
animLeft.addFrame(new FrameImpl(animLeftImage, 160000000,135, 0, 44, 68));
animLeft.addFrame(new FrameImpl(animLeftImage, 160000000,180, 0, 44, 68));
animLeft.addFrame(new FrameImpl(animLeftImage, 160000000,225, 0, 44, 68));
animLeft.setRepeated(true);
final Animation<Frame> animFront = new AnimationImpl<Frame>();
animFront.addFrame(new FrameImpl(animFrontImage, 160000000, 0, 0, 40, 70));
animFront.addFrame(new FrameImpl(animFrontImage, 160000000, 41, 0, 40, 70));
animFront.addFrame(new FrameImpl(animFrontImage, 160000000, 82, 0, 40, 70));
animFront.addFrame(new FrameImpl(animFrontImage, 160000000,123, 0, 40, 70));
animFront.addFrame(new FrameImpl(animFrontImage, 160000000,164, 0, 40, 70));
animFront.addFrame(new FrameImpl(animFrontImage, 160000000,205, 0, 40, 70));
animFront.setRepeated(true);
final Animation<Frame> animLeftStill = new AnimationImpl<Frame>();
animLeftStill.addFrame(new FrameImpl(leftImage, 160000000, 0, 0, 28, 68));
animLeftStill.setRepeated(true);
final Animation<Frame> animFrontStill = new AnimationImpl<Frame>();
animFrontStill.addFrame(new FrameImpl(frontImage, 160000000, 0, 0, 32, 70));
animFrontStill.setRepeated(true);
final Animation<Frame> animBackStill = new AnimationImpl<Frame>();
animBackStill.addFrame(new FrameImpl(backImage, 160000000, 0, 0, 32, 66));
animBackStill.setRepeated(true);
final Animation<Frame> animBack = new AnimationImpl<Frame>();
animBack.addFrame(new FrameImpl(animBackImage, 160000000, 0, 0, 36, 70));
animBack.addFrame(new FrameImpl(animBackImage, 160000000, 37, 0, 36, 70));
animBack.addFrame(new FrameImpl(animBackImage, 160000000, 74, 0, 36, 70));
animBack.addFrame(new FrameImpl(animBackImage, 160000000,111, 0, 36, 70));
animBack.addFrame(new FrameImpl(animBackImage, 160000000,148, 0, 36, 70));
animBack.addFrame(new FrameImpl(animBackImage, 160000000,185, 0, 36, 70));
animBack.setRepeated(true);
final Animation<Frame> animFire = new AnimationImpl<Frame>();
animFire.addFrame(new FrameImpl(campfire, 120000000,1, 1, 64, 80));
animFire.addFrame(new FrameImpl(campfire, 120000000, 66, 1, 64, 80));
animFire.addFrame(new FrameImpl(campfire, 120000000, 131, 1, 64, 80));
animFire.addFrame(new FrameImpl(campfire, 120000000,196, 1, 64, 80));
animFire.setRepeated(true);
// final Color4f red = new Color4f(1,0,0,1);
final Color4f white = new Color4f(1,1,1,1);
ColorGradientFactory gradientFactory = new ColorGradientFactory();
gradientFactory.addSourceSegment(50, 0, 50, 255, 150, new Color4f(1, 0, 0, 1));
gradientFactory.addSourceSegment(205, 0, 205, 255,150, new Color4f(0, 0, 1, 1));
// gradientFactory.addSourceSegment(0, 0, 0, 255, 256, new Color4f(0, 0, 0, 1));
// gradientFactory.addSourceSegment(255, 0, 255, 255, 256, new Color4f(1, 1, 1, 1));
gradientFactory.drawGradient(gradient);
// gradient.setDirty();
gradientFactory.clearSources();
gradientFactory.addSourcePoint(light.getWidth() / 2, light.getHeight() / 2, light.getWidth() / 2f * .9f, new Color4f(0,0,0,0));
gradientFactory.setBaseColor(new Color4f(1,1,1,1));
gradientFactory.drawGradient(light);
// gradientFactory.addSourceSegment(0, 0, 255, 255, new Color4f(1, 1, 1, 1));
// rm.cacheImage(gradient);