List of usage examples for com.google.gwt.canvas.dom.client Context2d setShadowBlur
public final native void setShadowBlur(double shadowBlur) ;
From source file:com.lambourg.webgallery.client.widgets.TitleBarIcon.java
License:GNU General Public License
private void draw() { Context2d ctx; Canvas buffer = Canvas.createIfSupported(); Image img;/* w ww . j av a 2s. c om*/ int size = Style.toPixelRatio(Style.titleIconSize); this.canvas.setCoordinateSpaceWidth(size); this.canvas.setCoordinateSpaceHeight(size + Style.toPixelRatio(1)); buffer.setCoordinateSpaceWidth(size); buffer.setCoordinateSpaceHeight(size); if (this.active) { img = this.imgActive; } else { img = this.imgNormal; } // We need to draw the icon itself in a separate buffer, and only // after apply the shadow. // The reason is that in order to draw the icon using the color we // want, we need to use composite operations, and this is not // compatible with the shadow effect we want. ctx = buffer.getContext2d(); if (this.over) { ctx.setFillStyle("#fff"); } else { ctx.setFillStyle("#ddd"); } ctx.fillRect(0, 0, size, size); ctx.setGlobalCompositeOperation(Composite.DESTINATION_ATOP); ctx.drawImage(ImageElement.as(img.getElement()), 0, 0, size, size); ctx.restore(); ctx = this.canvas.getContext2d(); ctx.setShadowBlur(0.0); ctx.setShadowColor("#333"); ctx.setShadowOffsetY(Style.toPixelRatio(1)); ctx.drawImage(buffer.getCanvasElement(), 0, 0, size, size); }