Package gwt.g2d.client.graphics

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


  }

  @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

  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

   
    // 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

   
    // 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

   
    // 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

    // get all different canvases and check for a collision
    boolean hit = false;
    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) {
        hit = true;
View Full Code Here

TOP

Related Classes of gwt.g2d.client.graphics.Surface

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.