Author |
Topic: RETROLIB 10 + REFERENCE MOD March 2018 (Read 2417 times) |
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Re: RETROLIB 6- here is your Christmas tree DEC 2
« Reply #30 on: Dec 26th, 2016, 8:42pm » |
|
NOTICE: This tool is FREE and OPEN SOURCE. Here is an information link:
https://en.wikipedia.org/wiki/Free_and_open-source_software
Zaphod, you may want to use my strategy.
The breakthough with buttonz was if you used a palette color to identify what was at a specific location, you could also eliminated a need for tracking something with variables.
Add to that, you could be very strategic with complicated creations with just one palette location within a image deciding its status.
Of course on a project I mentioned to Richard about using palettes as a means of storing data was related to this subject. And one day, while thinking of PEEK and POKE and memory and graphics plotting, that's when the idea came to me. You could hide your design on a graphics page.. And it would only need a tool to look at it.
The other thing about FNbuttonz is that it doesn't require *REFRESH, because it only changes what you see if the palette environment requires it.
So technically, if say, your graphics screen was 1000x1000 then your data area would be 500x500 x3 And if I am wrong about the vertical reads, it would be: 500x1000x3
Mainly because the palette takes up space ( its just what I noticed.. I am not sure if a perfect pixel can store a palette on its own... especially with what I have read about LCD technology.
This seems to lend a type of Object Orientated Programming to this library. (in my opinion)
Code: DEFFNbuttonz(X,Y,msg$)
LOCAL initialx%,fi%,reduction%,tx,ty,mx%,my%,mb%,ad%,ady%,c$
PRIVATE st$
IF msg$<> "clearitall" THEN
initialx%=LEN(msg$)
LET tx= X+initialx%+25
LET ty= Y:reduction%=0
reduction%=initialx%/2
reduction%=reduction%*6
IF initialx%<20 THEN reduction%=reduction%/2
initialx%=initialx%*22-reduction%
MOUSE mx%,my%,mb%
ad%=initialx%+8:ad%+=X:ady%=Y-28
IF mx% >X AND mx%<ad% AND my%<Y+8 AND my%>ady% THEN
c$="255,255,255"
IF mb%=4 THEN st$=msg$
ELSE c$="200,200,200"
ENDIF
IF FNrgb(X,Y)="000,000,000" THEN c$="200,200,200"
PROCcolor("f",c$)
IF FNrgb(X,Y)<>c$ THEN
FOR fi%=12 TO 48
LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
NEXT
PROCcolor("f","000,000,000")
MOVE tx,ty
PRINT msg$
ENDIF
ENDIF
IF msg$="clearitall" THEN st$=""
MOVE 0,0 REM hide that thing
=st$
|
| « Last Edit: Jan 23rd, 2017, 5:26pm by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
Zaphod
Guest
|
 |
Re: RETROLIB 6- here is your Christmas tree DEC 2
« Reply #31 on: Dec 27th, 2016, 01:24am » |
|
Quote:Zaphod, you may want to use my strategy. |
|
I thought I had but got tripped up by two things. First in changing to a rectangle draw I found I had to sense 2 pixels in to ensure I got the right colour picked up. Secondly my variation of PROCcolor did not recognize properly how it worked so the original has been reinstated, except I made the PRIVATE variable LOCAL. With that I believe that the redrawing occurs only when the button color changes, as it should.
I have updated the original post with these corrections and apologize for not realizing that it was not functioning correctly before. Thank you, Michael for pointing that out.
Z
|
|
Logged
|
|
|
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Re: RETROLIB 6- here is your Christmas tree DEC 2
« Reply #32 on: Dec 27th, 2016, 03:46am » |
|
Quote:| Secondly my variation of PROCcolor did not recognize properly how it worked so the original has been reinstated, except I made the PRIVATE variable LOCAL |
|
I looked carefully at your version of a buttonz like control.. It was interesting how you simplified it..
PROCcolor was a evolution of my color management right from the start.
It was a real show stopper, because it allowed certain control of colors for foreground and background color controls.
It, along with a few other tools I worked hard to refine.
I had to tediously check each palette RGB value and create them in the color interpreter to give the exact color for the original core colors.
The core colors would be EXACTLY the same palette, and I also discovered that the colors from 1- 15 were a special palette group. The color 0 was truly predictable when used to match the whole range of colors.
It was a journey of discovery. I had to research how palettes worked for RGB and it took a long time.
But now I can easily control colors and get the value from any point on the screen.
The area that PROCcolor fails is with POINT..
The TINT color setting is correct, but POINT wont see the redefined value of 0. But in this case you don't need POINT and I really prefer TINT, as I love working with palettes.
When all else fails, PROCcolor is dependable and I know it will provide the results for core colors or words or RGB values.
I also created resetrgb to keep the core colors uncontaminated after a procedure.
And PROCcrgb(r%,g%,b%) which is the foreground fast color tool for the fastest palette control.
Also, quite a while ago, when I was told I should, I did try to use the Hexadecimal tactics you were using for PROCcolor.. It didn't work the way I expected it should work.. So that's why it is the way it is.
Right now I am studying D3D and the theory behind 3D creation, as it seems to be the most logical step forward.
If possible, I will add the object creation and controls into another version of RETROLIB.. Although it will most likely be a much more elaborate version with only the most powerful parts of the existing library.
Ric, you out there?
|
| « Last Edit: Dec 27th, 2016, 04:51am by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
Zaphod
Guest
|
 |
Re: RETROLIB 6- DEMOS DEC 27 -set
« Reply #33 on: Dec 27th, 2016, 5:03pm » |
|
Quote:| The area that PROCcolor fails is with POINT.. |
|
Yes, there are warnings in the manual about that if you start adjusting the palette. POINT works on the logical colors not the physical ones. However code of the FNbuttonz type can work well with POINT if you don't mess with the palette. I know you like changing the palette so this is probably not for you , Michael. Code: REM Demo of buttons
REM Based on ideas by "Michael", recoded and revised by Zaphod. Dec 2016
REM REV 2 minimalist version. Uses existing color pallette
ON ERROR SYS "MessageBox",@hwnd%, REPORT$,0,48
MODE 22
OFF: VDU 5
REPEAT
REM Note that wait to avoid repeats is AFTER the action.
IF FNbuttonpressed(100,1100,"Rectangles") THEN GCOL RND(15)-1: RECTANGLE FILL RND(800)+200,RND(600)+100,RND(800),RND(600):WAIT 20
IF FNbuttonpressed(100,1000," Circles ") THEN GCOL RND(15)-1: CIRCLE FILL RND(800)+200, RND(600)+100, RND(200):WAIT 20
WAIT 0
UNTIL FNbuttonpressed(100,900,"Exit")
REM Clean up.
CLG
VDU 4
COLOUR 15
PRINT "That's all folks"
END
DEF FNbuttonpressed(x%,y%,text$) :REM by Zaphod
REM Returns TRUE while mouse held down over button.
REM Button is 1.5 times text height and 1.5 thime text length.
REM It is auto sizing so same text length gives same button size if required.
LOCAL mx%,my%,mb%,dx%,dy%,c%
dx%=LEN(text$)*3*@vdu%!216
dy%=@vdu%!220*3
MOUSE mx%,my%,mb%
IF mx% >x% AND mx%<(x%+dx%) AND my%<(y%+dy%) AND my%>y% THEN
c%=14 :REM Highlight color
IF mb%=4 THEN :=TRUE
ELSE
c%=6 :REM Base button color
ENDIF
IF POINT(x%+2,y%+2)<>c% THEN
REM only repaint if the color needs to change.
GCOL c%
RECTANGLE FILL x%, y%, dx%, dy%
GCOL 15 :REM Text color
MOVE x%+dx%/6, y%+dy%*5/6 :REM Center text.
PRINT text$
ENDIF
=FALSE
As you can see this is minimalist BB4W code rather than Retrolib. In cases like this it is probably easier just to use straight BBC BASIC.
The issue with the color returned from TINT or rgb as hex is easy to understand once you realize that computers store their data differently from humans and have the least significant byte first. The colors are thus Hex BBGGRR Each hex digit is 4 bits so if we do a right shift of 8 bits BBGGRR >> 8 we get BBGG with the red now discarded. Similarly if we shift 16 bits we get the blue only. If we take these results and put them into byte variables or AND with &FF and put them in to integer variables we have the three components separated.
Well thanks for keeping me entertained over the Christmas period.
Z
|
|
Logged
|
|
|
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Re: RETROLIB 6- DEMOS DEC 27 -set
« Reply #34 on: Dec 27th, 2016, 5:54pm » |
|
Quote: I know you like changing the palette so this is probably not for you , Michael. |
|
Ahhh.. but it can still be done.. That's why I made PROCresetrgb
I could make a command that always gives a true core color Perhaps PROCcorec("f or b","number or word of color") f or b would be the foreground and background controls and numbers 0-15 or words like blue or light blue"
OR I could just modify PROCcolor so that it actually serves you a core color for 0- 15 and for colors black - white
MEANWHILE still allowing RGB palette controls
After some insight on things, my position on programming would be:
It is not what I can or can't do, it is the limits that I place on myself. Its about telling myself what level my standards are at.
Code: REM Demo of buttons
REM Based on ideas by "Michael", recoded and revised by Zaphod. Dec 2016
REM REV 2 minimalist version. Uses existing color pallette
ON ERROR SYS "MessageBox",@hwnd%, REPORT$,0,48
MODE 22
OFF: VDU 5
REM lets ensure the palettes are correct
PROCresetrgb
REPEAT
REM Note that wait to avoid repeats is AFTER the action.
IF FNbuttonpressed(100,1100,"Rectangles") THEN GCOL RND(15)-1: RECTANGLE FILL RND(800)+200,RND(600)+100,RND(800),RND(600):WAIT 20
IF FNbuttonpressed(100,1000," Circles ") THEN GCOL RND(15)-1: CIRCLE FILL RND(800)+200, RND(600)+100, RND(200):WAIT 20
WAIT 0
UNTIL FNbuttonpressed(100,900,"Exit")
REM Clean up.
CLG
VDU 4
COLOUR 15
PRINT "That's all folks"
END
DEF FNbuttonpressed(x%,y%,text$) :REM by Zaphod
REM Returns TRUE while mouse held down over button.
REM Button is 1.5 times text height and 1.5 thime text length.
REM It is auto sizing so same text length gives same button size if required.
LOCAL mx%,my%,mb%,dx%,dy%,c%
dx%=LEN(text$)*3*@vdu%!216
dy%=@vdu%!220*3
MOUSE mx%,my%,mb%
IF mx% >x% AND mx%<(x%+dx%) AND my%<(y%+dy%) AND my%>y% THEN
c%=14 :REM Highlight color
IF mb%=4 THEN :=TRUE
ELSE
c%=6 :REM Base button color
ENDIF
IF POINT(x%+2,y%+2)<>c% THEN
REM only repaint if the color needs to change.
GCOL c%
RECTANGLE FILL x%, y%, dx%, dy%
GCOL 15 :REM Text color
MOVE x%+dx%/6, y%+dy%*5/6 :REM Center text.
PRINT text$
ENDIF
=FALSE
REM restore default color palettes
DEFPROCresetrgb
COLOUR 0,0,0,0 :COLOUR 1,200,0,0 :COLOUR 2,000,200,000
COLOUR 3,200,200,000:COLOUR 4,000,000,200:COLOUR 5,200,000,200
COLOUR 6,000,200,200:COLOUR 7,200,200,200:COLOUR 8,056,056,056
COLOUR 9,248,056,056:COLOUR 10,056,248,056:COLOUR 11,248,248,056
COLOUR 12,056,056,248:COLOUR 13,248,056,248:COLOUR 14,056,248,248
COLOUR 15,248,248,248
ENDPROC
|
| « Last Edit: Dec 27th, 2016, 11:26pm by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
Zaphod
Guest
|
 |
Re: RETROLIB 10 REFERENCE +FNgkey tool
« Reply #35 on: Jan 22nd, 2017, 10:02pm » |
|
Not sure if these are of any use, but here they are anyway!
[Updated Jan 24th to include a torus and ellipse, also made colors fade proportionally so only brightness changes not the color.]
These are developments from Michael's 'tools' ideas but are independent procedures that don't rely on lots of 'helper' procs, and don't leave the system in strange graphics configurations. That is to say none of Retrolib is used. They also give shapes that are the size you think they should be and in the place you might expect them to be. Rectangular items have the origin at the bottom left and circular items at the center. I also changed the color gradient so that 100% merges to black so 10% to 70% gives quite a useful range of shading gradients. They are small and thus could be put in a library. Code:
MODE 8
PROCrectblockZ(100,600,500,300,200,100,200,80)
PROCsphereZ(1000,300,100,200,26,200,70)
PROCrectborderZ(800,500,320,200,21,200,100,170,60)
PROCgradcylZ(100,100,100,400,200,100,100,100)
PROCgradcylZ(300,100,400,100,250,50,50,90)
PROCellipseZ(400,400,100,150,150,50,200,100)
PROCtorroidZ(900, 900, 120, 100, 50, 40, 140, 240, 50)
REM RECTANGLE 900,200,200,200
REM RECTANGLE 300,250,200,300
REM REM RECTANGLE 800,800,200,200
ELLIPSE 400,400,100,150
END
DEF PROCellipseZ(x%,y%,dx%,dy%,r,g,b,d%):LOCAL type%, pen%: type%=1 :pen%=@vdu%!248: VDU 23,23,3|
DEF PROCrectblockZ(x%,y%,dx%,dy%,r,g,b,d%):LOCAL type%, pen%: type%=0
REM x,y are at bottom left.
REM dx% is width, d% is % progression to black.
LOCAL I%, d, k%, f, l, m, n, oldgcol&
oldgcol&=@vdu.g.b&
IF type% =0 x%+=dx%/2: y%+=dy%/2 :REM Find center. We work outwards.
IF dx%<dy% k%=dy%:f=dx%/dy% ELSE k%=dx% :f=dy%/dx% :REM adjust for aspect ratio.
d=d%/100/k%*4 :REM Get color proportion change per scan.
l=r*d : m=g*d : n=b*d
FOR I%=1 TO k%/2 STEP 2
COLOUR 0,r,g,b :GCOL 0
CASE type% OF
WHEN 0: IF dx%<dy% RECTANGLE x%-I%*f, y%-I%, 2*I%*f, 2*I% ELSE RECTANGLE x%-I%,y%-I%*f, 2*I%, 2*I%*f
WHEN 1: IF dx%<dy% ELLIPSE x%, y%, 2*I%*f, 2*I% ELSE ELLIPSE x%, y%, 2*I%, 2*I%*f
ENDCASE
r-=l:g-=m:b-=n :REM Adjust colors
NEXT
COLOUR 0,0,0,0 :GCOL oldgcol& :REM reset color 0 and plot mode.
IF pen% VDU 23,23,pen%|
ENDPROC
DEF PROCgradcylZ(x%,y%,dx%,dy%,r,g,b,d%)
REM x,y are at bottom left.
REM dx% is width, d% is % progression to black.
LOCAL I%, d, k%, f, oldgcol&, l, m, n
oldgcol&=@vdu.g.b&
x%+=dx%/2: y%+=dy%/2 :REM Find center. We work outwards.
IF dx%<dy% k%=dy%:f=dx%/dy% ELSE k%=dx% :f=dy%/dx% :REM adjust for aspect ratio.
d=d%/100/k%*2 :REM Get color proportion change per scan.
l=r*d : m=g*d : n=b*d
FOR I%=0 TO k%/2
COLOUR 0,r,g,b :GCOL 0
IF dx%<dy% RECTANGLE x%-I%*f, y%-k%/2, 2*I%*f, dy% ELSE RECTANGLE x%-k%/2,y%-I%*f, dx%, 2*I%*f
r-=l:g-=m:b-=n :REM Adjust colors
NEXT
COLOUR 0,0,0,0 :GCOL oldgcol& :REM reset color 0
ENDPROC
DEFPROCsphereZ(x%,y%,zrad%,r,g,b,d%) :REM Redundant: use ellipse.
PROCellipseZ(x%,y%,zrad%,zrad%,r,g,b,d%)
ENDPROC
DEF PROCtorroidZ(x%, y%, dx%, dy%, bwidth%, r, g, b, d%):LOCAL type%, pen%: type%=1 :pen%=@vdu%!248: VDU 23,23,2|
DEF PROCrectborderZ(x%, y%, dx%, dy%, bwidth%, r, g, b, d%) :LOCAL type%, pen%: type%=0 :REM d%=gradient per cent.
LOCAL I%, d, oldgcol&, l, m, n
oldgcol&=@vdu.g.b&
bwidth% AND= -2 :REM Make border width an even number.
d=d%/100/bwidth%*2 :REM Get color proportion change per scan.
l=r*d : m=g*d : n=b*d
FOR I% =1 TO bwidth%/2
COLOUR 0,r,g,b :GCOL 0
CASE type% OF
WHEN 0:
RECTANGLE x%+bwidth%/2-I%,y%+bwidth%/2-I%, dx%+2*I%-bwidth%, dy%+2*I%-bwidth%
RECTANGLE x%+bwidth%/2+I%,y%+bwidth%/2+I%, dx%-2*I%-bwidth%, dy%-2*I%-bwidth%
WHEN 1:
ELLIPSE x%, y%, dx%-bwidth%/2-I%, dy%-bwidth%/2-I%
ELLIPSE x%, y%, dx%-bwidth%/2+I%, dy%-bwidth%/2+I%
ENDCASE
r-=l:g-=m:b-=n :REM Adjust colors
NEXT
COLOUR 0,0,0,0 :GCOL oldgcol&
IF pen% VDU 23,23,pen%|
ENDPROC
With PROCgradcylZ the gradient is across the smaller axis. If you want it across the other axis you will have to adapt the code, which is pretty easy.
|
| « Last Edit: Jan 24th, 2017, 5:31pm by Zaphod » |
Logged
|
|
|
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Re: RETROLIB 10 REFERENCE +FNgkey tool
« Reply #36 on: Jan 23rd, 2017, 12:00am » |
|
Nice work. Have you worked out light perspective on a sphere yet?
Say I wanted to have different light angles for a rolling ball?
Perhaps pool ball animations?
( I have created such a tool but its not on a presentation..)
|
| « Last Edit: Jan 23rd, 2017, 12:03am by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Re: RETROLIB 10 REFERENCE +FNgkey tool
« Reply #37 on: Jan 23rd, 2017, 1:42pm » |
|
On a side note. If we reflect on what has been achieved, we are creating a new foundation for controls. Non windows based. It has been a pet project for me for a very long time. I really think we could create a tool box for creating objects for D3D. Premade resizable objects.
We could make a program generator that automatically creates the code for additional constructs as they are done.
Ric you out there?
|
|
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
|