Search in sources :

Example 1 with Bitmap2D

use of jcog.signal.Bitmap2D in project narchy by automenta.

the class AutoConceptualizerTest method test1.

@Test
public void test1() {
    int W = 4, H = 4;
    NAR n = NARS.tmp();
    Bitmap2DSensor c = new Bitmap2DSensor((x, y) -> $.p(x, y), new Bitmap2D() {

        @Override
        public int width() {
            return W;
        }

        @Override
        public int height() {
            return H;
        }

        @Override
        public float brightness(int xx, int yy) {
            return (((xx + yy + n.time())) % 2) > 0 ? 1f : 0f;
        }
    }, n);
    AutoConceptualizer ac = new AutoConceptualizer(c.iter.order, /* HACK */
    true, 2, n);
    for (int i = 0; i < 155; i++) {
        c.input();
        c.print(System.out);
        n.run(1);
        System.out.println();
    }
}
Also used : Bitmap2D(jcog.signal.Bitmap2D) Bitmap2DSensor(nars.util.signal.Bitmap2DSensor) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 2 with Bitmap2D

use of jcog.signal.Bitmap2D in project narchy by automenta.

the class Scale method update.

@Override
public void update() {
    if (src instanceof Bitmap2D)
        ((Bitmap2D) src).update();
    Image in = src.get();
    if (in == null)
        return;
    if (out == null || outgfx == null || out.getWidth() != pw || out.getHeight() != ph) {
        if (outgfx != null)
            outgfx.dispose();
        out = new BufferedImage(pw, ph, BufferedImage.TYPE_INT_RGB);
        // create a graphics object to paint to
        outgfx = out.createGraphics();
    // outgfx.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
    // RenderingHints.VALUE_INTERPOLATION_BICUBIC
    // //RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
    // );
    // outgfx.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
    // RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY
    // //RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED
    // );
    // outgfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    // RenderingHints.VALUE_ANTIALIAS_ON
    // //RenderingHints.VALUE_ANTIALIAS_OFF
    // );
    }
    outgfx.setColor(Color.BLACK);
    // TODO add fade option
    outgfx.fillRect(0, 0, pw, ph);
    // boolean stillChanging =
    // outgfx.drawImage(in, 0, 0, pw, ph, this); //draw the image scaled
    /*
            public abstract boolean drawImage(Image img,
                                      int dx1, int dy1, int dx2, int dy2,
                                      int sx1, int sy1, int sx2, int sy2,
                                      Color bgcolor,
                                      ImageObserver observer);
         */
    int sw = in.getWidth(null);
    int sh = in.getHeight(null);
    boolean stillChanging = outgfx.drawImage(in, 0, 0, pw, ph, Math.round(sx1 * sw), Math.round(sy1 * sh), Math.round(sx2 * sw), Math.round(sy2 * sh), Color.BLACK, this);
    if (stillChanging) {
        // TODO better handling here
        Thread.yield();
    }
}
Also used : Bitmap2D(jcog.signal.Bitmap2D) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage)

Aggregations

Bitmap2D (jcog.signal.Bitmap2D)2 BufferedImage (java.awt.image.BufferedImage)1 NAR (nars.NAR)1 Bitmap2DSensor (nars.util.signal.Bitmap2DSensor)1 Test (org.junit.jupiter.api.Test)1