Example usage for com.badlogic.gdx.graphics Pixmap fillCircle

List of usage examples for com.badlogic.gdx.graphics Pixmap fillCircle

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Pixmap fillCircle.

Prototype

public void fillCircle(int x, int y, int radius) 

Source Link

Document

Fills a circle with the center at x,y and a radius using the current color.

Usage

From source file:com.ridiculousRPG.video.cortado.CortadoPlayerAppletWrapper.java

License:Open Source License

/**
 * Instantiates a new video player. Don't forget to dispose the player!
 * /*from  w  ww.  ja  v  a2  s.  c o m*/
 * @param url
 *            url to ogg / ogv file
 * @param screenBounds
 *            the screen position, width and height
 * @param projectToMap
 *            Defines whether to project the video onto the map or onto the
 *            screen coordinates
 * @param withAudio
 *            if false, the audio channel will be disabled.
 */
public CortadoPlayerAppletWrapper(URL url, Rectangle screenBounds, boolean projectToMap, boolean withAudio,
        boolean drawPlaceholder) {
    this.screenBounds = new Rectangle(screenBounds);
    this.projectToMap = projectToMap;
    if (!projectToMap) {
        GameBase gb = GameBase.$();
        this.screenBounds.width /= gb.getScreen().width;
        this.screenBounds.height /= gb.getScreen().height;
        this.screenBounds.x /= gb.getScreen().width;
        this.screenBounds.y /= gb.getScreen().height;
    }
    int width = (int) screenBounds.width;
    int height = (int) screenBounds.height;

    textureRef = TextureRegionLoader.obtainEmptyRegion(width, height, Format.RGBA8888);
    if (drawPlaceholder) {
        Pixmap placeholder = new Pixmap(width, height, Format.RGBA8888);
        placeholder.setColor(0, 0, 0, 1);
        placeholder.fillRectangle(0, 0, width, height);
        placeholder.setColor(.7f, .7f, .7f, 1);
        placeholder.fillCircle(width / 2, height / 2, Math.min(width, height) / 3);
        placeholder.setColor(.4f, .4f, .4f, 1);
        placeholder.drawRectangle(0, 0, width, height);
        placeholder.drawRectangle(2, 2, width - 4, height - 4);
        placeholder.drawLine(1, 0, width, height - 1);
        placeholder.drawLine(0, 1, width - 1, height);
        placeholder.drawLine(1, height, width, 1);
        placeholder.drawLine(0, height - 1, width - 1, 0);
        textureRef.draw(placeholder);
        placeholder.dispose();
    }
    graphicsPixmap = new VideoARGBintPixmapWrapper();
    player = new CortadoPlayerApplet(graphicsPixmap);
    initPlayer();
    player.setParam("url", url.toString());
    player.setParam("audio", String.valueOf(withAudio));
    player.setSize(width, height);
    player.setStub(this);
    player.init();
    player.start();
}

From source file:com.shatteredpixel.shatteredpixeldungeon.effects.Halo.java

License:Open Source License

public Halo() {
    super();/*from w  w w  .  j  av a2 s . c  o m*/

    if (!TextureCache.contains(CACHE_KEY)) {
        Pixmap pixmap = new Pixmap(RADIUS * 2, RADIUS * 2, Pixmap.Format.RGBA8888);
        pixmap.setColor(0xFFFFFFFF);
        pixmap.fillCircle(RADIUS, RADIUS, (int) (RADIUS * 0.75f));
        pixmap.setColor(0xFFFFFF88);
        pixmap.fillCircle(RADIUS, RADIUS, RADIUS);
        GdxTexture bmp = new GdxTexture(pixmap);
        TextureCache.add(CACHE_KEY, new SmartTexture(bmp));
    }

    texture(CACHE_KEY);

    origin.set(RADIUS);
}

From source file:es.eucm.ead.editor.utils.ImageBorderTracer.java

License:Open Source License

public static Pixmap createSamplePixmap(int width, int height, Pixmap.Format fmt) {
    if (fmt == null) {
        fmt = Pixmap.Format.RGBA8888;
    }/*from   w ww  .  j a va  2s.  c o m*/
    Pixmap p = new Pixmap(width, height, fmt);
    p.setColor(Color.YELLOW);
    p.fillCircle(width / 4, height / 2, width / 5);
    p.fillCircle(width * 3 / 4, height / 2, width / 5);
    return p;
}

From source file:es.eucm.ead.editor.view.scene.SimpleSceneViewer.java

License:Open Source License

private void initTextures() {
    Pixmap p = new Pixmap(10, 10, Pixmap.Format.RGBA8888);
    p.setColor(Color.GREEN);/*from   w ww.  j av a  2  s .c o m*/
    p.fillCircle(5, 5, 4);
    p.setColor(Color.DARK_GRAY);
    p.drawCircle(5, 5, 4);

    circle = new Texture(p);
    p.dispose();
    selectionMatrix.translate(-5f, -5.0f, 0f);

    p = new Pixmap(1, 5, Pixmap.Format.RGB888);
    vLine = new Texture(p);
    p.dispose();

    p = new Pixmap(5, 1, Pixmap.Format.RGB888);
    hLine = new Texture(p);
    p.dispose();
}

From source file:es.eucm.ead.engine.assets.drawables.shapes.GdxCircleShape.java

License:Open Source License

@Override
protected Pixmap generatePixmap() {
    EAdPaint paint = descriptor.getPaint();
    EAdFill fill = paint.getFill();//from  w  ww  . ja va  2s .  c o m
    EAdFill border = paint.getBorder();
    int borderWidth = paint.getBorderWidth();
    int size = descriptor.getRadius() * 2 + borderWidth * 2 + 1;
    int center = size / 2;

    Pixmap pixmap = new Pixmap(size, size, Pixmap.Format.RGBA8888);
    pixmapContains = new Pixmap(size, size, Pixmap.Format.RGBA8888);
    pixmapContains.setColor(0, 0, 0, 1);
    pixmapContains.fillCircle(center, center, descriptor.getRadius() + borderWidth);

    ColorFill c = ColorFill.TRANSPARENT;
    if (border != null) {
        if (border instanceof ColorFill) {
            c = (ColorFill) border;

        } else if (border instanceof LinearGradientFill) {
            LinearGradientFill l = (LinearGradientFill) border;
            c = l.getColor1();
        }

        pixmap.setColor(c.getRed() / 255.0f, c.getGreen() / 255.0f, c.getBlue() / 255.0f,
                c.getAlpha() / 255.0f);
        pixmap.drawCircle(center, center, descriptor.getRadius() + borderWidth);
    }

    if (fill instanceof ColorFill) {
        c = (ColorFill) fill;
        pixmap.setColor(c.getRed() / 255.0f, c.getGreen() / 255.0f, c.getBlue() / 255.0f,
                c.getAlpha() / 255.0f);
        pixmap.fillCircle(center, center, descriptor.getRadius());
    } else if (fill instanceof LinearGradientFill) {
        LinearGradientFill l = (LinearGradientFill) fill;
        initGradientParams(l.getColor1(), l.getX0(), l.getY0(), l.getColor2(), l.getX1(), l.getY1());
        int size2 = descriptor.getRadius() * descriptor.getRadius();
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                int s1 = (i - center);
                s1 = s1 * s1;
                int s2 = (j - center);
                s2 = s2 * s2;
                if (s1 + s2 < size2) {
                    setColor(pixmap, i, j);
                    pixmap.drawPixel(i, j);
                }
            }
        }
    }

    return pixmap;
}

From source file:es.eucm.ead.engine.components.renderers.shape.ShapeToPixmap.java

License:Open Source License

/** Creates a circle **/
private Pixmap createCircle(Circle circle) {
    int radius = circle.getRadius();
    int size = radius * 2;
    pixmapHeight = size;//w  ww .  ja  v  a 2  s  . c  om
    originX = 0;
    originY = 0;
    Pixmap pixmap = new Pixmap(size, size, Format.RGBA8888);
    if (useGradient) {
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < pixmapHeight; j++) {
                if (auxVector.set(i - radius, j - radius).len() <= radius - 1) {
                    setGradientColor(pixmap, i, j);
                    pixmap.drawPixel(i, j);
                }
            }
        }
    } else {
        pixmap.setColor(color1);
        pixmap.fillCircle(radius, radius, radius - 1);
    }

    if (hasBorder) {
        pixmap.setColor(borderColor);
        pixmap.drawCircle(radius, radius, radius - 1);
    }
    return pixmap;
}

From source file:mobi.shad.s3lib.gfx.pixmap.procedural.Object2D.java

License:Apache License

/**
 * @param pixmap/*from   ww  w .j a  va  2  s.  com*/
 * @param xCenter
 * @param yCenter
 * @param xSize
 * @param ySize
 * @param maxIterations
 */
public static void generate(final Pixmap pixmap, int mode, int count, int size, int growth, int randomColor,
        int red, int green, int blue) {

    S3Log.log("Object2D", "mode: " + mode + " count: " + count + " size: " + size);

    int width = pixmap.getWidth();
    int height = pixmap.getHeight();

    if (objectsPosistionX.length != count) {
        objectsPosistionX = new int[count];
        objectsPosistionY = new int[count];
        objectsExpand = new int[count];
        objectsFade = new int[count];
        objectsColor = new float[count][3];

        for (int i = 0; i < count; i++) {
            objectsPosistionX[i] = rnd.nextInt(width);
            objectsPosistionY[i] = rnd.nextInt(height);
            objectsExpand[i] = rnd.nextInt(growth);
            objectsFade[i] = 0;

            if (randomColor > 0) {
                objectsColor[i][0] = rnd.nextInt(256);
                objectsColor[i][1] = rnd.nextInt(256);
                objectsColor[i][2] = rnd.nextInt(256);
            } else {
                objectsColor[i][0] = red;
                objectsColor[i][1] = green;
                objectsColor[i][2] = blue;
            }
        }
    }

    for (int i = 0; i < count; i++) {
        int r = (int) (objectsColor[i][0] * (1.0F - objectsFade[i] / growth));
        int g = (int) (objectsColor[i][1] * (1.0F - objectsFade[i] / growth));
        int b = (int) (objectsColor[i][2] * (1.0F - objectsFade[i] / growth));

        int diameter = size + objectsExpand[i];

        if (objectsExpand[i] < growth) {

            pixmap.setColor(((int) r << 24) | ((int) g << 16) | ((int) b << 8) | 255);

            int offset = diameter / 2;

            switch (mode) {
            default:
                pixmap.drawCircle(objectsPosistionX[i] - offset, objectsPosistionY[i] - offset, diameter);
                break;
            case 1:
                pixmap.fillCircle(objectsPosistionX[i] - offset, objectsPosistionY[i] - offset, diameter);
                break;
            case 2:
                pixmap.drawRectangle(objectsPosistionX[i] - offset, objectsPosistionY[i] - offset, diameter,
                        diameter);
                break;
            case 3:
                pixmap.fillRectangle(objectsPosistionX[i] - offset, objectsPosistionY[i] - offset, diameter,
                        diameter);
                break;
            case 4:
                pixmap.drawCircle(objectsPosistionX[i] - offset, objectsPosistionY[i] - offset, diameter);
                pixmap.drawCircle(objectsPosistionX[i] - offset + diameter / 4 - diameter / 8,
                        objectsPosistionY[i] - offset + diameter / 3, diameter / 4);
                pixmap.drawCircle(objectsPosistionX[i] - offset + (int) (diameter * 0.75F) - diameter / 8,
                        objectsPosistionY[i] - offset + diameter / 3, diameter / 4);
                pixmap.drawCircle(objectsPosistionX[i] - offset + diameter / 4,
                        objectsPosistionY[i] - offset + diameter / 3, diameter / 8);
                pixmap.drawCircle(objectsPosistionX[i] - offset + (int) (diameter * 0.75F),
                        objectsPosistionY[i] - offset + diameter / 3, diameter / 8);
                break;
            }
        }

        objectsExpand[i] += 2;
        objectsFade[i] += 2;
        if (objectsFade[i] >= growth) {
            objectsFade[i] = growth;
        }

        if ((objectsExpand[i] < growth) || (rnd.nextInt(100) >= 10)) {
            continue;
        }
        objectsPosistionX[i] = rnd.nextInt(width);
        objectsPosistionY[i] = rnd.nextInt(height);
        objectsExpand[i] = 0;
        objectsFade[i] = 0;
    }
}

From source file:mobi.shad.s3lib.gui.dialog.Editor2d.java

License:Apache License

public void create(Texture areaTexture, final float startX, final float startY, final float width,
        final float height, final ChangeListener changeListener) {

    super.create();

    backendWindow = GuiResource.windowBackend();
    backendWindow.setColor(1f, 1f, 1f, 0f);
    backendWindow.setVisible(false);/*from w ww .  j  a  v  a 2s .com*/
    S3.stage.addActor(backendWindow);

    mainWindow = GuiResource.window("WidgetBase", "WidgetBase");
    mainWindow.setColor(1f, 1f, 1f, 0f);
    mainWindow.setVisible(false);
    mainWindow.setModal(true);
    mainWindow.setMovable(false);

    this.currentX = startX;
    this.currentY = startY;
    this.currentWidth = width;
    this.currentHeight = height;
    //
    // Grid Layer
    //
    Pixmap pixmap = new Pixmap(10, 10, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    gridtextureLayer = new Texture(pixmap);

    gridLayer = new Widget() {

        @Override
        public void draw(Batch batch, float parentAlpha) {
            batch.setColor(0.8f, 0.8f, 0.8f, 0.3f);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY1, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY2, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY3, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY4, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY5, S3Screen.width, 3);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY6, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY7, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY8, S3Screen.width, 1);
            batch.draw(gridtextureLayer, 0, S3Constans.gridY9, S3Screen.width, 1);

            batch.draw(gridtextureLayer, S3Constans.gridX1, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX2, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX3, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX4, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX5, 0, 3, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX6, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX7, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX8, 0, 1, S3Screen.height);
            batch.draw(gridtextureLayer, S3Constans.gridX9, 0, 1, S3Screen.height);
        }
    };
    gridLayer.setX(0);
    gridLayer.setY(0);
    gridLayer.setWidth(S3Screen.width);
    gridLayer.setHeight(S3Screen.height);

    //
    //
    //
    final TextureRegion areaRegion = new TextureRegion(areaTexture);

    areaImage = new Widget() {

        @Override
        public void draw(Batch batch, float parentAlpha) {
            Color color = getColor();
            batch.setColor(color.r, color.g, color.b, parentAlpha);
            batch.draw(areaRegion, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(),
                    getScaleX(), getScaleY(), getRotation());
        }
    };
    areaImage.setX(currentX);
    areaImage.setY(currentY);
    areaImage.setWidth(currentWidth);
    areaImage.setHeight(currentHeight);

    //
    // Create texture
    //
    Pixmap redPixmap = new Pixmap(32, 32, Pixmap.Format.RGBA8888);
    redPixmap.setColor(Color.RED);
    redPixmap.fillCircle(16, 16, 14);
    Texture redTexture = new Texture(redPixmap);
    Pixmap yellowPixmap = new Pixmap(32, 32, Pixmap.Format.RGBA8888);
    yellowPixmap.setColor(Color.YELLOW);
    yellowPixmap.fillCircle(16, 16, 14);
    Texture yellowTexture = new Texture(yellowPixmap);
    Pixmap greenPixmap = new Pixmap(32, 32, Pixmap.Format.RGBA8888);
    greenPixmap.setColor(Color.GREEN);
    greenPixmap.fillCircle(16, 16, 14);
    Texture greenTexture = new Texture(greenPixmap);

    //
    //
    //
    TextButton textButtonOk = GuiResource.textButton("Save", "Save");
    TextButton textButtonFullScreen = GuiResource.textButton("Full", "Full");
    TextButton textButtonCenter = GuiResource.textButton("Center", "Center");
    TextButton textButtonCancel = GuiResource.textButton("Cancel", "Cancel");

    //
    //
    //
    textButtonOk.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            S3Log.log("Editor2d::textButtonOk::clicked", " event: " + event + " actor: " + actor.toString(), 2);
            hide();
            if (changeListener != null) {
                changeListener.changed(event, areaImage);
            }
        }
    });

    textButtonFullScreen.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            S3Log.log("Editor2d::textButtonFullScreen::clicked", " event: " + event + " x: " + x + " y: " + y,
                    2);
            currentX = 0;
            currentY = 0;
            currentWidth = S3Screen.width;
            currentHeight = S3Screen.height;
            setAreaPosistion();
            setTouchPosistion();
        }
    });

    textButtonCenter.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            S3Log.log("Editor2d::textButtonCenter::clicked", " event: " + event + " x: " + x + " y: " + y, 2);
            currentX = S3Screen.centerX - (float) S3Screen.centerX / 2;
            currentY = S3Screen.centerY - (float) S3Screen.centerY / 2;
            currentWidth = (float) S3Screen.centerX;
            currentHeight = (float) S3Screen.centerY;
            setAreaPosistion();
            setTouchPosistion();
        }
    });

    textButtonCancel.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            S3Log.log("Editor2d::textButtonCancel::clicked", " event: " + event + " x: " + x + " y: " + y, 2);
            currentX = startX;
            currentY = startY;
            currentWidth = width;
            currentHeight = height;
            hide();
        }
    });

    sizeElementLabel = GuiResource.label("X: Y: Width: Height:", "sizeElementLabel");
    mainWindow.row();
    mainWindow.add(textButtonOk);
    mainWindow.add(textButtonFullScreen);
    mainWindow.add(textButtonCenter);
    mainWindow.add(textButtonCancel);
    mainWindow.row();
    mainWindow.add(sizeElementLabel).colspan(4).left();
    GuiUtil.windowPosition(mainWindow, 0, 0);

    S3.stage.addActor(gridLayer);
    S3.stage.addActor(areaImage);

    //
    // Create AreaPlot
    //
    dotLeftImage = createAreaPoint("dotLeftImage", redTexture, (int) (currentX - 16),
            (int) (currentY + (currentHeight / 2) - 16));
    dotRightImage = createAreaPoint("dotRightImage", redTexture, (int) (currentX + currentWidth - 16),
            (int) (currentY + (currentHeight / 2) - 16));

    dotTopImage = createAreaPoint("dotTopImage", redTexture, (int) (currentX + (currentWidth / 2) - 16),
            (int) (currentY + currentHeight - 16));
    dotBottomImage = createAreaPoint("dotBottomImage", redTexture, (int) (currentX + (currentWidth / 2) - 16),
            (int) (currentY - 16));

    dotTopLeftImage = createAreaPoint("dotTopLeftImage", yellowTexture, (int) (currentX - 16),
            (int) (currentY + currentHeight - 16));
    dotTopRightImage = createAreaPoint("dotTopRightImage", yellowTexture, (int) (currentX + currentWidth - 16),
            (int) (currentY + currentHeight - 16));

    dotBottomLeftImage = createAreaPoint("dotBottomLeftImage", yellowTexture,
            (int) (currentX + currentWidth - 16), (int) (currentY - 16));
    dotBottomRightImage = createAreaPoint("dotBottomRightImage", yellowTexture,
            (int) (currentX + currentWidth - 16), (int) (currentY - 16));

    dotCenterImage = createAreaPoint("dotCenter", greenTexture, (int) (currentX + (currentWidth / 2) - 16),
            (int) (currentY + (currentHeight / 2) - 16));

    S3.stage.addActor(mainWindow);

    //
    // Assign Listener
    //
    mainWindow.addListener(new InputListener() {
        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {

            lastPointX = pointX;
            lastPointY = pointY;
            pointX = x;
            pointY = y;

            deltaX = pointX - lastPointX;
            deltaY = pointY - lastPointY;

            S3Log.log("dotCenterImage::touchDragged", " event: " + event + " x: " + x + " y: " + y
                    + " pointer: " + pointer + " deltaX: " + deltaX + " deltaY: " + deltaY, 3);

            if (pointClick != null) {
                S3Log.log("dotCenterImage::touchDragged",
                        " Point click: " + pointClickName + " aX: " + aspectRatioX + " aY: " + aspectRatioY, 2);
                if (pointClickName.equalsIgnoreCase("dotLeftImage")) {
                    if (currentX > 0 && deltaX < 0 && currentWidth >= 32) {
                        currentX += deltaX;
                        currentWidth -= deltaX;
                    } else if (currentX < S3Screen.width && deltaX > 0 && currentWidth > 32) {
                        currentX += deltaX;
                        currentWidth -= deltaX;
                    }
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotRightImage")) {
                    if (currentX + currentWidth > 0 && currentX + currentWidth < S3Screen.width
                            && currentWidth >= 32 && currentX > -1 && deltaX > 0) {
                        currentWidth += deltaX;
                    } else if (currentX + currentWidth > 0 && currentX + currentWidth <= S3Screen.width
                            && currentWidth >= 32 && currentX > -1 && deltaX < 0) {
                        currentWidth += deltaX;
                    }
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotTopImage")) {
                    if (currentY + currentHeight > 0 && currentY + currentHeight < S3Screen.height
                            && currentHeight >= 32 && currentY > -1 && deltaY > 0) {
                        currentHeight += deltaY;
                    } else if (currentY + currentHeight > 0 && currentY + currentHeight <= S3Screen.height
                            && currentHeight >= 32 && currentY > -1 && deltaY < 0) {
                        currentHeight += deltaY;
                    }
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotBottomImage")) {
                    if (currentY > 0 && deltaY < 0 && currentHeight >= 32) {
                        currentY += deltaY;
                        currentHeight -= deltaY;
                    } else if (currentY < S3Screen.height && deltaY > 0 && currentHeight > 32) {
                        currentY += deltaY;
                        currentHeight -= deltaY;
                    }
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotTopRightImage")) {
                    float delta = (deltaX + deltaY) / 2;
                    currentHeight += delta * aspectRatioY;
                    currentWidth += delta * aspectRatioX;
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotBottomLeftImage")) {
                    float delta = (deltaX + deltaY) / 2;
                    currentX += delta * aspectRatioX;
                    currentY += delta * aspectRatioY;
                    currentHeight -= delta * aspectRatioY;
                    currentWidth -= delta * aspectRatioX;
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotCenter")) {
                    currentX += deltaX;
                    currentY += deltaY;
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotTopLeftImage")) {
                    float delta = (deltaX - deltaY) / 2;
                    currentX += delta * aspectRatioY;
                    currentHeight -= delta * aspectRatioY;
                    currentWidth -= delta * aspectRatioY;
                    setAreaPosistion();
                    setTouchPosistion();
                } else if (pointClickName.equalsIgnoreCase("dotBottomRightImage")) {
                    float delta = (deltaX - deltaY) / 2;
                    currentY -= delta * aspectRatioY;
                    currentHeight += delta * aspectRatioY;
                    currentWidth += delta * aspectRatioY;
                    setAreaPosistion();
                    setTouchPosistion();
                }

                //
                // dotBottomRightImage

            } else if (isAreaImageClick) {
                currentX += deltaX;
                currentY += deltaY;
                setAreaPosistion();
                setTouchPosistion();
            }
        }

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            S3Log.log("dotCenterImage::touchDown", " event: " + event + " x: " + x + " y: " + y + " pointer: "
                    + pointer + " button: " + button, 3);

            pointX = x;
            pointY = y;
            lastPointX = x;
            lastPointY = y;

            isAreaImageClick = checkAreaClick(x, y);
            pointClick = checkPointClick(x, y);
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            S3Log.log("dotCenterImage::touchUp", " event: " + event + " x: " + x + " y: " + y + " pointer: "
                    + pointer + " button: " + button, 2);
            isAreaImageClick = false;
            pointClick = null;
            pointClickName = "";
        }
    });

    setAreaPosistion();
    setTouchPosistion();
}

From source file:name.herve.bastod.gui.screen.game.OverlayManager.java

License:Open Source License

public void renderUnitOverlay(Unit selected) {
    if (selected != null) {
        if (selected instanceof Tower) {
            int shotRange = (int) (((Tower) selected).getRangeOnBoard());
            String k = selected.getPlayer().getColor() + "-" + shotRange;

            if (!towerRanges.containsKey(k)) {
                int gfxSize = shotRange * 2;

                Blending bck = Pixmap.getBlending();
                Pixmap.setBlending(Blending.None);

                Pixmap p = new Pixmap(gfxSize, gfxSize, Pixmap.Format.RGBA8888);
                Color c = GUIResources.getInstance().getColor(selected.getPlayer().getColor()).cpy();
                c.a = 0.2f;/*from   www  .  java 2  s. c  o m*/
                p.setColor(c);
                p.fillCircle(shotRange, shotRange, shotRange);
                Texture t = new Texture(p);
                p.dispose();
                Pixmap.setBlending(bck);
                towerRanges.put(k, t);
            }

            batchBegin();
            draw(towerRanges.get(k), Engine._SP_SIDE + selected.getPositionOnBoard().getX() - shotRange,
                    Engine._SP_BOTTOM + selected.getPositionOnBoard().getY() - shotRange);
            batchEnd();
        }
    }
}

From source file:se.angergard.game.util.Util.java

License:Apache License

public static final Texture createSolidCircleTexture(Color color, int width, int height) {
    Pixmap map = new Pixmap(width, height, Format.RGBA8888);
    Color alpha = new Color(0, 0, 0, 0);
    map.setColor(alpha);/*from ww w. j a va  2 s .c o  m*/
    map.fill();
    map.setColor(color);
    map.fillCircle(width / 2, height / 2, ((width + height) / 2) / 2);
    Texture texture = new Texture(map);
    map.dispose();
    return texture;
}