Package com.google.gwt.canvas.client

Examples of com.google.gwt.canvas.client.Canvas


      ImageData imageData = context.getImageData(0, 0, w, h);

      return imageData;
  }
  public  static ImageData fillImage(Image image, double cw,double ch) {
       Canvas canvasTmp = Canvas.createIfSupported();
        Context2d context = canvasTmp.getContext2d();

        //double ch = (image.getHeight() * scaleToRatioh) + 100;
        //double cw = (image.getWidth() * scaleToRatiow) + 100;

        canvasTmp.setCoordinateSpaceHeight((int) ch);
        canvasTmp.setCoordinateSpaceWidth((int) cw);
       
        ImageElement imageElement = ImageElement.as(image.getElement());
      
        // s = source
        // d = destination
View Full Code Here


  private int mFPScount = 0;
  private int mFPS = 0;

  public void onModuleLoad()
  {     
    final Canvas webGLCanvas = Canvas.createIfSupported();
    webGLCanvas.setCoordinateSpaceHeight(PU_Engine.SCREEN_HEIGHT);
        webGLCanvas.setCoordinateSpaceWidth(PU_Engine.SCREEN_WIDTH);
    PUWeb.mGlContext = (WebGLRenderingContext)webGLCanvas.getContext("experimental-webgl");
    PUWeb.mGlContext.viewport(0, 0, PU_Engine.SCREEN_WIDTH, PU_Engine.SCREEN_HEIGHT);
    RootPanel.get("gwtGL").add(webGLCanvas);
   
    PUWeb.mResources = new PU_Resources();
    PUWeb.mGame = new PU_Game();
View Full Code Here

         panel.getElement().getStyle().setVisibility(Visibility.HIDDEN);
         panel.getElement().getStyle().setOverflow(Overflow.SCROLL);
         RootPanel.get().add(panel, -2000, -2000);
     
         // add a canvas element to the div and get the 2d drawing context
         final Canvas canvas = Canvas.createIfSupported();
         canvas.setWidth("512px");
         canvas.setHeight("64px");
         canvas.getElement().getStyle().setLeft(400, Unit.PX);
         canvas.getElement().getStyle().setBackgroundColor("#ffe");
         panel.add(canvas);
         final Context2d ctx = canvas.getContext2d();
         ctx.setFillStyle("#000000");
        
         // closure to generate a hash for a font
         class HashGenerator {
            public String getHash(String fontName)
            {
               ctx.setFont("57px " + fontName + ", " + defaultFontName);
               int width = canvas.getOffsetWidth();
               int height = canvas.getOffsetHeight();
               ctx.clearRect(0, 0, width, height);
               ctx.fillText("TheQuickBrownFox", 2, 50);
               return canvas.toDataUrl();
            }};
        
         // get hashes and compare them
         HashGenerator hashGenerator = new HashGenerator();
         String defaultHash = hashGenerator.getHash(defaultFontName);
View Full Code Here

    int width = resource.getWidth();

    ImageElement imageElement = loadImage(resource.getSafeUri().asString(),
        width, height);

    Canvas canvas = Canvas.createIfSupported();
    canvas.getElement().setPropertyInt("height", height);
   canvas.getElement().setPropertyInt("width", width);

    Context2d context = canvas.getContext2d();
    context.drawImage(imageElement, 0, 0);
    ImageData imageData = context.getImageData(0, 0, width,
        height);

    CanvasPixelArray canvasPixelArray = imageData.getData();

    for (int i = 0; i < canvasPixelArray.getLength(); i += 4) {
      canvasPixelArray.set(i, red);
      canvasPixelArray.set(i + 1, green);
      canvasPixelArray.set(i + 2, blue);
      canvasPixelArray.set(i + 3,
      canvasPixelArray.get(i + 3));
    }
    context.putImageData(imageData, 0, 0);


    return new ConvertedImageResource(
        canvas.toDataUrl("image/png"), resource.getWidth(),
        resource.getHeight());
  }
View Full Code Here

  int frames;
  GwtApplicationConfiguration config;
  boolean inFullscreenMode = false;

  public GwtGraphics (Panel root, GwtApplicationConfiguration config) {
    Canvas canvasWidget = Canvas.createIfSupported();
    if (canvasWidget == null) throw new GdxRuntimeException("Canvas not supported");
    canvas = canvasWidget.getCanvasElement();
    root.add(canvasWidget);
    canvas.setWidth(config.width);
    canvas.setHeight(config.height);
    this.config = config;
View Full Code Here

  int frames;
  GwtApplicationConfiguration config;
  boolean inFullscreenMode = false;

  public GwtGraphics (Panel root, GwtApplicationConfiguration config) {
    Canvas canvasWidget = Canvas.createIfSupported();
    if (canvasWidget == null) throw new GdxRuntimeException("Canvas not supported");
    canvas = canvasWidget.getCanvasElement();
    root.add(canvasWidget);
    canvas.setWidth(config.width);
    canvas.setHeight(config.height);
    this.config = config;
View Full Code Here

        return clone;
    }

    @Override
    public Widget cloneDisplay(Map<String, Object> formData) {
        Canvas cv = Canvas.createIfSupported();
        if (cv == null) {
            return new Label(notSupported.getText());
        }
        populate(cv);
        super.populateActions(cv.getElement());
        return cv;
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.canvas.client.Canvas

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.