PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/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/*
 2This file is part of Silex - see http://projects.silexlabs.org/?/silex
 3
 4Silex is Š 2010-2011 Silex Labs and is released under the GPL License:
 5
 6This 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. 
 7
 8This 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.
 9
10To read the license please visit http://www.gnu.org/copyleft/gpl.html
11*/
12package cocktail.domElement.js;
13
14import cocktail.nativeElement.NativeElement;
15import cocktail.domElement.abstract.AbstractImageDOMElement;
16
17/**
18 * This is the JavaScript implementation of the Image DOMElement.
19 * 
20 * @author Yannick DOMINUGEZ
21 */
22class ImageDOMElement extends AbstractImageDOMElement
23{
24
25	/**
26	 * This value smooth the bitmap
27	 */
28	private static inline var IMAGE_RENDERING_OPTIMIZE_QUALITY = "optimizeQuality";
29	
30	/**
31	 * This value doesn't smooth the bitmap
32	 */
33	private static inline var IMAGE_RENDERING_OPTIMIZE_SPEED = "optimizeSpeed";
34	
35	/**
36	 * class constructor
37	 */
38	public function new(nativeElement:NativeElement = null) 
39	{
40		super(nativeElement);
41	}
42	
43	//////////////////////////////////////////////////////////////////////////////////////////
44	// Overriden GETTER/SETTER
45	//////////////////////////////////////////////////////////////////////////////////////////
46	
47	/**
48	 * Override to use the CSS to smooth/unsmooth the bitmap
49	 * @param	value
50	 * @return
51	 */
52	override public function setSmooth(value:Bool):Bool
53	{
54		super.setSmooth(value);
55		
56		//set the CSS influencing image quality rendering
57		if (value == true)
58		{
59			untyped this._nativeElement.style.imageRendering = IMAGE_RENDERING_OPTIMIZE_QUALITY;
60		}
61		else
62		{
63			untyped this._nativeElement.style.imageRendering = IMAGE_RENDERING_OPTIMIZE_SPEED;
64		}
65		
66		return value;
67	}
68	
69}