当前位置: 首页>>代码示例>>Java>>正文


Java PPath.offset方法代码示例

本文整理汇总了Java中org.piccolo2d.nodes.PPath.offset方法的典型用法代码示例。如果您正苦于以下问题:Java PPath.offset方法的具体用法?Java PPath.offset怎么用?Java PPath.offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.piccolo2d.nodes.PPath的用法示例。


在下文中一共展示了PPath.offset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
    final PLayer layer = getCanvas().getLayer();

    final Random random = new Random();
    for (int i = 0; i < 1000; i++) {
        final PPath each = PPath.createRectangle(0, 0, 100, 80);
        each.scale(random.nextFloat() * 2);
        each.offset(random.nextFloat() * 10000, random.nextFloat() * 10000);
        each.setPaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
        each.setStroke(new BasicStroke(1 + 10 * random.nextFloat()));
        each.setStrokePaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
        layer.addChild(each);
    }
    getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());
    getCanvas().addInputEventListener(new PNavigationEventHandler());
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:17,代码来源:NavigationExample.java

示例2: testRenderFull

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void testRenderFull() {
    final POffscreenCanvas canvas = new POffscreenCanvas(100, 200);
    final PPath rect = PPath.createRectangle(0.0f, 0.0f, 200.0f, 300.0f);
    rect.setPaint(new Color(255, 0, 0));
    rect.setStroke(null);
    rect.offset(-100.0d, -100.0d);
    canvas.getCamera().getLayer(0).addChild(rect);
    final BufferedImage image = new BufferedImage(100, 200, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D graphics = image.createGraphics();
    canvas.render(graphics);
    for (int x = 0; x < 100; x++) {
        for (int y = 0; y < 200; y++) {
            // red pixel, RGBA is 255, 0, 0, 255
            assertEquals(-65536, image.getRGB(x, y));
        }
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:18,代码来源:POffscreenCanvasTest.java

示例3: initialize

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {

        PPath eacha = PPath.createRectangle(50, 50, 300, 300);
        eacha.setPaint(Color.red);
        getCanvas().getLayer().addChild(eacha);

        eacha = PPath.createRectangle(-50, -50, 100, 100);
        eacha.setPaint(Color.green);
        getCanvas().getLayer().addChild(eacha);

        eacha = PPath.createRectangle(350, 350, 100, 100);
        eacha.setPaint(Color.green);
        getCanvas().getLayer().addChild(eacha);

        getCanvas().getCamera().addInputEventListener(new PBasicInputEventHandler() {
            public void mousePressed(final PInputEvent event) {
                if (!(event.getPickedNode() instanceof PCamera)) {
                    event.setHandled(true);
                    getCanvas().getCamera().animateViewToPanToBounds(event.getPickedNode().getGlobalFullBounds(), 500);
                }
            }
        });

        final PLayer layer = getCanvas().getLayer();

        final Random random = new Random();
        for (int i = 0; i < 1000; i++) {
            final PPath each = PPath.createRectangle(0, 0, 100, 80);
            each.scale(random.nextFloat() * 2);
            each.offset(random.nextFloat() * 10000, random.nextFloat() * 10000);
            each.setPaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
            each.setStroke(new BasicStroke(1 + 10 * random.nextFloat()));
            each.setStrokePaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
            layer.addChild(each);
        }

        getCanvas().removeInputEventListener(getCanvas().getZoomEventHandler());
    }
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:39,代码来源:PanToExample.java

示例4: OffscreenCanvasExample

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
/**
 * Create a new offscreen canvas example with the specified graphics device.
 * 
 * @param device graphics device
 */
public OffscreenCanvasExample(final GraphicsDevice device) {
    final GraphicsConfiguration configuration = device.getDefaultConfiguration();
    frame = new Frame(configuration);
    frame.setUndecorated(true);
    frame.setIgnoreRepaint(true);
    frame.setBounds(100, 100, 400, 400);
    frame.setVisible(true);
    frame.createBufferStrategy(2);

    canvas = new POffscreenCanvas(400, 400);

    final PText text = new PText("Offscreen Canvas Example");
    text.setFont(text.getFont().deriveFont(32.0f));
    text.setTextPaint(new Color(200, 200, 200));
    text.offset(200.0f - text.getWidth() / 2.0f, 200.0f - text.getHeight() / 2.0f);

    final PPath rect = PPath.createRectangle(0.0f, 0.0f, 360.0f, 360.0f);
    rect.setPaint(new Color(20, 20, 20, 80));
    rect.setStroke(new BasicStroke(2.0f));
    rect.setStrokePaint(new Color(20, 20, 20));
    rect.offset(20.0f, 20.0f);

    canvas.getCamera().getLayer(0).addChild(text);
    canvas.getCamera().getLayer(0).addChild(rect);

    final Rectangle2D right = new Rectangle2D.Double(200.0f, 200.0f, 800.0f, 800.0f);
    final Rectangle2D left = new Rectangle2D.Double(-200.0f, 200.0f, 225.0f, 225.0f);
    final Rectangle2D start = new Rectangle2D.Double(0.0f, 0.0f, 400.0f, 400.0f);
    final PActivity toRight = canvas.getCamera().animateViewToCenterBounds(right, true, 5000);
    final PActivity toLeft = canvas.getCamera().animateViewToCenterBounds(left, true, 5000);
    final PActivity toStart = canvas.getCamera().animateViewToCenterBounds(start, true, 5000);
    toLeft.startAfter(toRight);
    toStart.startAfter(toLeft);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:40,代码来源:OffscreenCanvasExample.java


注:本文中的org.piccolo2d.nodes.PPath.offset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。