9 #include <X11/keysym.h>
11 //VGint x_pos = -10, y_pos = -10;
12 VGint x_pos
= 0, y_pos
= 4;
13 VGint img_width
= 120, img_height
= 120;
15 static void RectToPath(VGPath path
, VGfloat x
, VGfloat y
, VGfloat width
, VGfloat height
)
17 static const VGubyte segments
[5] = {VG_MOVE_TO_ABS
,
30 vgAppendPathData(path
, 5, segments
, data
);
38 /* new window size or exposure */
44 int key_press(unsigned key
)
70 fprintf(stderr
, "Posi = %dx%d\n", x_pos
, y_pos
);
71 fprintf(stderr
, "Size = %dx%d\n", img_width
, img_height
);
78 VGint WINDSIZEX
= window_width();
79 VGint WINDSIZEY
= window_height();
83 VGfloat color
[4] = {1.f
, 0.f
, 0.f
, 1.f
};
84 VGfloat bgCol
[4] = {0.7f
, 0.7f
, 0.7f
, 1.0f
};
85 VGfloat transCol
[4] = {0.f
, 0.f
, 0.f
, 0.f
};
86 VGImage image
= vgCreateImage(VG_sRGBA_8888
, img_width
, img_height
,
87 VG_IMAGE_QUALITY_NONANTIALIASED
);
89 /* Background clear */
90 fill
= vgCreatePaint();
91 vgSetParameterfv(fill
, VG_PAINT_COLOR
, 4, color
);
92 vgSetPaint(fill
, VG_FILL_PATH
);
94 box
= vgCreatePath(VG_PATH_FORMAT_STANDARD
, VG_PATH_DATATYPE_F
,
95 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL
);
96 /* Rectangle to cover completely 16x16 pixel area. */
97 RectToPath(box
, 0, 0, 64, 64);
99 vgSetfv(VG_CLEAR_COLOR
, 4, transCol
);
100 vgClearImage(image
, 0, 0, img_width
, img_height
);
101 vgSetfv(VG_CLEAR_COLOR
, 4, color
);
102 vgClearImage(image
, 10, 10, 12, 12);
103 //vgImageSubData(image, pukki_64x64_data, pukki_64x64_stride,
104 // VG_sRGBA_8888, 0, 0, 32, 32);
105 vgSeti(VG_MASKING
, VG_TRUE
);
108 vgSetfv(VG_CLEAR_COLOR
, 4, bgCol
);
109 vgClear(0, 0, WINDSIZEX
, WINDSIZEY
);
112 vgMask(image
, VG_FILL_MASK
, 0, 0, window_width(), window_height());
113 vgMask(image
, VG_SET_MASK
, x_pos
, y_pos
, 100, 100);
115 vgDrawPath(box
, VG_FILL_PATH
);
117 //vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
118 //vgTranslate(-10, -10);
119 //vgDrawImage(image);
122 vgDestroyPaint(fill
);
127 int main(int argc
, char **argv
)
129 set_window_size(64, 64);
130 return run(argc
, argv
, init
, reshape
,