Package com.emitrom.lienzo.client.core

Examples of com.emitrom.lienzo.client.core.Context2D


    public static final Color extract(String color)
    {
        s_canvas.clear();

        Context2D context = s_canvas.getContext();

        context.setFillColor(color);

        context.fillRect(0, 0, 2, 2);

        ImageData data = context.getImageData(0, 0, 2, 2);

        return new Color(data.getRedAt(1, 1), data.getGreenAt(1, 1), data.getBlueAt(1, 1), (((double) data.getAlphaAt(1, 1)) / 255.0));
    }
View Full Code Here


            m_element.setWidth(wide);

            m_element.setHeight(high);

            m_context = new Context2D(getNativeContext2D(m_element));
        }
        else
        {
            m_element = null;
View Full Code Here

        }
    }

    public final void clear()
    {
        Context2D context = getContext();

        if (null != context)
        {
            context.clearRect(0, 0, m_wide, m_high);
        }
    }
View Full Code Here

            {
                m_element = Document.get().createCanvasElement();
            }
            if (null == m_context)
            {
                m_context = new Context2D(getNativeContext2D(m_element));
            }
        }
        return m_element;
    }
View Full Code Here

                {
                    draw = m_olbd.onLayerBeforeDraw(this);
                }
                if (draw)
                {
                    Context2D context = getContext();

                    Transform transform = null;

                    if (isTransformable())
                    {
                        transform = getViewport().getTransform();
                    }
                    if (transform != null)
                    {
                        context.save();

                        context.transform(transform);
                    }
                    drawWithTransforms(context);

                    if (transform != null)
                    {
                        context.restore();
                    }
                    if (m_olad != null)
                    {
                        m_olad.onLayerAfterDraw(this);
                    }
                    if (isListening())
                    {
                        SelectionLayer selection = getSelectionLayer();

                        if (null != selection)
                        {
                            selection.clear();

                            context = selection.getContext();

                            if (transform != null)
                            {
                                context.save();

                                context.transform(transform);
                            }
                            drawWithTransforms(context);

                            if (transform != null)
                            {
                                context.restore();
                            }
                        }
                    }
                }
            }
View Full Code Here

                // Prepare the Image for the Selection Layer.
                // Get ImageData of the image by drawing it in a temporary canvas...

                ScratchCanvas scratch = new ScratchCanvas(m_destinationWidth, m_destinationHeight);

                Context2D context = scratch.getContext();

                context.drawImage(m_imageJSO, m_x, m_y, m_width, m_height, 0, 0, m_destinationWidth, m_destinationHeight);

                ImageData imageData = context.getImageData(0, 0, m_destinationWidth, m_destinationHeight);

                // Now draw the image again, replacing each color with the color key

                scratch.clear();

                Color rgb = Color.fromColorString(m_picture.getColorKey());

                context.putImageData(new RGBIgnoreAlphaImageDataFilter(rgb.getR(), rgb.getG(), rgb.getB()).filter(imageData, true), 0, 0);

                // Load the resulting image from the temporary canvas into the selection Image

                String dataURL = scratch.toDataURL();
View Full Code Here

        {
            return null;
        }
        ScratchCanvas scratch = new ScratchCanvas(m_destinationWidth, m_destinationHeight);

        Context2D context = scratch.getContext();

        context.drawImage(m_imageJSO, m_x, m_y, m_width, m_height, 0, 0, m_destinationWidth, m_destinationHeight);

        ImageData imageData = context.getImageData(0, 0, m_destinationWidth, m_destinationHeight);

        return imageData;
    }
View Full Code Here

        {
            return null;
        }
        ScratchCanvas scratch = new ScratchCanvas(m_destinationWidth, m_destinationHeight);

        Context2D context = scratch.getContext();

        context.drawImage(m_imageJSO, m_x, m_y, m_width, m_height, 0, 0, m_destinationWidth, m_destinationHeight);

        if (mimeType == null)
        {
            return scratch.toDataURL();
        }
View Full Code Here

     */
    public final ImageData copy()
    {
        ScratchCanvas scratch = new ScratchCanvas(getWidth(), getHeight());

        Context2D context = scratch.getContext();

        context.putImageData(this, 0, 0);

        return context.getImageData(0, 0, getWidth(), getHeight());
    }
View Full Code Here

    {
        if (false == m_virgin)
        {
            if (LienzoGlobals.getInstance().getLayerClearMode() == LayerClearMode.CLEAR)
            {
                Context2D context = getContext();

                if (null != context)
                {
                    context.clearRect(0, 0, m_wide, m_high);
                }
            }
            else
            {
                setPixelSize(m_wide, m_high);
View Full Code Here

TOP

Related Classes of com.emitrom.lienzo.client.core.Context2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.