1 package sample;
2
3 import static fi.jyu.mit.graphics.Bitmap.packRGB;
4 import fi.jyu.mit.graphics.Bitmap;
5 import fi.jyu.mit.graphics.EasyWindow;
6 import static java.lang.Math.*;
7
8
13 public class BitmapEmptySample {
14
15
21 public static void main(String[] args) {
22 Bitmap bm = new Bitmap(0,0,200,200);
23 EasyWindow window = new EasyWindow(bm.getWidth()+50,bm.getHeight()+50);
24 window.add(bm);
25 int musta = packRGB(0,0,0);
26 int keltainen = packRGB(255,255,0);
27 int punainen = packRGB(255,0,0);
28 int m = bm.getWidth();
29
30 int [][] data = bm.getData();
31
32 for (int iy=0; iy<data.length;iy++) {
33 for (int ix=0; ix<data[iy].length;ix++) {
34 int c = keltainen;
35 if ( abs(iy-ix) < 10 ) c = musta; if ( abs(iy+ix-m) < 10 ) c = punainen; data[iy][ix] = c;
38 }
39 }
40 bm.setData(0,0,data);
41 bm.redraw();
42 }
43
44 }
45