Package org.terasology.math

Examples of org.terasology.math.Rect2i


                int cellOffsetX = rowOffsetX;
                for (int i = 0; i < row.size(); ++i) {
                    UIWidget widget = row.get(i);
                    int rowHeight = rowInfo.height;
                    if (widget != null) {
                        Rect2i drawRegion = Rect2i.createFromMinAndSize(cellOffsetX, rowOffsetY, minWidths[i], rowHeight);
                        canvas.drawWidget(widget, drawRegion);
                    }
                    cellOffsetX += minWidths[i] + horizontalSpacing;
                }
                rowOffsetY += rowInfo.height + verticalSpacing;
View Full Code Here


        sliderWidth = canvas.size().x - tickerWidth * 2;
        int drawLocation = pixelOffsetFor(value.get(), sliderWidth);
        if (rightTicker) {
            drawLocation += tickerWidth;
        }
        Rect2i tickerRegion = Rect2i.createFromMinAndSize(drawLocation, 0, tickerWidth, canvas.size().y);
        try (SubRegion ignored = canvas.subRegion(tickerRegion, false)) {
            canvas.drawBackground();
            canvas.drawText(display);
            canvas.addInteractionRegion(tickerListener);
        }
View Full Code Here

            Font font = canvas.getCurrentStyle().getFont();
            Border itemMargin = canvas.getCurrentStyle().getMargin();
            int height = (font.getLineHeight() + itemMargin.getTotalHeight()) * options.get().size() + canvas.getCurrentStyle().getBackgroundBorder().getTotalHeight();
            canvas.addInteractionRegion(mainListener, Rect2i.createFromMinAndSize(0, 0, canvas.size().x, canvas.size().y + height));

            Rect2i location = Rect2i.createFromMinAndSize(0, canvas.size().y, canvas.size().x, height);
            canvas.drawBackground(location);

            int itemHeight = itemMargin.getTotalHeight() + font.getLineHeight();
            canvas.setPart(LIST_ITEM);
            for (int i = 0; i < optionListeners.size(); ++i) {
                if (optionListeners.get(i).isMouseOver()) {
                    canvas.setMode(HOVER_MODE);
                } else {
                    canvas.setMode(DEFAULT_MODE);
                }
                Rect2i itemRegion = Rect2i.createFromMinAndSize(0, canvas.size().y + itemHeight * i, canvas.size().x, itemHeight);
                canvas.drawBackground(itemRegion);
                optionRenderer.draw(options.get().get(i), canvas, itemMargin.shrink(itemRegion));
                canvas.addInteractionRegion(optionListeners.get(i), itemRegion);
            }
        } else {
View Full Code Here

    public void process(GeneratingRegion region) {
        Border3D border = region.getBorderForFacet(SurfaceHeightFacet.class);
        SurfaceHeightFacet facet = new SurfaceHeightFacet(region.getRegion(), border);
        SeaLevelFacet seaLevelFacet = region.getRegionFacet(SeaLevelFacet.class);
        float seaLevel = seaLevelFacet.getSeaLevel();
        Rect2i processRegion = facet.getWorldRegion();
        float[] noise = surfaceNoise.noise(processRegion);

        for (int i = 0; i < noise.length; ++i) {
            noise[i] = seaLevel + seaLevel * ((noise[i] + 1f) / 2f);
        }
View Full Code Here

        for (HUDElement element : elementsLookup.values()) {
            int minX = TeraMath.floorToInt(element.region.minX() * canvas.size().x);
            int minY = TeraMath.floorToInt(element.region.minY() * canvas.size().y);
            int sizeX = TeraMath.floorToInt(element.region.width() * canvas.size().x);
            int sizeY = TeraMath.floorToInt(element.region.height() * canvas.size().y);
            Rect2i region = Rect2i.createFromMinAndSize(minX, minY, sizeX, sizeY);
            canvas.drawWidget(element.widget, region);
        }
    }
View Full Code Here

        ByteBuffer buf = ByteBuffer.allocateDirect(size);
        for (int y = 0; y < height; ++y) {
            for (int x = 0; x < width; ++x) {
                int px = (x + offX) * scale;
                int py = (y + offY) * scale;
                Rect2i area = Rect2i.createFromMinAndSize(px, py, scale, scale);
                Color c = previewGenerator.get(layerName, area);
                c.addToBuffer(buf);
            }
            if (Thread.currentThread().isInterrupted()) {
                throw new InterruptedException();
View Full Code Here

        ports.add(addLastPortIns);
        this.node = node;
    }

    public void onDraw(Canvas canvas) {
        Rect2i region = canvas.getRegion();
        inputPort.updateRect();
        canvas.drawWidget(inputPort, Rect2i.createFromMinAndMax(
                (int) (inputPort.rect.minX() / 10.f * region.width()),
                (int) (inputPort.rect.minY() / 5.f * region.height()),
                (int) (inputPort.rect.maxX() / 10.f * region.width()),
                (int) (inputPort.rect.maxY() / 5.f * region.height())));
        for (Port port : ports) {
            port.updateRect();
            canvas.drawWidget(port, Rect2i.createFromMinAndMax(
                    (int) (port.rect.minX() / 10.f * region.width()),
                    (int) (port.rect.minY() / 5.f * region.height()),
                    (int) (port.rect.maxX() / 10.f * region.width()),
                    (int) (port.rect.maxY() / 5.f * region.height())));
        }
    }
View Full Code Here

        if (!contents.isEmpty()) {
            int xOffset = 0;
            for (int i = 0; i < contents.size(); ++i) {
                int itemWidth = widths.get(i);
                Rect2i region = Rect2i.createFromMinAndSize(xOffset, 0, itemWidth, canvas.size().y);
                canvas.drawWidget(contents.get(i), region);
                xOffset += itemWidth;
                xOffset += horizontalSpacing;
            }
        }
View Full Code Here

        sliderSize = canvas.size().y - canvas.getCurrentStyle().getFixedHeight();

        if (sliderSize > 0) {
            int drawLocation = pixelOffsetFor(getValue());
            handleSize = canvas.getCurrentStyle().getFixedHeight();
            Rect2i handleRegion = Rect2i.createFromMinAndSize(0, drawLocation, canvas.getCurrentStyle().getFixedWidth(), handleSize);
            canvas.drawBackground(handleRegion);
            canvas.addInteractionRegion(handleListener, handleRegion);
        }
    }
View Full Code Here

            return sizeRestrictions;
        }

        String family = (widget.getFamily() != null) ? widget.getFamily() : state.family;
        UIStyle elementStyle = state.skin.getStyleFor(family, widget.getClass(), UIWidget.BASE_PART, widget.getMode());
        Rect2i region = applyStyleToSize(Rect2i.createFromMinAndSize(Vector2i.zero(), sizeRestrictions), elementStyle);
        try (SubRegion ignored = subRegionForWidget(widget, region, false)) {
            Vector2i preferredSize = widget.getPreferredContentSize(this, elementStyle.getMargin().shrink(sizeRestrictions));
            preferredSize = elementStyle.getMargin().grow(preferredSize);
            return applyStyleToSize(preferredSize, elementStyle);
        }
View Full Code Here

TOP

Related Classes of org.terasology.math.Rect2i

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.