This site requires JavaScript, please enable it in your browser!
Greenfoot back

Duta's Comments

Back to Duta's profile

DutaDuta

2012/1/23

Ah, you legend! :p I hadn't paid much attention to those lines >.< Its working now, I'll upload it soon - just going to comment some methods
DutaDuta

2012/1/23

I was kind of expecting this, but the repaint()ing makes the image flicker, and my method doesn't seem to be working as it just gives the magnifier a black image :/ Here's my code: private GreenfootImage getWorldImage() { getImage().clear(); getWorld().repaint(); JPanel panel = WorldHandler.getInstance().getWorldCanvas(); BufferedImage buff = new BufferedImage(panel.getWidth(), panel.getHeight(), BufferedImage.TYPE_INT_RGB); //Note: buff.getWidth() - 2 == getWorld().getWidth() // (and the same for height) // (I assume this is the 1 pixel thick border around the perimeter of the world) GreenfootImage img = new GreenfootImage(buff.getWidth() - 2, buff.getHeight() - 2); for(int x = 0; x < img.getWidth(); x++) { for(int y = 0; y < img.getHeight(); y++) { Color colour = new Color(buff.getRGB(x + 1, y + 1)); img.setColorAt(x, y, colour); } } return img; } I'm assuming its a problem with the line Color colour = new Color(etc) line...
DutaDuta

2012/1/23

Oh and then after that some code to translate it into a GreenfootImage
DutaDuta

2012/1/23

I was going to do something along the lines of: getImage().clear(); getWorld().repaint(); <the code you supplied>
DutaDuta

2012/1/23

Don't worry, I found it. Got supper now, but back to this afterwards :D
DutaDuta

2012/1/23

What import statement do I need for WorldHandler? I can't seem to find it anywhere...
DutaDuta

2012/1/23

Although that'd be amazing, it includes the magnify image itself (I might be wrong here, but I think that'd mean it'd be zoomed whatever the normal zoom is squared)... Actually I might have thought of a way round that. BRB :p (Major props if it works! - although it doesn't slow down the scenario at all on my computer - which only has a 3ghz processor - I'd noticed on slower computers it did)
DutaDuta

2012/1/23

That last update was a bug fix for rotated actor's support - before it was appearing to be cutting off the edges of rotated actors when they were magnified.
I like the effect, however I'm not going to switch from my Magnify scenario because I looked in the source code for this and there's code in like all the classes, rather than just one self-contained class, and there doesn't seem to be much abstraction :/ I might look into re-creating the effect myself if I have the time :) Not going to take the code from this scenario 'cause if I did it'd be no fun :p Oh and also you might want to add support for actors - at the moment if you add an actor to the world it just acts like the actor isn't there. Hopefully you update this because like I said I think the fish-eye like effect is really good.