public HtmlImage(GLContext ctx, Scale scale, CanvasElement img) { super(ctx, scale); this.canvas = img; fakeComplete(img); this.img = img.cast(); }
@Override protected Pattern toSubPattern(AbstractImageGL<?> image, boolean repeatX, boolean repeatY, float x, float y, float width, float height) { CanvasElement canvas = Document.get().createElement("canvas").<CanvasElement>cast(); canvas.setWidth(MathUtil.iceil(width)); canvas.setHeight(MathUtil.iceil(height)); canvas.getContext2d().drawImage(img, x, y, width, height, 0, 0, width, height); ImageElement subelem = canvas.cast(); return new HtmlPattern(image, subelem, repeatX, repeatY); }
@Override public void draw() { super.draw(); if (surfaceElement == null) { surfaceElement = Document.get().createCanvasElement().cast(); getCanvas().setWidth(width); getCanvas().setHeight(height); container.appendChild(surfaceElement); } getContext().clearRect(0, 0, width, height); //TODO only sort, clear, re-render modified sprites (where they were, where they are) //as a test to see if that gives us a bump in speed Collections.sort(sprites, zIndexComparator()); //collect viewbox if (component.isViewBox()) { int temp = sprites.indexOf(backgroundSprite); sprites.remove(temp); PreciseRectangle bbox = sprites.getBBox(); sprites.add(temp, backgroundSprite); setViewBox(bbox.getX(), bbox.getY(), bbox.getWidth(), bbox.getHeight()); backgroundSprite.setWidth(bbox.getWidth()); backgroundSprite.setHeight(bbox.getHeight()); } appendAll(); } /**