Package com.tinyline.tiny2d

Examples of com.tinyline.tiny2d.Tiny2D


        TinyBuffer pixbuf = new TinyBuffer();
        pixbuf.width = tile.width;
        pixbuf.height = tile.height;
        pixbuf.pixels32 = tile.pixels32;

        Tiny2D t2d = new Tiny2D(pixbuf);
        t2d.antialias = true;
        TinyRect clip = t2d.getClip();
        t2d.devClip = clip;
        t2d.clearRect(clip);
        t2d.invalidate();
        return t2d;
    }
View Full Code Here


            tile.pixels32[(cy + 1) * tile.width + cx + 1] = gobanMarkColor;
        }
    }

    void drawStone(final Tile tile, boolean black) {
        Tiny2D t2d = getT2D(tile);

        t2d.strokeColor = new TinyColor(blackStoneColor);
        t2d.strokeWidth = ONE;
        if (black)
            t2d.fillColor = t2d.strokeColor;
        else
            t2d.fillColor = new TinyColor(whiteStoneColor);

        t2d.drawOval(daAnchorX, daAnchorY, daWidth(tile), daHeight(tile));
        //t2d.drawLine(arg0, arg1, arg2, arg3)
    }
View Full Code Here

        t2d.drawOval(daAnchorX, daAnchorY, daWidth(tile), daHeight(tile));
        //t2d.drawLine(arg0, arg1, arg2, arg3)
    }

    void drawCircle(final Tile tile, boolean black) {
        Tiny2D t2d = getT2D(tile);
        setT2DPureMark(t2d, tile, black);

        int wH = daWidth(tile) >> 1;
        int hH = daHeight(tile) >> 1;
        int wQ = wH >> 1;
        int hQ = hH >> 1;
        t2d.drawOval(daAnchorX + wQ, daAnchorY + hQ, wH, hH);
    }
View Full Code Here

        int hQ = hH >> 1;
        t2d.drawOval(daAnchorX + wQ, daAnchorY + hQ, wH, hH);
    }

    void drawSelected(final Tile tile, boolean black) {
        Tiny2D t2d = getT2D(tile);
        //t2d.strokeWidth = ONE;
        //t2d.strokeColor = new TinyColor(selectedColor);
        t2d.fillColor = new TinyColor(selectedColor);

        int wH = daWidth(tile) >> 1;
        int hH = daHeight(tile) >> 1;
        int wQ = wH >> 1;
        int hQ = hH >> 1;
        t2d.drawRect(daAnchorX + wQ, daAnchorY + hQ, wH, hH);
    }
View Full Code Here

        int hQ = hH >> 1;
        t2d.drawRect(daAnchorX + wQ, daAnchorY + hQ, wH, hH);
    }

    void drawCross(final Tile tile, boolean black) {
        Tiny2D t2d = getT2D(tile);
        setT2DPureMark(t2d, tile, black);

        int wH = daWidth(tile) >> 1;
        int hH = daHeight(tile) >> 1;
        int wQ = wH >> 1;
        int hQ = hH >> 1;
        t2d.drawLine(daAnchorX + wQ, daAnchorY + hQ, daAnchorX + wH + wQ, daAnchorY + hH + hQ);
        t2d.drawLine(daAnchorX + wQ, daAnchorY + hH + hQ, daAnchorX + wH + wQ, daAnchorY + hQ);
    }
View Full Code Here

        t2d.drawLine(daAnchorX + wQ, daAnchorY + hQ, daAnchorX + wH + wQ, daAnchorY + hH + hQ);
        t2d.drawLine(daAnchorX + wQ, daAnchorY + hH + hQ, daAnchorX + wH + wQ, daAnchorY + hQ);
    }

    void drawSquare(final Tile tile, boolean black) {
        Tiny2D t2d = getT2D(tile);
        setT2DPureMark(t2d, tile, black);

        int wH = daWidth(tile) >> 1;
        int hH = daHeight(tile) >> 1;
        int wQ = wH >> 1;
        int hQ = hH >> 1;
        t2d.drawRect(daAnchorX + wQ, daAnchorY + hQ, wH, hH);
    }
View Full Code Here

        int hQ = hH >> 1;
        t2d.drawRect(daAnchorX + wQ, daAnchorY + hQ, wH, hH);
    }

    void drawTriangle(final Tile tile, boolean black) {
        Tiny2D t2d = getT2D(tile);
        setT2DPureMark(t2d, tile, black);

        int wH = daWidth(tile) >> 1;
        int hH = daHeight(tile) >> 1;
        int triangleYTop = wH - ONE;
        int triangleXBottom = triangleYTop * 866 / 1000; // * sqrt(3)/2
        int triangleYBottom = triangleYTop / 2;
        TinyVector poly = new TinyVector(3);
        poly.addElement(new TinyPoint(daAnchorX + wH, daAnchorY + hH - triangleYTop));
        poly.addElement(new TinyPoint(daAnchorX + wH + triangleXBottom, daAnchorY + hH + triangleYBottom));
        poly.addElement(new TinyPoint(daAnchorX + wH - triangleXBottom, daAnchorY + hH + triangleYBottom));
        t2d.drawPolygon(poly);
    }
View Full Code Here

        poly.addElement(new TinyPoint(daAnchorX + wH - triangleXBottom, daAnchorY + hH + triangleYBottom));
        t2d.drawPolygon(poly);
    }

    void drawLabel(final Tile tile, boolean black, String label) {
        Tiny2D t2d = getT2D(tile);
        setT2DPureMark(t2d, tile, black);
        t2d.fillColor = t2d.strokeColor;
        t2d.strokeColor = TinyColor.NONE;

        int wH = daWidth(tile) >> 1;
        int hH = daHeight(tile) >> 1;
        int stoneSize = daWidth(tile);
        int fontSize = stoneSize;
        TinyFont font = MyArial.getFont();

        char[] text = label.toCharArray();
        TinyRect cbox;
        // calculate fontSize, so the number fits into stone
        while (true) {
            cbox = Tiny2D.charsBounds(font, fontSize, text, 0, text.length, Tiny2D.TEXT_DIR_LR);
            // add one pixel from each side, so the number won't blent with stone border
            if (cbox.xmax - cbox.xmin + ONE * 2 >= stoneSize)
                fontSize -= HALF;
            else
                break;
        }
        t2d.drawChars(font, fontSize, text, 0, text.length,
                daAnchorX + wH - (cbox.xmax - cbox.xmin) / 2,
                // same baseline for any text
                daAnchorY + hH + fontSize * (font.ascent + font.descent) / font.unitsPerEm / 2,
                Tiny2D.TEXT_ANCHOR_START);
    }
View Full Code Here

                daAnchorY + hH + fontSize * (font.ascent + font.descent) / font.unitsPerEm / 2,
                Tiny2D.TEXT_ANCHOR_START);
    }

    void drawLabelBackground(final Tile tile) {
        Tiny2D t2d = getT2D(tile);
        t2d.fillColor = new TinyColor(gobanColor);
        t2d.drawOval(daAnchorX, daAnchorY, daWidth(tile), daHeight(tile));
    }
View Full Code Here

        t2d.fillColor = new TinyColor(gobanColor);
        t2d.drawOval(daAnchorX, daAnchorY, daWidth(tile), daHeight(tile));
    }

    void drawTerritory(final Tile tile, boolean black) {
        Tiny2D t2d = getT2D(tile);
        int color = black ? moyoBlackColor : moyoWhiteColor;
        t2d.fillColor = new TinyColor(color);

        int wH = daWidth(tile) >> 1;
        int hH = daHeight(tile) >> 1;
        int wQ = wH >> 1;
        int hQ = hH >> 1;
//        t2d.drawOval(daAnchorX + wQ, daAnchorY + hQ, wH, hH);
        t2d.drawRect(daAnchorX + wQ, daAnchorY + hQ, wH, hH);
    }
View Full Code Here

TOP

Related Classes of com.tinyline.tiny2d.Tiny2D

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.