Examples of Surface


Examples of gwt.g2d.client.graphics.Surface

  @Override
  public void initialize() {
    add(new Label("The left surface is rendered using DirectShapeRenderer, "
        + "the right surface is rendered using ShapeBuilder."));
    Surface surface = getPrimarySurface();
    surface.setSize(220, 220);
    add(surface);
    drawDirectly(surface);
       
    Surface surface2 = new Surface(surface.getSize());
    add(surface2);
    drawWithShapeBuilder(surface2);
  }
View Full Code Here

Examples of gwt.g2d.client.graphics.Surface

  }

  @Override
  public void initialize() {
    add(new Label("This demo does not work under IE."));
    Surface originalCanvas = new Surface(300, 300);
    Circle smallCircle = new Circle(150, 150, 140);
    Circle bigCircle = new Circle(150, 150, 150);
    Shape smallCircleShape = new ShapeBuilder().drawCircle(smallCircle).build();
    Shape bigCircleShape = new ShapeBuilder().drawCircle(bigCircle).build();
    Gradient radialGradient = new RadialGradient(new Circle(150, 150, 0), smallCircle)
        .addColorStop(0, KnownColor.RED)
        .addColorStop(1, KnownColor.GREEN);
    originalCanvas.setFillStyle(KnownColor.BLACK)
        .fillShape(bigCircleShape)
        .setFillStyle(radialGradient)
        .fillShape(smallCircleShape);
   
    add(new Label("Original Canvas"));
    add(originalCanvas);
   
    add(new Label("Canvas with the original canvas drawn on top of it."));
    add(getPrimarySurface());
   
    getPrimarySurface().clear()
        .fillBackground(KnownColor.GRAY)
        .drawImage(originalCanvas.getCanvas(), 0, 0)
        .drawImage(originalCanvas.getCanvas(), 300, 0)
        .drawImage(originalCanvas.getCanvas(), 0, 300)
        .drawImage(originalCanvas.getCanvas(), 300, 300)
        .drawImage(originalCanvas.getCanvas(), 150, 150);
  }
View Full Code Here

Examples of gwt.g2d.client.graphics.Surface

  private final String demoName;
  private final Panel parentContainer;
 
  public AbstractDemo(String demoName, Panel parentContainer) {
    super(60);
    surface = new Surface(WIDTH, HEIGHT);
    this.demoName = demoName;
    this.parentContainer = parentContainer;
    parentContainer.clear();
  }
View Full Code Here

Examples of gwt.g2d.client.graphics.Surface

  }

  @Override
  public void onMouseMove(MouseMoveEvent event) {
    if (isLeftButtonDown || isRightButtonDown) {
      Surface surface = getPrimarySurface();
      surface.save().setLineCap(LineCap.ROUND).setLineJoin(LineJoin.ROUND);
      if (isLeftButtonDown) {
        surface.setStrokeStyle(KnownColor.BLACK).setLineWidth(5);
      } else if (isRightButtonDown) {
        surface.setStrokeStyle(KnownColor.WHITE).setLineWidth(20);
      }
      surface.strokeShape(new ShapeBuilder()
          .drawLineSegment(lastPosition, new Vector2(event.getX(), event.getY()))
          .build());
      surface.restore();
      lastPosition.set(event.getX(), event.getY());
    }   
  }
View Full Code Here

Examples of gwt.g2d.client.graphics.Surface

  private int totalRowsCleared;
  private int levelOffset = 0;
  private boolean needRedraw = true, needRedrawNextPiece = true;
 
  public Tetris(int startingLevel, Panel parentContainer) {
    surface = new Surface(DEFAULT_NUM_COLS * BLOCK_PIXEL_SIZE,
        DEFAULT_NUM_ROWS * BLOCK_PIXEL_SIZE);
    this.parentContainer = parentContainer;
    matrix = new TetrisMatrix(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS);
    this.levelOffset = startingLevel;
    setLevel(startingLevel);
View Full Code Here

Examples of gwt.g2d.client.graphics.Surface

  }

  @Override
  public void initialize() {
    super.initialize();
    Surface surface = getPrimarySurface();
    int size = surface.getWidth();
    matrix.setIdentity();
    surface.setTransform(matrix);

    surface.fillRectangle(0, 0, size, size)
        .setTransform(matrix.mutableTranslate(size / 2, size / 2))
        .clipShape(new CircleShape(0, 0, size / 2.0 * .8));

    Gradient gradient = new LinearGradient(0, -size / 2, 0, size / 2)
        .addColorStop(0, new Color(35, 34, 86))
        .addColorStop(1, new Color(20, 55, 120));
   
    surface.setFillStyle(gradient)
        .fillRectangle(-size / 2, -size / 2, size, size);

    // draw stars
    surface.setFillStyle(KnownColor.WHITE);
    for (int j = 0; j < 500; j++) {
      surface.save()
          .translate(size / 2 - Random.nextInt(size),
              size / 2 - Random.nextInt(size));
      drawStar(Random.nextInt(4) + 2);
      surface.restore();
    }
  }
View Full Code Here

Examples of gwt.g2d.client.graphics.Surface

  public void update() {

  }

  private void drawStar(double r) {
    Surface surface = getPrimarySurface();
    surface.save();
    ShapeBuilder shapeBuilder = new ShapeBuilder().moveTo(r, 0);
    for (int i = 0; i < 9; i++) {
      shapeBuilder.rotate(Math.PI / 5);
      if (i % 2 == 0) {
        shapeBuilder.drawLineTo((r / 0.525731) * 0.200811, 0);
      } else {
        shapeBuilder.drawLineTo(r, 0);
      }
    }
    surface.fillShape(shapeBuilder.build())
        .restore();
  }
View Full Code Here

Examples of gwt.g2d.client.graphics.Surface

   
    // set id
    fCurrentId = id;
   
    // surface
    Surface surface = null;
   
    // doesn't exist yet - create a new canvas
    if (!fIdToSurface.containsKey(id)) {
      surface = new Surface(fOriginalSurface.getCoordinateSpaceWidth(), fOriginalSurface.getCoordinateSpaceHeight());
      fIdToSurface.put(id,  surface);
      fIdToHandlers.put(id, new Handlers());
      fIds.add(id);
    }
   
    // exist - get the existing canvas
    else {
     
      // get the surface
      surface = fIdToSurface.get(id);
      surface.clear();
     
      // find the position of this id, and put it at the end of our draw list
      fIds.remove(id);
      fIds.add(id);
    }
View Full Code Here

Examples of gwt.g2d.client.graphics.Surface

   
    // get all different canvases and check for a collision
    ListIterator<Long> it = fIds.listIterator(fIds.size());
    while (it.hasPrevious()) {
      Long id = it.previous();
      Surface surface = fIdToSurface.get(id);
     
      // get the color at the given location
      ImageData data = surface.getImageData(x, y, 1, 1);
      double alpha = data.getAlpha(0, 0);
     
      // hit is not transparent - we got a hit!
      if (alpha > Double.MIN_VALUE) {
       
View Full Code Here

Examples of gwt.g2d.client.graphics.Surface

   
    // get all different canvases and check for a collision
    ListIterator<Long> it = fIds.listIterator(fIds.size());
    while (it.hasPrevious()) {
      Long id = it.previous();
      Surface surface = fIdToSurface.get(id);
     
      // get the color at the given location
      ImageData data = surface.getImageData(x, y, 1, 1);
      double alpha = data.getAlpha(0, 0);
     
      // hit is not transparent - we got a hit!
      if (alpha > Double.MIN_VALUE) {
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.