javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/GraphicsContext.java
author toni.epple@eppleton.de
Tue, 21 May 2013 16:10:52 +0200
branchcanvas
changeset 1125 a3d504d7e588
parent 1122 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5GraphicsContext.java@f5f15ac48ea8
permissions -rw-r--r--
Refactored names to unpopular naming scheme, because (a) bck2brwsr Canvas implementation must be named Canvas due to mapping in bck2brwsr and I don't want interface and impl to have the same name. (b) with the "I" prefix at least it's consistent, even if nobody uses that anymore. (c) names are the same as in HTML5 Canvas Javascript API, so it's more familiar...
toni@1111
     1
/**
toni@1111
     2
 * Back 2 Browser Bytecode Translator Copyright (C) 2012 Jaroslav Tulach
toni@1111
     3
 * <jaroslav.tulach@apidesign.org>
toni@1111
     4
 *
toni@1111
     5
 * This program is free software: you can redistribute it and/or modify it under
toni@1111
     6
 * the terms of the GNU General Public License as published by the Free Software
toni@1111
     7
 * Foundation, version 2 of the License.
toni@1111
     8
 *
toni@1111
     9
 * This program is distributed in the hope that it will be useful, but WITHOUT
toni@1111
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
toni@1111
    11
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
toni@1111
    12
 * details.
toni@1111
    13
 *
toni@1111
    14
 * You should have received a copy of the GNU General Public License along with
toni@1111
    15
 * this program. Look for COPYING file in the top folder. If not, see
toni@1111
    16
 * http://opensource.org/licenses/GPL-2.0.
toni@521
    17
 */
toni@1112
    18
package org.apidesign.bck2brwsr.htmlpage.api;
toni@521
    19
toni@1125
    20
toni@1125
    21
import net.java.html.canvas.IGraphicsContext;
toni@1125
    22
import net.java.html.canvas.IImage;
toni@1125
    23
import net.java.html.canvas.IImageData;
toni@1125
    24
import net.java.html.canvas.ILinearGradient;
toni@1125
    25
import net.java.html.canvas.IPattern;
toni@1125
    26
import net.java.html.canvas.IRadialGradient;
toni@1125
    27
import net.java.html.canvas.ITextMetrics;
toni@521
    28
import org.apidesign.bck2brwsr.core.JavaScriptBody;
toni@521
    29
toni@1125
    30
toni@521
    31
/**
toni@521
    32
 *
toni@1112
    33
 * @author Anton Epple <toni.epple@eppleton.de>
toni@521
    34
 */
toni@1125
    35
public class GraphicsContext implements IGraphicsContext {
toni@521
    36
toni@1112
    37
    Object context;
toni@1112
    38
toni@1125
    39
    GraphicsContext(Object contextImpl) {
toni@1112
    40
        this.context = contextImpl;
toni@1112
    41
    }
toni@1112
    42
toni@1112
    43
    @JavaScriptBody(args = {"centerx", "centery", "radius", "startangle", "endangle", "ccw"},
toni@1112
    44
            body = "this._context().arc(centerx,centery, radius, startangle, endangle,ccw);")
toni@1112
    45
    @Override
toni@1112
    46
    public native void arc(double centerX,
toni@1111
    47
            double centerY,
toni@1111
    48
            double startAngle,
toni@1111
    49
            double radius,
toni@1111
    50
            double endAngle,
toni@1111
    51
            boolean ccw);
toni@521
    52
toni@1112
    53
    @JavaScriptBody(args = {"x1", "y1", "x2", "y2", "r"},
toni@1112
    54
            body = "this._context().arcTo(x1,y1,x2,y2,r);")
toni@1112
    55
    @Override
toni@1112
    56
    public native void arcTo(double x1,
toni@1111
    57
            double y1,
toni@1111
    58
            double x2,
toni@1111
    59
            double y2,
toni@1111
    60
            double r);
toni@521
    61
toni@1112
    62
    @JavaScriptBody(args = {"x", "y"},
toni@1112
    63
            body = "return this._context().isPointInPath(x,y);")
toni@1112
    64
    @Override
toni@1112
    65
    public native boolean isPointInPath(double x, double y);
toni@521
    66
toni@1112
    67
    @JavaScriptBody(args = {}, body = "this._context().fill();")
toni@1112
    68
    @Override
toni@1112
    69
    public native void fill();
toni@521
    70
toni@1112
    71
    @JavaScriptBody(args = {}, body = "this._context().stroke();")
toni@1112
    72
    @Override
toni@1112
    73
    public native void stroke();
toni@1109
    74
toni@1112
    75
    @JavaScriptBody(args = {}, body = "this._context().beginPath();")
toni@1112
    76
    @Override
toni@1112
    77
    public native void beginPath();
toni@1109
    78
toni@1112
    79
    @JavaScriptBody(args = {}, body = "this._context().closePath();")
toni@1112
    80
    @Override
toni@1112
    81
    public native void closePath();
toni@521
    82
toni@1112
    83
    @JavaScriptBody(args = {}, body = "this._context().clip();")
toni@1112
    84
    @Override
toni@1112
    85
    public native void clip();
toni@1109
    86
toni@1112
    87
    @JavaScriptBody(args = {"x", "y"}, body = "this._context().moveTo(x,y);")
toni@1112
    88
    @Override
toni@1112
    89
    public native void moveTo(double x, double y);
toni@1109
    90
toni@1112
    91
    @JavaScriptBody(args = {"x", "y"}, body = "this._context().lineTo(x,y);")
toni@1112
    92
    @Override
toni@1112
    93
    public native void lineTo(double x, double y);
toni@1109
    94
toni@1112
    95
    @JavaScriptBody(args = {"cpx", "cpy", "x", "y"}, body = "this._context().quadraticCurveTo(cpx,cpy,x,y);")
toni@1112
    96
    @Override
toni@1112
    97
    public native void quadraticCurveTo(double cpx, double cpy, double x, double y);
toni@1109
    98
toni@1112
    99
    @JavaScriptBody(args = {"cp1x", "cp1y", "cp2x", "cp2y", "x", "y"},
toni@1112
   100
            body = "this._context().bezierCurveTo(cp1x,cp1y,cp2x,cp2y,x,y);")
toni@1112
   101
    @Override
toni@1112
   102
    public native void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
toni@1109
   103
toni@1112
   104
    @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().fillRect(x,y,width,height);")
toni@1112
   105
    @Override
toni@1112
   106
    public native void fillRect(double x, double y, double width, double height);
toni@1109
   107
toni@1112
   108
    @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().strokeRect(x,y,width,height);")
toni@1112
   109
    @Override
toni@1112
   110
    public native void strokeRect(double x, double y, double width, double height);
toni@1109
   111
toni@1112
   112
    @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().clearRect(x,y,width,height);")
toni@1112
   113
    @Override
toni@1112
   114
    public native void clearRect(double x, double y, double width, double height);
toni@1109
   115
toni@1112
   116
    @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().rectect(x,y,width,height);")
toni@1112
   117
    @Override
toni@1112
   118
    public native void rect(double x, double y, double width, double height);
toni@1109
   119
toni@1112
   120
    @JavaScriptBody(args = {}, body = "this._context().save();")
toni@1112
   121
    @Override
toni@1112
   122
    public native void save();
toni@1109
   123
toni@1112
   124
    @JavaScriptBody(args = {}, body = "this._context().restore();")
toni@1112
   125
    @Override
toni@1112
   126
    public native void restore();
toni@1109
   127
toni@1112
   128
    @JavaScriptBody(args = {"angle"}, body = "this._context().rotate(angle);")
toni@1112
   129
    @Override
toni@1112
   130
    public native void rotate(double angle);
toni@1109
   131
toni@1112
   132
    @JavaScriptBody(args = {"a", "b", "c", "d", "e", "f"}, body = "this._context().transform(a,b,c,d,e,f);")
toni@1112
   133
    @Override
toni@1112
   134
    public native void transform(double a, double b, double c, double d, double e, double f);
toni@1109
   135
toni@1112
   136
    @JavaScriptBody(args = {"a", "b", "c", "d", "e", "f"}, body = "this._context().setTransform(a,b,c,d,e,f);")
toni@1112
   137
    @Override
toni@1112
   138
    public native void setTransform(double a, double b, double c, double d, double e, double f);
toni@1109
   139
toni@1112
   140
    @JavaScriptBody(args = {"x", "y"}, body = "this._context().translate(x,y);")
toni@1112
   141
    @Override
toni@1112
   142
    public native void translate(double x, double y);
toni@1109
   143
toni@1112
   144
    @JavaScriptBody(args = {"x", "y"}, body = "this._context().scale(x,y);")
toni@1112
   145
    @Override
toni@1112
   146
    public native void scale(double x, double y);
toni@1109
   147
toni@1112
   148
    @Override
toni@1125
   149
    public void drawImage(IImage image, double x, double y) {
toni@1125
   150
        drawImageImpl(context, Element.getElementById((Image) image), x, y);
toni@1112
   151
    }
toni@1109
   152
toni@1112
   153
    @Override
toni@1125
   154
    public void drawImage(IImage image, double x, double y, double width, double height) {
toni@1125
   155
        drawImageImpl(context, Element.getElementById((Image) image), x, y, width, height);
toni@1112
   156
    }
toni@1109
   157
toni@1112
   158
    @Override
toni@1125
   159
    public void drawImage(IImage image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height) {
toni@1125
   160
        drawImageImpl(context, Element.getElementById((Image) image), sx, sy, sWidth, sHeight, x, y, width, height);
toni@1112
   161
    }
toni@1109
   162
toni@1112
   163
    @JavaScriptBody(args = {"ctx", "img", "x", "y", "width", "height"}, body = "ctx.drawImage(img,x,y,width,height);")
toni@1112
   164
    private native static void drawImageImpl(Object ctx, Object img, double x, double y, double width, double height);
toni@1109
   165
toni@1112
   166
    @JavaScriptBody(args = {"ctx", "img", "sx", "sy", "swidth", "sheight", "x", "y", "width", "height"}, body = "ctx.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);")
toni@1112
   167
    private native static void drawImageImpl(Object ctx, Object img, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height);
toni@1109
   168
toni@1112
   169
    @JavaScriptBody(args = {"ctx", "img", "x", "y"}, body = "ctx.drawImage(img,x,y);")
toni@1112
   170
    private native static void drawImageImpl(Object ctx, Object img, double x, double y);
toni@1109
   171
toni@1112
   172
    @JavaScriptBody(args = {"style"}, body = "this._context().fillStyle=style.valueOf();")
toni@1112
   173
    @Override
toni@1112
   174
    public native void setFillStyle(String style);
toni@1109
   175
toni@1112
   176
    @JavaScriptBody(args = {}, body = "return this._context().fillStyle;")
toni@1112
   177
    @Override
toni@1112
   178
    public native String getFillStyle();
toni@1109
   179
toni@1112
   180
    @Override
toni@1125
   181
    public void setFillStyle(ILinearGradient style) {
toni@1125
   182
        setFillStyleImpl(context, ((LinearGradient) style).object());
toni@1112
   183
    }
toni@1109
   184
toni@1112
   185
    @Override
toni@1125
   186
    public void setFillStyle(IRadialGradient style) {
toni@1125
   187
        setFillStyleImpl(context, ((RadialGradient) style).object());
toni@1112
   188
    }
toni@1109
   189
toni@1112
   190
    @Override
toni@1125
   191
    public void setFillStyle(IPattern style) {
toni@1125
   192
        setFillStyleImpl(context, ((Pattern) style).object());
toni@1112
   193
    }
toni@1109
   194
toni@1112
   195
    @JavaScriptBody(args = {"context", "obj"}, body = "context.fillStyle=obj;")
toni@1112
   196
    private native void setFillStyleImpl(Object context, Object obj);
toni@1109
   197
toni@1112
   198
    @JavaScriptBody(args = {"style"}, body = "this._context().strokeStyle=style.valueOf();")
toni@1112
   199
    @Override
toni@1112
   200
    public native void setStrokeStyle(String style);
toni@1109
   201
toni@1112
   202
    @Override
toni@1125
   203
    public void setStrokeStyle(ILinearGradient style) {
toni@1125
   204
        setStrokeStyleImpl(context, ((LinearGradient) style).object());
toni@1112
   205
    }
toni@1109
   206
toni@1117
   207
    @Override
toni@1125
   208
    public void setStrokeStyle(IRadialGradient style) {
toni@1125
   209
        setStrokeStyleImpl(context, ((RadialGradient) style).object());
toni@1112
   210
    }
toni@1109
   211
toni@1112
   212
    @JavaScriptBody(args = {"style"}, body = "this._context().fillStyle=style;")
toni@1112
   213
    @Override
toni@1125
   214
    public void setStrokeStyle(IPattern style) {
toni@1125
   215
        setStrokeStyleImpl(context, ((LinearGradient) style).object());
toni@1112
   216
    }
toni@1109
   217
toni@1112
   218
    @JavaScriptBody(args = {"context", "obj"}, body = "context.strokeStyle=obj;")
toni@1112
   219
    private native void setStrokeStyleImpl(Object context, Object obj);
toni@1109
   220
toni@1112
   221
    @JavaScriptBody(args = {"color"}, body = "this._context().shadowColor=color.valueOf();")
toni@1112
   222
    @Override
toni@1112
   223
    public native void setShadowColor(String color);
toni@1109
   224
toni@1112
   225
    @JavaScriptBody(args = {"blur"}, body = "this._context().shadowBlur=blur;")
toni@1112
   226
    @Override
toni@1112
   227
    public native void setShadowBlur(double blur);
toni@1109
   228
toni@1112
   229
    @JavaScriptBody(args = {"x"}, body = "this._context().shadowOffsetX=x;")
toni@1112
   230
    @Override
toni@1112
   231
    public native void setShadowOffsetX(double x);
toni@1109
   232
toni@1112
   233
    @JavaScriptBody(args = {"y"}, body = "this._context().shadowOffsetY=y;")
toni@1112
   234
    @Override
toni@1112
   235
    public native void setShadowOffsetY(double y);
toni@1109
   236
toni@1112
   237
    @JavaScriptBody(args = {}, body = "return this._context().strokeStyle;")
toni@1112
   238
    @Override
toni@1112
   239
    public native String getStrokeStyle();
toni@1109
   240
toni@1112
   241
    @JavaScriptBody(args = {}, body = "return this._context().shadowColor;")
toni@1112
   242
    @Override
toni@1112
   243
    public native String getShadowColor();
toni@1109
   244
toni@1112
   245
    @JavaScriptBody(args = {}, body = "return this._context().shadowBlur;")
toni@1112
   246
    @Override
toni@1112
   247
    public native double getShadowBlur();
toni@1109
   248
toni@1112
   249
    @JavaScriptBody(args = {}, body = "return this._context().shadowOffsetX;")
toni@1112
   250
    @Override
toni@1112
   251
    public native double getShadowOffsetX();
toni@1109
   252
toni@1112
   253
    @JavaScriptBody(args = {}, body = "return this._context().shadowOffsetY;")
toni@1112
   254
    @Override
toni@1112
   255
    public native double getShadowOffsetY();
toni@1109
   256
toni@1112
   257
    @JavaScriptBody(args = {}, body = "return this._context().lineCap;")
toni@1112
   258
    @Override
toni@1112
   259
    public native String getLineCap();
toni@1109
   260
toni@1112
   261
    @JavaScriptBody(args = {"style"}, body = "this._context().lineCap=style.valueOf();")
toni@1112
   262
    @Override
toni@1112
   263
    public native void setLineCap(String style);
toni@521
   264
toni@1112
   265
    @JavaScriptBody(args = {}, body = "return this._context().lineJoin;")
toni@1112
   266
    @Override
toni@1112
   267
    public native String getLineJoin();
toni@521
   268
toni@1112
   269
    @JavaScriptBody(args = {"style"}, body = "this._context().lineJoin=style.valueOf();")
toni@1112
   270
    @Override
toni@1112
   271
    public native void setLineJoin(String style);
toni@521
   272
toni@1112
   273
    @JavaScriptBody(args = {}, body = "return this._context().lineWidth;")
toni@1112
   274
    @Override
toni@1112
   275
    public native double getLineWidth();
toni@521
   276
toni@1112
   277
    @JavaScriptBody(args = {"width"}, body = "this._context().lineWidth=width;")
toni@1112
   278
    @Override
toni@1112
   279
    public native void setLineWidth(double width);
toni@521
   280
toni@1112
   281
    @JavaScriptBody(args = {}, body = "return this._context().miterLimit;")
toni@1112
   282
    @Override
toni@1112
   283
    public native double getMiterLimit();
toni@521
   284
toni@1112
   285
    @JavaScriptBody(args = {"limit"}, body = "this._context().miterLimit=limit;")
toni@1112
   286
    @Override
toni@1112
   287
    public native void setMiterLimit(double limit);
toni@1111
   288
toni@1112
   289
    @JavaScriptBody(args = {}, body = "return this._context().font;")
toni@1112
   290
    @Override
toni@1112
   291
    public native String getFont();
toni@1111
   292
toni@1112
   293
    @JavaScriptBody(args = {"font"}, body = "this._context().font=font.valueOf();")
toni@1112
   294
    @Override
toni@1112
   295
    public native void setFont(String font);
toni@1111
   296
toni@1112
   297
    @JavaScriptBody(args = {}, body = "return this._context().textAlign;")
toni@1112
   298
    @Override
toni@1112
   299
    public native String getTextAlign();
toni@1111
   300
toni@1112
   301
    @JavaScriptBody(args = {"textalign"}, body = "this._context().textAlign=textalign.valueOf();")
toni@1112
   302
    @Override
toni@1112
   303
    public native void setTextAlign(String textAlign);
toni@1111
   304
toni@1112
   305
    @JavaScriptBody(args = {}, body = "return this._context().textBaseline;")
toni@1112
   306
    @Override
toni@1112
   307
    public native String getTextBaseline();
toni@1111
   308
toni@1112
   309
    @JavaScriptBody(args = {"textbaseline"}, body = "this._context().textBaseline=textbaseline.valueOf();")
toni@1112
   310
    @Override
toni@1112
   311
    public native void setTextBaseline(String textbaseline);
toni@1111
   312
toni@1112
   313
    @JavaScriptBody(args = {"text", "x", "y"}, body = "this._context().fillText(text,x,y);")
toni@1112
   314
    @Override
toni@1112
   315
    public native void fillText(String text, double x, double y);
toni@1111
   316
toni@1112
   317
    @JavaScriptBody(args = {"text", "x", "y", "maxwidth"}, body = "this._context().fillText(text,x,y,maxwidth);")
toni@1112
   318
    @Override
toni@1112
   319
    public void fillText(String text, double x, double y, double maxWidth) {
toni@1112
   320
    }
toni@1111
   321
toni@1112
   322
    @Override
toni@1125
   323
    public ITextMetrics measureText(String text) {
toni@1125
   324
        return new TextMetrics(measureTextImpl(text));
toni@1112
   325
    }
toni@1111
   326
toni@1112
   327
    @JavaScriptBody(args = {"text"},
toni@1112
   328
            body = "return this._context().measureText(text);")
toni@1112
   329
    private native Object measureTextImpl(String text);
toni@1111
   330
toni@1112
   331
    @JavaScriptBody(args = {"text", "x", "y"}, body = "this._context().strokeText(text,x,y);")
toni@1112
   332
    @Override
toni@1112
   333
    public native void strokeText(String text, double x, double y);
toni@1111
   334
toni@1112
   335
    @JavaScriptBody(args = {"text", "x", "y", "maxWidth"}, body = "this._context().strokeText(text,x,y,maxWidth);")
toni@1112
   336
    @Override
toni@1112
   337
    public native void strokeText(String text, double x, double y, double maxWidth);
toni@1111
   338
toni@1112
   339
    @Override
toni@1125
   340
    public IImageData createImageData(double x, double y) {
toni@1125
   341
        return new ImageData(createImageDataImpl(x, y));
toni@1112
   342
    }
toni@1111
   343
toni@1112
   344
    @JavaScriptBody(args = {"x", "y"},
toni@1112
   345
            body = "return this._context().createImageData(x,y);")
toni@1112
   346
    private native Object createImageDataImpl(double x, double y);
toni@1111
   347
toni@1112
   348
    @Override
toni@1125
   349
    public IImageData createImageData(IImageData imageData) {
toni@1125
   350
        return new ImageData(createImageDataImpl(imageData.getWidth(), imageData.getHeight()));
toni@1112
   351
    }
toni@1111
   352
toni@1112
   353
    @Override
toni@1125
   354
    public IImageData getImageData(double x, double y, double width, double height) {
toni@1125
   355
        return new ImageData(getImageDataImpl(x, y, width, height));
toni@1112
   356
    }
toni@1111
   357
toni@1112
   358
    @JavaScriptBody(args = {"x", "y", "width", "height"},
toni@1112
   359
            body = "return this._context().getImageData(x,y,width,height);")
toni@1112
   360
    private native Object getImageDataImpl(double x, double y, double width, double height);
toni@1111
   361
toni@1112
   362
    @Override
toni@1125
   363
    public void putImageData(IImageData imageData, double x, double y) {
toni@1125
   364
        putImageDataImpl(((ImageData) imageData).object(), x, y);
toni@1112
   365
    }
toni@1112
   366
toni@1112
   367
    @JavaScriptBody(args = {"imageData", "x", "y"},
toni@1112
   368
            body = "this._context().putImageData(imageData,x,y);")
toni@1112
   369
    private native void putImageDataImpl(Object imageData, double x, double y);
toni@1112
   370
toni@1112
   371
    @Override
toni@1125
   372
    public void putImageData(IImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) {
toni@1125
   373
        putImageDataImpl(((ImageData) imageData).object(), x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
toni@1112
   374
    }
toni@1112
   375
toni@1112
   376
    @JavaScriptBody(args = {"imageData", "x", "y", "dirtyx", "dirtyy", "dirtywidth", "dirtyheight"},
toni@1112
   377
            body = "this._context().putImageData(imageData,x,y, dirtyx, dirtyy, dirtywidth,dirtyheight);")
toni@1112
   378
    private native void putImageDataImpl(Object imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
toni@1112
   379
toni@1112
   380
    @JavaScriptBody(args = {"alpha"}, body = "this._context().globalAlpha=alpha;")
toni@1112
   381
    @Override
toni@1112
   382
    public native void setGlobalAlpha(double alpha);
toni@1112
   383
toni@1112
   384
    @JavaScriptBody(args = {}, body = "return this._context().globalAlpha;")
toni@1112
   385
    @Override
toni@1112
   386
    public native double getGlobalAlpha();
toni@1112
   387
toni@1112
   388
    @JavaScriptBody(args = {"operation"}, body = "this._context().globalCompositeOperation=operation.valueOf();")
toni@1112
   389
    @Override
toni@1112
   390
    public native void setGlobalCompositeOperation(String operation);
toni@1112
   391
toni@1112
   392
    @JavaScriptBody(args = {}, body = "return this._context().globalCompositeOperation;")
toni@1112
   393
    @Override
toni@1112
   394
    public native String getGlobalCompositeOperation();
toni@1112
   395
toni@1112
   396
    @Override
toni@1125
   397
    public LinearGradient createLinearGradient(double x0, double y0, double x1, double y1) {
toni@1125
   398
        return new LinearGradient(createLinearGradientImpl(context, x0, y0, x1, y1));
toni@1112
   399
    }
toni@1112
   400
toni@1112
   401
    @JavaScriptBody(args = {"context", "x0", "y0", "x1", "y1"}, body = "return context.createLinearGradient(x0,y0,x1,y1);")
toni@1112
   402
    private native Object createLinearGradientImpl(Object context, double x0, double y0, double x1, double y1);
toni@1112
   403
toni@1112
   404
    @Override
toni@1125
   405
    public IPattern createPattern(IImage image, String repeat) {
toni@1125
   406
        return new Pattern(createPatternImpl(context, image, repeat));
toni@1112
   407
    }
toni@1112
   408
toni@1112
   409
    @JavaScriptBody(args = {"context", "image", "repeat"}, body = "return context.createPattern(image, repeat);")
toni@1125
   410
    private static native Object createPatternImpl(Object context, IImage image, String repeat);
toni@1112
   411
toni@1112
   412
    @Override
toni@1125
   413
    public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1) {
toni@1125
   414
        return new RadialGradient(createRadialGradientImpl(context, x0, y0, r0, x1, y1, r1));
toni@1112
   415
    }
toni@1112
   416
toni@1112
   417
    @JavaScriptBody(args = {"context", "x0", "y0", "r0", "x1", "y1", "r1"}, body = "return context.createRadialGradient(x0,y0,r0,x1,y1,r1);")
toni@1112
   418
    private static native Object createRadialGradientImpl(Object context, double x0, double y0, double r0, double x1, double y1, double r1);
toni@1121
   419
toni@1122
   420
    @JavaScriptBody(args = {"path"}, body = "var b = new Image(); b.src=path; return b;")
toni@1121
   421
    @Override
toni@1125
   422
    public IImage getImageForPath(String path) {
toni@1121
   423
        throw new UnsupportedOperationException("getImageForPath is not yet supported");
toni@1121
   424
    }
toni@521
   425
}