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

Report as inappropriate.

SPower
SPower presents ...

2013/10/15

Magnifier demo

This is a little demo for my implementation of a magnifier, which is quite memory efficient and fast.

The files you need to copy are the Magnifier class and the Magnifiable interface. For an actor to be magnified by the Magnifier, it must implement the Magnifiable interface. The world where you use the Magnifier must also have this line:
setPaintOrder(Magnifier.class);
in its constructor.

A magnifier is created with 4 arguments: width, height, scale and doesRotation. The first 3 are obvious, but the fourth needs a little explanation. When doesRotation is false, the magnifier will pay no attention to the rotation of actors (i.e. it draws their images with rotation 0). This will improve performance, so use this ability when possible.

In this demo, the magnifier follows the movement of your mouse cursor. The bugs are added at random locations.

3673 views / 15 in the last 7 days

2 votes | 0 in the last 7 days

Tags: demo with-source magnifier

This scenario is a member of: Reusable actors & support classes


open in greenfoot
Your browser does not support the canvas tag.
A new version of this scenario was uploaded on Tue Oct 15 14:31:07 UTC 2013 -Added a new argument to the magnifier class: doesRotation. If this is set to false, the magnifier will pay no attention to the rotation of the actors and the speed will be greatly improved. -Improved the code a little bit. -The scenario now creates 100 bugs
A new version of this scenario was uploaded on Tue Oct 15 14:45:23 UTC 2013 -Changed the way the Magnifier class works: it's much faster now
A new version of this scenario was uploaded on Tue Oct 15 15:06:03 UTC 2013 -Speed improvement
A new version of this scenario was uploaded on Tue Oct 15 15:12:50 UTC 2013 -Little change to the Magnifier class
A new version of this scenario was uploaded on Tue Oct 15 15:17:40 UTC 2013 -Bug fix
A new version of this scenario was uploaded on Tue Oct 15 16:29:44 UTC 2013 -Memory improvements -Added some comments in Magnifier to make it more understandable

Want to leave a comment? You must first log in.

Who likes this?

nightwingx13 Entity1037