GR.OPEN         0,0,0,40,0,-1 ! main parameters -------------- ARRAY.LOAD      nCtrl[], 60, 120, 180 , 240 ARRAY.LOAD      nCols[], 6,  8,   10  , 12 ARRAY.LOAD      rad[],   36, 30,  27  , 23 butType       = 2 variant       = 1 scale         = 1.1 nctrl         = nCtrl [variant] nCols         = nCols [variant] rad           = rad   [variant]  / scale GR.SCALE        scale, scale GOSUB          init  !main loop ----------------- DO PAUSE 33 UNTIL0 !------------------------ END !callbackRoutines (but individual) ------------ _1::  PRINT "button: ";1  : RETURN  _2::  PRINT "button: ";2  : RETURN  _3::  PRINT "button: ";3  : RETURN  _4::  PRINT "button: ";4  : RETURN  _5::  PRINT "button: ";5  : RETURN  _6::  PRINT "button: ";6  : RETURN  _7::  PRINT "button: ";7  : RETURN  _8::  PRINT "button: ";8  : RETURN  _9::  PRINT "button: ";9  : RETURN  _10:: PRINT "button: ";10 : RETURN  !   ....and so on  !------------------------------------ !press action (all buts) -------- butPressAction: RETURN !------------------------ !release action (all buts) ------ butReleaseAction: txt$         += CHR$(48+ curBut ) IF              !MOD(LEN(txt$),20) THEN  txt$ =""+CHR$(48+curBut) GR.MODIFY       txt1, "text", txt$ VIBRATE         vib2[],-1 RETURN !------------------------ !=========================================== !Private part ============================== !------------------------ ONGRTOUCH: tic= CLOCK() GOSUB           butPressAction curBut        = 0 DO tic= CLOCK() GR.TOUCH       tou,tx,ty GR.MODIFY      dum ,"x", tx /scale , "y", ty /scale FOR i        = 1 TO nctrl   IF            GR_COLLISION(ctrl[i],dum) THEN GOSUB colliHandle NEXT UNTIL           !tou IF               curBut GR.MODIFY       ctrl[curBut], "alpha", 255 GOSUB           curBut, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10 GOSUB           butReleaseAction GR.RENDER ENDIF GR.ONGRTOUCH.RESUME !------------------------ !------------------------ colliHandle: PRINT            CLOCK()-tic IF               i <> curBut THEN VIBRATE         vib1[],-1 IF              curBut THEN GR.MODIFY ctrl[curBut], "alpha", 255 GR.MODIFY       ctrl[i]       , "alpha", 150 curBut        = i tic= CLOCK() GR.RENDER PRINT            CLOCK()-tic ENDIF RETURN !------------------------ !------------------------------- init:  GOSUB           userfun GR.COLOR        0 ,255,0,0,1 GR.CIRCLE       dum, 0,0,0 ARRAY.LOAD      vib1[],0,20 ARRAY.LOAD      vib2[],0,10 ! colors ---------------------- ! now below GR.PAINT.GET    colorIdx ! create button grid ---------- rcr           = roundCornerRect (rad*2, rad*2, 10) DIM             ctrl[nctrl] kx            = 2*rad*1.30 ky            = 2*rad*1.15 FOR i         = 0 TO nctrl-1 x            = 50  + MOD(i,nCols) *kx  + MOD(INT(i/nCols),2) *kx/2 y            = 150 + INT(i/nCols) *ky  ctrl[i+1]    = butCreate (x, y ,rad, colorIdx,CHR$(48+i), butType ) NEXT ! text bar for feedback ------- GR.TEXT.ALIGN   1 GR.TEXT.SIZE    50 GR.COLOR        255, 120,120,255,1 GR.TEXT.DRAW    txt1, 50, 60 ,"--" GR.RENDER RETURN ! ------------------------ !------------------------ userfun: FN.DEF          butCreate (x,y,rad, color, txt$,type)  GR.TEXT.SIZE    rad*1.3 GR.SET.STROKE   4 GR.TEXT.ALIGN   2 GR.TEXT.BOLD    1 GR.BITMAP.CREATE   bmp,2*rad+1,2*rad+1 GR.BITMAP.DRAW     nn, bmp, x,y GR.BITMAP.DRAWINTO.START bmp IF type     = 1    GR.COLOR        255, 40  , 00  , 140 , 1    GR.RECT         nn , 0, 0, 2*rad, 2*rad   GR.COLOR        255, 120 , 120 , 255 , 0   GR.RECT         nn , 1 ,1, 2*rad,2*rad   GR.COLOR        255, 00  , 00  , 45  , 0   GR.RECT         nn , 3, 3, 2*rad+1, 2*rad+1 ELSEIF type     = 2   GR.COLOR        255, 40  , 00  , 140 , 1    GR.CIRCLE       nn , rad,rad,rad   GR.COLOR        255, 120 , 120 , 255 , 0   GR.CIRCLE       nn ,  rad,rad,rad-2   GR.COLOR        255, 00  , 00  , 45  , 0   GR.CIRCLE       nn , rad+1,rad+1,rad-2 ELSEIF type     = 3   GR.COLOR        255, 40  , 00  , 140 , 1    GR.POLY         nn , 1, rad, rad   GR.COLOR        255, 120 , 120 , 255 , 0   GR.POLY         nn , 1, rad, rad   GR.COLOR        255, 00  , 00  , 45  , 0   GR.POLY         nn , 1, rad+1, rad+1 ENDIF GR.COLOR        255, 255 , 120 , 120 , 1 GR.TEXT.DRAW   nn, rad,rad*1.5,txt$ GR.COLOR        255, 90  , 20  , 10  , 1 GR.TEXT.DRAW   nn, rad+2,rad*1.5+2,txt$ GR.BITMAP.DRAWINTO.END FN.RTN         nn FN.END FN.DEF                roundCornerRect (b, h, r) dphi               = PI()/2 / 8 LIST.CREATE          N, S1 FOR phi            = 0 TO PI()/2 STEP dphi   LIST.ADD            s1, -b/2+r -COS(phi)*r, -h/2+r -SIN(phi)*r NEXT FOR phi            = 0 TO PI()/2 STEP dphi   LIST.ADD            s1,  b/2-r +SIN(phi)*r, -h/2+r -COS(phi)*r NEXT FOR phi            = 0 TO PI()/2 STEP dphi   LIST.ADD            s1,  b/2-r +COS(phi)*r,  h/2-r +SIN(phi)*r NEXT FOR phi            = 0 TO PI()/2 STEP dphi   LIST.ADD            s1, -b/2+r -SIN(phi)*r,  h/2-r +COS(phi)*r NEXT FN.RTN s1 FN.END RETURN !------------------------ !===========================================