The AS3 Magnifying Glass is a lense refraction class employing PixelBender. The class is an encapsulated method that takes a source image, a position and radius and returns a refracted result in sprite form.
I needed to represent a spy glass in my current project, and was looking for a very efficient method to achieve this. PixelBender seemed the obvious route and I’m pretty impressed by the speeds I am getting. I have max-ed out the frame rate and am still getting full (120) fps.
The MagnifyingGlass effect is the resultant class. The class embeds a pixelbender filter that spherizes it’s input and returns this as a sprite.
When using the class, the source image should be sent to the MagnifyingGlass full size, and be displayed to the user at a reduced size. This helps to preserve the integrity of the refracted image.
Usage:
//refraction: 0=Lots, 1 =None
//radius: The radius of the magnifying glass
//position_point: The position of the magnifying glass on the source image
//source_pic: BitmapData of the source picture
magnifying_glass = new MagnifyingGlass(refraction,radius, posn_point, source_pic)magnifying_glass.magnifyingGlassPosition=posn_point
magnifying_glass.update()
I have set up a quick demo that shows the class at work on 3 different images. Press any key to change the image.
Image#1: Have a look around a bit of England & Wales. Enjoy.
Image#2: Hundreds of cartoon characters. See if you can find Quagmire! – Gigity.
Image#3: There is a sheep in there somewhere.
NOTE: The PixelBender filter used here is based on Joa Ebert’s Spherize Filter originally built in Hydra – the forerunner of PixelBender.
NOTE: This requires Flash Player 10 and above.
Demo: Magnifying Glass Class Demo
Source: MagnifyingGlass.zip
hey, just found your article after posting mine. heck, that should read: found your blog! any way, your source link is broken 🙂
Makc, Thanks for spotting my school-boy cut & paste error. The link to the source zip is now working =-)
I look inside zip and see no pbk there. I put on my robe and wizard hat, cast level 90 teleportation spell, and missing source magically appears on Joa Ebert site 😀
Awesome. I’ve had the filter knocking around for ages – long ago the pbj must have got parted from the pbk. I’d totally forgotten where it had come from.
If you can give me the link I’ll post it and give Joa proper credit for the pixelbender work.
I just found it few days ago – the word “refraction” gave it away (as well as “popforge” in pbj). It’s in obsolete language (hydra) but with minor voodoo it is possible to get working pbk.
Hi,

Thank you very much for sharing that wonderful source.
I’ve searched a long time in order to reproduce that effect.
I use it on a spherical snowglobe, with dynamic background picture uploded by users.
It works, but I would like to try the opposite effect : A concave effect.
have a look at this :
I can’t figure how to do it, I tried a negative refraction, but no way.
Maybe I need a new pixel bender object?
thank you
best regards
saturnino
Hey, is there a way to use this effect on every object on the stage?
Nice! More PB filters:
http://www.randomfractals.com/lab/SlenderPixelBender/SlenderPixelBender.html
http://blogs.adobe.com/kevin-goldsmith/