Author |
Topic: Custom Donut Button BMP file maker (Read 350 times) |
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Custom Donut Button BMP file maker
« Thread started on: Mar 15th, 2016, 04:16am » |
|
You can place the image anywhere on the screen... as well it will automatically save the image, no matter where it sits) UPDATED MARCH 16 2016 (BETTER CROPS) Code:
REM SET MODE TO 8 USING VDU
VDU 22,8
REM SET LINE THICKNESS TO 3
VDU 23,23,3|
OFF
GCOL 1
REM believe me... this was tough to get right
REM "filename",H,V,R,G,B - you dont need to add .BMP to the filename
PROC_donut("donut1",100,100,200,200,200)
PROC_donut("donut2",200,200,150,200,200)
PROC_donut("donut3",300,300,200,200,150)
PROC_donut("donut4",400,400,200,150,200)
(mou)
GOTO (mou)
DEF PROC_donut(filename$,H,V,RR,GG,BB)
PROC_ellipsering(3,3,H,V,30,40,RR,GG,BB,10)
PROC_sphere(H,V,10,RR,GG,BB,7)
filename$=filename$+".BMP"
file1$=@usr$+ filename$
h$=STR$(H-40)
v$=STR$(V-40)
size$=STR$(80)
combinit$=h$+","+v$+","+size$+","+size$
pos1$=combinit$
OSCLI "SCREENSAVE "+file1$+" "+pos1$
ENDPROC
DEF PROC_ellipsering(CENTERH,CENTERV,H,V,SIZE,THICKNESS,X,C,A,DI)
IF SIZE > THICKNESS THEN SIZE = THICKNESS
OC=THICKNESS/2
OUTCENTERH=CENTERH+OC
OUTCENTERV=CENTERV+OC
R=0
SWITCH=0
DEPTHCOUNT=SIZE/2
FOR Y=1 TO DEPTHCOUNT
COLOUR 1,X,C,A
ELLIPSE H,V,OUTCENTERH-R,OUTCENTERV-R
ELLIPSE H,V,OUTCENTERH+R,OUTCENTERV+R
R=R+1
(leap)
X=X-DI
C=C-DI
A=A-DI
IF X<2 THEN X=2
IF C<2 THEN C=2
IF A<2 THEN A=2
NEXT Y
ENDPROC
ENDPROC
DEF PROC_sphere(H,V,SIZE,R,G,B,DI)
r%=R
g%=G
b%=B
size%=SIZE
dimmer%=DI
FOR x%=0 TO size%
c%=50
r%=r%-dimmer%
g%=g%-dimmer%
b%=b%-dimmer%
IF r% <2 THEN r%=2
IF g% <2 THEN g%=2
IF b%<2 THEN b%=2
IF r%<50 AND g%<50 AND b%<50 THEN GOTO (jump)
COLOUR 1,r%,g%,b%
CIRCLE H,V,x%
(jump)
NEXT x%
ENDPROC
|
« Last Edit: Mar 17th, 2016, 03:07am by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
sveinioslo
Developer
member is offline


Posts: 64
|
 |
Re: Custom Donut Button BMP file maker
« Reply #1 on: Mar 15th, 2016, 11:50am » |
|
Nice ones, but you may need to adjust how you calculate the size of these images. The saved donuts do not look as good as the ones on the screen, they are cropped. I had the same problem with your 3D buttons.
Please don't remove the WAIT instruction when there is nothing to do or the program is just waiting:
(mou) GOTO (mou)
From another thread, some years ago: Quote:It's an 'infinite loop' so will inevitably use 100% CPU time (if it's registering only 25% that simply means that you have a CPU with four cores). Even worse, it risks overheating the chip - you will probably notice the cooling fan ramping up - and will rapidly run down the battery on a laptop. It's for all these reasons that you should never write a program that, whilst 'idling' (i.e. with nothing useful to do), actually races around a loop as fast as it can. The simplest way to solve the problem is to add a WAIT 0 statement in the loop. |
|
Many people use laptops these days, including myself. (at home, not at work)
Svein
|
|
Logged
|
|
|
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Re: Custom Donut Button BMP file maker
« Reply #2 on: Mar 15th, 2016, 12:12pm » |
|
Ok fixed the WAIT command issue and here is the DONUT BUTTONS IN ACTION LEFT CLICK ON EACH ONE I think I am done for the night (coding for 12 hours)
MAKE SURE YOU RUN THE PROGRAM AT THE START OF THIS POST BEFORE YOU RUN THIS ONE. (or it wont find the BMP images) UPDATED ON MARCH 16 2016 (BETTER BUTTON IMAGE RENDER) Code:
SWP_HIDEWINDOW = &80
SWP_NOMOVE = 2
SWP_NOSIZE = 1
SWP_NOZORDER = 4
SWP_SHOWWINDOW = 64
LR_LOADFROMFILE = 16
BM_SETIMAGE = 247
BS_BITMAP = &80
ON CLOSE : PROCclose : QUIT
INSTALL @lib$+"winlib5"
INSTALL @lib$+"timerlib"
REM SET MODE TO 8 USING VDU
VDU 22,8
REM SET LINE THICKNESS TO 3
VDU 23,23,3|
REM OFF
GCOL 1
REM create and save button images------------------------------------
file1$=@usr$+"donut1.bmp"
file2$=@usr$+"donut2.bmp"
file3$=@usr$+"donut3.bmp"
file1b$=@usr$+"donut4.bmp"
CLS
REM -----------------------------------------------------------------
REM create buttons --------------------------------------------------
butnu1=FN_button("",300,200,40,40,FN_setproc(PROCbutnu1),BS_BITMAP)
butnu2=FN_button("",340,200,40,40,FN_setproc(PROCbutnu2),BS_BITMAP)
butnu3=FN_button("",380,200,40,40,FN_setproc(PROCbutnu3),BS_BITMAP)
REM -----------------------------------------------------------------
REM assign images to buttons----------------------------------------
SYS "LoadImage", 0, file1$, 0, 40, 40, LR_LOADFROMFILE TO hbitmap1
SYS "SendMessage", butnu1, BM_SETIMAGE, 0, hbitmap1
SYS "LoadImage", 0, file2$, 0, 40, 40, LR_LOADFROMFILE TO hbitmap2
SYS "SendMessage", butnu2, BM_SETIMAGE, 0, hbitmap2
SYS "LoadImage", 0, file3$, 0, 40, 40, LR_LOADFROMFILE TO hbitmap3
SYS "SendMessage", butnu3, BM_SETIMAGE, 0, hbitmap3
SYS "LoadImage", 0, file1b$, 0, 40, 40, LR_LOADFROMFILE TO hbitmap1b
REM -----------------------------------------------------------------
REM MAIN --------------------------------
(mou)
WAIT 0 : REM just wait, nothing to do !
GOTO (mou)
END
REM -------------------------------------
REM clicking buttons will jump here automatically -------------------
DEF PROCbutnu1 : PRINTTAB(0,27);"Button 1" : PROCflash1
DEF PROCbutnu2 : PRINTTAB(0,27);"Button 2" : PROCflash2
DEF PROCbutnu3 : PRINTTAB(0,27);"Button 3" : PROCflash3
LOCAL X,Y,CC,I%
FOR I%=1 TO 20000
X=RND(100)
Y=RND(100)
CC=RND(200)
COLOUR 1,X+Y,CC,Y+X
LINE X,Y,X,Y
NEXT I%
ENDPROC
REM -----------------------------------------------------------------
DEF PROCflash1 : LOCAL A%
SYS "SendMessage", butnu1, BM_SETIMAGE, 0, hbitmap1b
A%=FN_ontimer(100,PROCflash1off,0)
ENDPROC
DEF PROCflash1off
SYS "SendMessage", butnu1, BM_SETIMAGE, 0, hbitmap1
ENDPROC
DEF PROCflash2 : LOCAL A%
SYS "SendMessage", butnu2, BM_SETIMAGE, 0, hbitmap1b
A%=FN_ontimer(100,PROCflash2off,0)
ENDPROC
DEF PROCflash2off
SYS "SendMessage", butnu2, BM_SETIMAGE, 0, hbitmap2
ENDPROC
DEF PROCflash3 : LOCAL A%
SYS "SendMessage", butnu3, BM_SETIMAGE, 0, hbitmap1b
A%=FN_ontimer(100,PROCflash3off,0)
ENDPROC
DEF PROCflash3off
SYS "SendMessage", butnu3, BM_SETIMAGE, 0, hbitmap3
ENDPROC
DEF PROC_button(H,V,BEGIN,SIZE,X,C,A,DI,butnu)
R=X
G=C
B=A
P=SIZE-BEGIN
P=P/2
P=BEGIN+P
FOR Y=P TO SIZE
COLOUR 1,X,C,A
LINE H-Y,V-Y,H+Y,V-Y
LINE H+Y,V-Y,H+Y,V+Y
LINE H+Y,V+Y,H-Y,V+Y
LINE H-Y,V+Y,H-Y,V-Y
X=X-DI
C=C-DI
A=A-DI
IF X<2 THEN X=2
IF C<2 THEN C=2
IF A<2 THEN A=2
NEXT Y
FOR Y=BEGIN TO P
COLOUR 1,X,C,A
LINE H-Y,V-Y,H+Y,V-Y
LINE H+Y,V-Y,H+Y,V+Y
LINE H+Y,V+Y,H-Y,V+Y
LINE H-Y,V+Y,H-Y,V-Y
X=X+DI
C=C+DI
A=A+DI
NEXT Y
COLOUR 1,R,G,B
FILL H,V
ENDPROC
REM delete the stuff we made
DEF PROCclose
SYS "DeleteObject", hbitmap1
SYS "DeleteObject", hbitmap2
SYS "DeleteObject", hbitmap3
SYS "DeleteObject", hbitmap1b
PROC_closewindow(butnu1)
PROC_closewindow(butnu2)
PROC_closewindow(butnu3)
ENDPROC
|
« Last Edit: Mar 17th, 2016, 03:21am by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
sveinioslo
Developer
member is offline


Posts: 64
|
 |
Re: Custom Donut Button BMP file maker
« Reply #3 on: Mar 15th, 2016, 11:22pm » |
|
Nice work !
|
|
Logged
|
|
|
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Re: Custom Donut Button BMP file maker
« Reply #4 on: Mar 16th, 2016, 12:00am » |
|
Thanks. I am still working on trying to BASICfy the method for doing this so its perhaps 3 simple commands for a complete button creation and I really mean, that's it..and perhaps I can do this with the entire windows interface. Perhaps a function? DEF PROC and PROC seem ok, but maybe there is a way to get the actions done in a more custom way.. I don't know how yet since I am thinking in many programming dialects.
|
|
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
|