git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@62 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-29 08:22:34 +00:00
parent ed7dc61897
commit 002e721a31
4 changed files with 77 additions and 68 deletions

View File

@@ -12,22 +12,22 @@
#define SIZE 100
MwWidget buttons[6];
double deg = 0;
double deg = 0;
int ww, wh;
void handler(MwWidget w, void* user, void* client){
int i;
void handler(MwWidget w, void* user, void* client) {
int i;
double cdeg = deg;
(void)w;
(void)user;
(void)client;
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++){
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
double rad = cdeg / 180 * M_PI;
int x = ww / 2;
int y = wh / 2;
int x = ww / 2;
int y = wh / 2;
x += cos(rad) * (ww / 2 - SIZE / 2);
y += sin(rad) * (wh / 2 - SIZE / 2);
@@ -36,9 +36,9 @@ void handler(MwWidget w, void* user, void* client){
y -= SIZE / 2;
MwVaApply(buttons[i],
MwNx, x,
MwNy, y,
NULL);
MwNx, x,
MwNy, y,
NULL);
cdeg += 360 / (sizeof(buttons) / sizeof(buttons[0]));
}
@@ -46,7 +46,7 @@ void handler(MwWidget w, void* user, void* client){
deg += 120.0 / (1000.0 / MwWaitMS);
}
void resize(MwWidget w, void* user, void* client){
void resize(MwWidget w, void* user, void* client) {
(void)w;
(void)user;
(void)client;
@@ -55,16 +55,16 @@ void resize(MwWidget w, void* user, void* client){
wh = MwGetInteger(w, MwNheight);
}
int main(){
int main() {
MwWidget window = MwVaCreateWidget(MwWindowClass, "window", NULL, 0, 0, (ww = 500), (wh = 500),
MwNtitle, "rotate",
NULL);
int i;
MwNtitle, "rotate",
NULL);
int i;
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++){
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
const char* color = "";
char fgcolor[5];
int j;
char fgcolor[5];
int j;
if(i == 0) color = "#f66";
if(i == 1) color = "#6f6";
@@ -75,15 +75,15 @@ int main(){
fgcolor[0] = '#';
fgcolor[4] = 0;
for(j = 0; j < 3; j++){
for(j = 0; j < 3; j++) {
fgcolor[j + 1] = color[j + 1] == 'f' ? '6' : 'f';
}
buttons[i] = MwVaCreateWidget(MwButtonClass, "button", window, 0, 0, SIZE, SIZE,
MwNbackground, color,
MwNforeground, fgcolor,
MwNtext, "fancy",
NULL);
MwNbackground, color,
MwNforeground, fgcolor,
MwNtext, "fancy",
NULL);
}
MwAddUserHandler(window, MwNtickHandler, handler, NULL);