Search in sources :

Example 1 with CanvasRenderingContext2D

use of com.gargoylesoftware.htmlunit.javascript.host.canvas.CanvasRenderingContext2D in project htmlunit by HtmlUnit.

the class HTMLCanvasElement method getContext.

/**
 * Gets the context.
 * @param contextId the context id
 * @return Returns an object that exposes an API for drawing on the canvas,
 * or null if the given context ID is not supported
 */
@JsxFunction
public Object getContext(final String contextId) {
    if ("2d".equals(contextId)) {
        if (context2d_ == null) {
            final CanvasRenderingContext2D context = new CanvasRenderingContext2D(this);
            context.setParentScope(getParentScope());
            context.setPrototype(getPrototype(context.getClass()));
            context2d_ = context;
        }
        return context2d_;
    }
    return null;
}
Also used : CanvasRenderingContext2D(com.gargoylesoftware.htmlunit.javascript.host.canvas.CanvasRenderingContext2D) JsxFunction(com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)

Aggregations

JsxFunction (com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)1 CanvasRenderingContext2D (com.gargoylesoftware.htmlunit.javascript.host.canvas.CanvasRenderingContext2D)1