use of com.ait.lienzo.client.core.util.ScratchPad in project lienzo-core by ahome-it.
the class Scene method toDataURL.
// package protected
final String toDataURL(final Layer background) {
if (LienzoCore.IS_CANVAS_SUPPORTED) {
final ScratchPad scratch = new ScratchPad(getWidth(), getHeight());
final Context2D context = scratch.getContext();
final NFastArrayList<Layer> layers = getChildNodes();
BoundingBox bbox = getStorageBounds();
if (null == bbox) {
final Viewport viewport = getViewport();
if (null != viewport) {
bbox = viewport.getStorageBounds();
}
}
if (null != layers) {
final int size = layers.size();
if (null != background) {
background.drawWithTransforms(context, 1, bbox);
}
final IPathClipper clip = getPathClipper();
if ((null != clip) && (clip.isActive())) {
context.save();
clip.clip(context);
}
for (int i = size - 1; i >= 0; i--) {
final Layer layer = layers.get(i);
if ((null != layer) && (layer.isVisible())) {
layer.drawWithTransforms(context, 1, bbox);
}
}
if ((null != clip) && (clip.isActive())) {
context.restore();
}
}
return scratch.toDataURL();
} else {
return "data:,";
}
}
use of com.ait.lienzo.client.core.util.ScratchPad in project lienzo-core by ahome-it.
the class ImageProxy method toDataURL.
/**
* Returns the "data:" URL
*
* @param mimeType If null, defaults to DataURLType.PNG
* @return String
*/
public String toDataURL(final boolean filtered) {
if (false == isLoaded()) {
return null;
}
if ((m_fastout) || (false == filtered)) {
final ScratchPad temp = new ScratchPad(m_jsimg.getWidth(), m_jsimg.getHeight());
temp.getContext().drawImage(m_jsimg, 0, 0);
return temp.toDataURL();
} else {
return m_filterImage.toDataURL();
}
}
use of com.ait.lienzo.client.core.util.ScratchPad in project lienzo-core by ahome-it.
the class WiresConnectionControlImpl method showMagnets.
private void showMagnets(final WiresShape prim) {
m_magnets = null != prim ? prim.getMagnets() : null;
if (m_magnets != null) {
m_magnets.show();
final ScratchPad scratch = m_manager.getLayer().getLayer().getScratchPad();
m_magnetsBacking = m_manager.getMagnetManager().drawMagnetsToBack(m_magnets, m_shape_color_map, m_magnet_color_map, scratch);
}
}
use of com.ait.lienzo.client.core.util.ScratchPad in project lienzo-core by ahome-it.
the class ImageData method copy.
/**
* ImageData can't be cloned or deep-copied, it's an internal data structure and has some CRAZY crap in it, this is cheeeeeezy, but hey, it works, and it's portable!!!
*/
public final ImageData copy() {
final Context2D context = new ScratchPad(getWidth(), getHeight()).getContext();
context.putImageData(this, 0, 0);
return context.getImageData(0, 0, getWidth(), getHeight());
}
use of com.ait.lienzo.client.core.util.ScratchPad in project lienzo-core by ahome-it.
the class ImageProxy method getImageData.
/**
* Returns an ImageData object that can be used for further image processing
* e.g. by image filters.
*
* @return ImageData
*/
public ImageData getImageData() {
if (false == isLoaded()) {
return null;
}
if (m_fastout) {
final ScratchPad temp = new ScratchPad(m_dest_wide, m_dest_high);
temp.getContext().drawImage(m_jsimg, m_clip_xpos, m_clip_ypos, m_clip_wide, m_clip_high, 0, 0, m_dest_wide, m_dest_high);
return temp.getContext().getImageData(0, 0, m_dest_wide, m_dest_high);
} else {
return m_filterImage.getContext().getImageData(0, 0, m_dest_wide, m_dest_high);
}
}
Aggregations