/src/cocktail/domElement/js/ImageDOMElement.hx

http://github.com/silexlabs/Cocktail · Haxe · 69 lines · 25 code · 10 blank · 34 comment · 2 complexity · 90577e90f91b00f6c7d7b8993cea9f08 MD5 · raw file

  1. /*
  2. This file is part of Silex - see http://projects.silexlabs.org/?/silex
  3. Silex is Š 2010-2011 Silex Labs and is released under the GPL License:
  4. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
  5. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  6. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  7. */
  8. package cocktail.domElement.js;
  9. import cocktail.nativeElement.NativeElement;
  10. import cocktail.domElement.abstract.AbstractImageDOMElement;
  11. /**
  12. * This is the JavaScript implementation of the Image DOMElement.
  13. *
  14. * @author Yannick DOMINUGEZ
  15. */
  16. class ImageDOMElement extends AbstractImageDOMElement
  17. {
  18. /**
  19. * This value smooth the bitmap
  20. */
  21. private static inline var IMAGE_RENDERING_OPTIMIZE_QUALITY = "optimizeQuality";
  22. /**
  23. * This value doesn't smooth the bitmap
  24. */
  25. private static inline var IMAGE_RENDERING_OPTIMIZE_SPEED = "optimizeSpeed";
  26. /**
  27. * class constructor
  28. */
  29. public function new(nativeElement:NativeElement = null)
  30. {
  31. super(nativeElement);
  32. }
  33. //////////////////////////////////////////////////////////////////////////////////////////
  34. // Overriden GETTER/SETTER
  35. //////////////////////////////////////////////////////////////////////////////////////////
  36. /**
  37. * Override to use the CSS to smooth/unsmooth the bitmap
  38. * @param value
  39. * @return
  40. */
  41. override public function setSmooth(value:Bool):Bool
  42. {
  43. super.setSmooth(value);
  44. //set the CSS influencing image quality rendering
  45. if (value == true)
  46. {
  47. untyped this._nativeElement.style.imageRendering = IMAGE_RENDERING_OPTIMIZE_QUALITY;
  48. }
  49. else
  50. {
  51. untyped this._nativeElement.style.imageRendering = IMAGE_RENDERING_OPTIMIZE_SPEED;
  52. }
  53. return value;
  54. }
  55. }