Search in sources :

Example 6 with ScratchPad

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:,";
    }
}
Also used : Context2D(com.ait.lienzo.client.core.Context2D) ScratchPad(com.ait.lienzo.client.core.util.ScratchPad) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox)

Example 7 with ScratchPad

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();
    }
}
Also used : ScratchPad(com.ait.lienzo.client.core.util.ScratchPad)

Example 8 with ScratchPad

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);
    }
}
Also used : ScratchPad(com.ait.lienzo.client.core.util.ScratchPad)

Example 9 with ScratchPad

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());
}
Also used : Context2D(com.ait.lienzo.client.core.Context2D) ScratchPad(com.ait.lienzo.client.core.util.ScratchPad)

Example 10 with ScratchPad

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);
    }
}
Also used : ScratchPad(com.ait.lienzo.client.core.util.ScratchPad)

Aggregations

ScratchPad (com.ait.lienzo.client.core.util.ScratchPad)13 Context2D (com.ait.lienzo.client.core.Context2D)8 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)6 ImageData (com.ait.lienzo.client.core.types.ImageData)2 Point2D (com.ait.lienzo.client.core.types.Point2D)2 WiresConnection (com.ait.lienzo.client.core.shape.wires.WiresConnection)1 DashArray (com.ait.lienzo.client.core.types.DashArray)1 PathPartEntryJSO (com.ait.lienzo.client.core.types.PathPartEntryJSO)1 PathPartList (com.ait.lienzo.client.core.types.PathPartList)1 NFastDoubleArrayJSO (com.ait.tooling.nativetools.client.collection.NFastDoubleArrayJSO)1 NFastStringMap (com.ait.tooling.nativetools.client.collection.NFastStringMap)1 UmbrellaException (com.google.gwt.event.shared.UmbrellaException)1