(04-30-2022, 11:55 PM)bplus Wrote: Eye Candy #9B
I've been playing with this one. I added some code so that moving the mouse ends the program, so it can be used as a screensaver, and tried to make it fullscreen.
However there are a couple of things I haven't been able to figure out -
- When it ends, it doesn't close, but instead says "press any key to continue".
How do you make it just end?
- It isn't really fullscreen, the left and right edges of the screen are just black.
I tried playing with some settings and the bottom left and right corners were still black.
How do you make the image fill the whole screen for a 1080p display?
Code: (Select All)
' Eye Candy #9B by bplus, Mini-Mod
' 04-30-2022, 07:55 PM (This post was last modified: 04-30-2022, 08:19 PM by bplus.)
' https://qb64phoenix.com/forum/showthread.php?tid=219&pid=1291#pid1291
' INSTRUCTIONS:
' ENTER...............change function
' SPACE...............show/hide function name
' ESC OR MOVE MOUSE...quit
' (any other key).....change colors
' madscijr added Steve's mouse check,
' so when user touches the mouse it closes,
' to use as a screen saver,
' and also modified function Plasma~&
' to use not just SIN but also COS TAN _COT _CSC _SEC
' maybe later we'll experiment with other functions
' (they didn't work by just dropping them in, it will take some studying)
' and added hotkeys to cycle through functions, etc.
' TO DO / ISSUES:
' * Image doesn't fill the whole screen - the bottom
' left & right corners are black, how do we get the
' image to fill the whole screen?
' * When program ends, it says "press any key to continue"
' How do you make that go away so program just ends??
_Title " Eye Candy #9B Closer" ' b+ 2022-03-09
DefDbl A-Z
Const fps = 80
Const cSecondsPerFunction = 30 ' # seconds before next function cycles
Const cMouseDelaySeconds = 5 ' # of seconds before begin checking for mouse
Const cMinFn = 0 ' min value select case checks for in Function Plasma~&
Const cMaxFn = 5 ' max value select case checks for in Function Plasma~&
' KEY CODES FOR _BUTTON
Const KeyCode_Escape = 2
Const KeyCode_Spacebar = 58
Const KeyCode_Enter = 29
Const KeyCode_Up = 329
Const KeyCode_Down = 337
Const KeyCode_Left = 332
Const KeyCode_Right = 334
Dim Shared cN, pR, pG, pB
Dim Shared iFuncNum% ' index of current function select case checks for
Dim Shared FuncName$ ' name of current function
Dim Shared iFunc2%
Dim message$
ReDim colr(-100 To 1000) As _Unsigned Long
Dim iLoop%, iValue%
Dim iFrameCount% ' counts frames
Dim iFramesPerFunction% ' # frames before next function cycles
Dim iFramesBeforeEnableMouse% ' # frames before start checking for mouse
Dim MaxCols%, MaxRows% ' for printing text on screen
Dim OldMouseX, OldMouseY As Integer
Dim bFinished As Integer: bFinished = _FALSE
Dim bTrackMouse As Integer: bTrackMouse = _FALSE
Dim bShowFuncName%: bShowFuncName% = _FALSE
Dim iLastKeyCode%: iLastKeyCode% = 0
' INITIALIZE
iFramesPerFunction% = cSecondsPerFunction * fps
iFramesBeforeEnableMouse% = cMouseDelaySeconds * fps
xmax = _DesktopWidth - 1
ymax = _DesktopHeight - 1
'xmax = 800
'ymax = 600
'Print "xmax=" + _Trim$(Str$(xmax)) + ", ymax=" + _Trim$(Str$(ymax)) : End
Screen _NewImage(xmax, ymax, 32)
_FullScreen
'_ScreenMove 0, 0
' for printing text
MaxCols% = (_Width / _FontWidth) - 1
MaxRows% = (_Height / _FontHeight) - 1
' Center:
xc = xmax / 2
yc = ymax / 2
diag = Sqr(xc * xc + yc * yc)
ReDim colr(-100 To diag + 1000) As _Unsigned Long
p2 = _Pi * 2
iFuncNum% = cMinFn
iFrameCount% = 0
Randomize Timer
While _MouseInput: Wend: OldMouseX = _MouseX: OldMouseY = _MouseY ' initial mouse placement
While 1
resetPlasma
For iLoop% = -100 To diag + 1000
colr(iLoop%) = Plasma~&(iFuncNum%)
Next iLoop%
ro = 950
s = 0
While ro > -50
' PROCESS KEYBOARD INPUT
While _DeviceInput(1): Wend ' clear and update the keyboard buffer
If _Button(KeyCode_Escape) Then
' ESC = QUIT
iLastKeyCode% = KeyCode_Escape
bFinished = _TRUE: Exit While
ElseIf _Button(KeyCode_Enter) Then
' ENTER = CYCLE TO NEXT FUNCTION
If iLastKeyCode% <> KeyCode_Enter Then
iFuncNum% = iFuncNum% + 1: If iFuncNum% > cMaxFn Then iFuncNum% = cMinFn
resetPlasma
For iLoop% = -100 To diag + 1000
colr(iLoop%) = Plasma~&(iFuncNum%)
Next iLoop%
iLastKeyCode% = KeyCode_Enter
End If
ElseIf _Button(KeyCode_Spacebar) Then
' ENTER = SHOW/HIDE FUNCTION NAME
If iLastKeyCode% <> KeyCode_Spacebar Then
bShowFuncName% = Not (bShowFuncName%)
iLastKeyCode% = KeyCode_Spacebar
End If
Else
' ANY OTHER KEY = CHANGE COLORS
iLastKeyCode% = 0
k$ = InKey$: _KeyClear
If Len(k$) Then Exit While
End If
_KeyClear ' CLEAR KEYBOARD BUFFER
' Tie dye!
Cls
' SINGLE ! or none -2.802597E-45 +3.402823E+38 4
' DOUBLE # -4.490656458412465E-324 +1.797693134862310E+308 8
' _FLOAT ## -1.18E-4932 +1.18E+4932 32(10 used)
iTo# = p2 / 64
iStep# = p2 / (16 * 360)
'For a = 0 To p2 / 64 Step p2 / (16 * 360)
For a = 0 To iTo# Step iStep#
iValue% = 50 * Sin(s) ' 2 * s or just s
If _TRUE = _FALSE Then
iValue% = (s / 50) * 25
iValue% = (s / 500) * 25
iValue% = (s / 500) * p2 ^ .25
iValue% = (s / 500) * p2 ^ (a * .25)
iValue% = (s / 500) * p2 ^ a
iValue% = (a / 50000) * s ^ (p2 * .25)
' EXPERIMENT WITH DIFFERENT VALUES HERE:
iFunc2% = RandomNumber%(1, 5)
Select Case iFunc2%
Case 1:
iValue% = 50 * Sin(s) ' 2 * s or just s
Case 2:
iValue% = 50 * Cos(s * 1)
Case 3:
iValue% = 1 * Tan(s * 1)
Case 4:
iValue% = 1 * _Sec(s * 2)
Case 5:
iValue% = 1 * _Acos(s * 1)
Case Else
iValue% = 1 * _Acosh(s * 2)
End Select
' TRY SOME OF THESE...
iValue% = 50 * Sin(s) ' 2 * s or just s
iValue% = 50 * Sin(s * 2) ' 2 * s or just s
iValue% = 50 * Sin(s * 3)
iValue% = 50 * Sin(s * 4)
iValue% = 50 * Sin(s * 5)
iValue% = 50 * Cos(s * 1)
iValue% = 50 * Cos(s * 2)
iValue% = 50 * Cos(s * 3)
iValue% = 50 * Cos(s * 4)
iValue% = 25 * Cos(s * 5)
iValue% = 1 * Tan(s * 1)
iValue% = 1 * Tan(s * 2)
iValue% = 1 * _Sec(s * 2)
iValue% = 1 * _Acos(s * 1)
iValue% = 1 * _Acos(s * 2)
iValue% = 1 * _Acos(s * 3)
iValue% = 1 * _Acos(s * 4)
iValue% = 1 * _Acos(s * 5)
iValue% = 1 * _Acosh(s * 2)
iValue% = 1 * _Asin(s * 2)
iValue% = 1 * _Asinh(s * 2)
iValue% = 1 * Atn(s * 2)
iValue% = 1 * _Tanh(s * 2)
iValue% = 1 * _Atanh(s * 1)
iValue% = 1 * _Atanh(s * 4)
iValue% = 1 * _Arccot(s * 1)
' STARTED GOING BACKWARDS! BUT CRASHED!
'iValue% = 1 * _Coth(s * .009)
'iValue% = 1 * _Coth(s * .008)
'iValue% = 1 * _Coth(s * .007)
'iValue% = 1 * _Coth(s * .006)
'iValue% = 1 * _Coth(s * .005)
'iValue% = 1 * _Coth(s * .002)
iValue% = 1 * _Coth(s * .001)
iValue% = 1 * _Sech(s * .001)
iValue% = 1 * _Sech(s * .005)
iValue% = 1 * _Sech(s * .05)
iValue% = 1 * _Sech(s * .1)
End If
' JUST RESULTS IN WHITE ON WHITE OR BLACK ON BLACK:
' _ACOS (function) arccosine function returns the angle in radians based on an input COSine value range from -1 to 1.
' _COSH (function) Returns the hyperbolic cosine of x radians.
' _ACOSH (function) Returns the nonnegative arc hyperbolic cosine of x, expressed in radians.
' _ARCSEC (function) is the inverse function of the secant.
' _ARCCSC (function) is the inverse function of the cosecant.
' _SINH (function) Returns the hyperbolic sine of x radians.
' _ASIN (function) Returns the principal value of the arc sine of x, expressed in radians.
' _ASINH (function) Returns the arc hyperbolic sine of x, expressed in radians.
' ATN (function) or arctangent returns the angle in radians of a numerical tangent value.
' _TANH (function) Returns the hyperbolic tangent of x radians.
' _ATANH (function) Returns the arc hyperbolic tangent of x, expressed in radians.
' _ARCCOT (function) is the inverse function of the cotangent.
' CAUSE ERRORS:
' _COTH (function) Returns the hyperbolic cotangent.
' _CSCH (function) Returns the hyperbolic cosecant.
' _SECH (function) Returns the hyperbolic secant.
For r = 0 To diag
PSet (xc + r * Cos(a), yc + r * Sin(a)), colr(r + iValue% + ro)
Next r
s = s + p2 / 180
Next a
sx1 = xc
sy1 = yc
sx2 = xc + diag * Cos(.002)
sy2 = yc + diag * Sin(.002)
sx3 = xc + diag * Cos(p2 / 64 - .002)
sy3 = yc + diag * Sin(p2 / 64 - .002)
For a = p2 / 64 To p2 - p2 / 64 Step p2 / 64
dx1 = xc
dy1 = yc
dx2 = xc + diag * Cos(a)
dy2 = yc + diag * Sin(a)
dx3 = xc + diag * Cos(a + p2 / 64)
dy3 = yc + diag * Sin(a + p2 / 64)
_MapTriangle (sx1, sy1)-(sx2, sy2)-(sx3, sy3), source& To(dx1, dy1)-(dx2, dy2)-(dx3, dy3), 0
Next a
Line (0, 0)-(xc - 1.5 * yc, _Height), &HFF000000, BF
Line (xc + 1.5 * yc, 0)-(_Width, _Height), &HFF000000, BF
' SHOW THE CURRENT GEOMETRY FUNCTION BEING USED BY Plasma~&
If bShowFuncName% = _TRUE Then
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
Locate MaxRows% / 2, (MaxCols% / 2) - (Len(FuncName$) / 2)
Print FuncName$;
End If
'' SHOW SOME VALUES FOR DEBUGGING
'message$ = "iValue% = " + _Trim$(Str$(iValue%))
'Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
'Locate MaxRows% / 2, (MaxCols% / 2) - (Len(message$) / 2)
'Print message$;
' Count down to color change
toggle = 1 - toggle
If toggle Then _Display
ro = ro - 1
' Cycle through different geometry functions (SIN, COS, TAN, etc.)
' after iFramesPerFunction% repetitions (# cycles for the given # seconds)
iFrameCount% = iFrameCount% + 1
If iFrameCount% > iFramesPerFunction% Then
iFrameCount% = 0
iFuncNum% = iFuncNum% + 1: If iFuncNum% > cMaxFn Then iFuncNum% = cMinFn
resetPlasma
For iLoop% = -100 To diag + 1000
colr(iLoop%) = Plasma~&(iFuncNum%)
Next iLoop%
End If
' If user moves mouse, quit
' NOTE: for some reason we have to wait a couple seconds
' before checking for this, or the program just
' immediately quits?
If bTrackMouse = _TRUE Then
While _MouseInput: Wend
If OldMouseX <> _MouseX Or OldMouseY <> _MouseY Then
bFinished = _TRUE
Exit While ' if the mouse moved, quit
End If
Else
' We had to delay the mouse move test
' because it was always resulting in _TRUE
' no idea why?
If iFrameCount% > iFramesBeforeEnableMouse% Then
While _MouseInput: Wend: OldMouseX = _MouseX: OldMouseY = _MouseY ' initial mouse placement
bTrackMouse = _TRUE
End If
End If
_Limit fps
Wend
If bFinished = _TRUE Then Exit While
Wend
End
' /////////////////////////////////////////////////////////////////////////////
Function Plasma~& (fn%)
cN = cN + .2
Select Case fn%: '
Case 0:
FuncName$ = "SIN"
Plasma~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
Case 1:
FuncName$ = "COS"
Plasma~& = _RGB32(127 + 127 * Cos(pR * cN), 127 + 127 * Cos(pG * cN), 127 + 127 * Cos(pB * cN))
Case 2:
FuncName$ = "TAN"
Plasma~& = _RGB32(127 + 127 * Tan(pR * cN), 127 + 127 * Tan(pG * cN), 127 + 127 * Tan(pB * cN))
Case 3:
FuncName$ = "_COT"
Plasma~& = _RGB32(127 + 127 * _Cot(pR * cN), 127 + 127 * _Cot(pG * cN), 127 + 127 * _Cot(pB * cN))
Case 4:
FuncName$ = "_CSC"
Plasma~& = _RGB32(127 + 127 * _Csc(pR * cN), 127 + 127 * _Csc(pG * cN), 127 + 127 * _Csc(pB * cN))
Case 5:
FuncName$ = "_SEC"
Plasma~& = _RGB32(127 + 127 * _Sec(pR * cN), 127 + 127 * _Sec(pG * cN), 127 + 127 * _Sec(pB * cN))
Case Else:
Plasma~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
End Select
End Function ' Plasma~&
' /////////////////////////////////////////////////////////////////////////////
Sub resetPlasma ()
pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2
End Sub
' /////////////////////////////////////////////////////////////////////////////
Function RandomNumber% (Min%, Max%)
Dim NumSpread%
NumSpread% = (Max% - Min%) + 1
RandomNumber% = Int(Rnd * NumSpread%) + Min% ' GET RANDOM # BETWEEN Max% AND Min%
End Function ' RandomNumber%
' /////////////////////////////////////////////////////////////////////////////
' Geometry functions we tried with Plasma~&:
' PRODUCE COLORS:
' SIN (function) returns the sine of a radian angle.
' COS (function) returns the cosine of a radian angle value.
' TAN (function) returns the ratio of SINe to COSine or tangent value of an angle measured in radians.
' _COT (function) the mathematical function cotangent defined by 1/TAN.
' _CSC (function) the mathematical function cosecant defined by 1/SIN.
' _SEC (function) the mathematical function secant defined by 1/COS.
' JUST RESULTS IN WHITE ON WHITE OR BLACK ON BLACK:
' _ACOS (function) arccosine function returns the angle in radians based on an input COSine value range from -1 to 1.
' _COSH (function) Returns the hyperbolic cosine of x radians.
' _ACOSH (function) Returns the nonnegative arc hyperbolic cosine of x, expressed in radians.
' _ARCSEC (function) is the inverse function of the secant.
' _ARCCSC (function) is the inverse function of the cosecant.
' _SINH (function) Returns the hyperbolic sine of x radians.
' _ASIN (function) Returns the principal value of the arc sine of x, expressed in radians.
' _ASINH (function) Returns the arc hyperbolic sine of x, expressed in radians.
' ATN (function) or arctangent returns the angle in radians of a numerical tangent value.
' _TANH (function) Returns the hyperbolic tangent of x radians.
' _ATANH (function) Returns the arc hyperbolic tangent of x, expressed in radians.
' _ARCCOT (function) is the inverse function of the cotangent.
' CAUSE ERRORS:
' _COTH (function) Returns the hyperbolic cotangent.
' _CSCH (function) Returns the hyperbolic cosecant.
' _SECH (function) Returns the hyperbolic secant.
' OTHER GEOMETRY FUNCTIONS:
' _ATAN2 (function) Returns the principal value of the arc tangent of y/x, expressed in radians.
' _HYPOT (function) Returns the hypotenuse of a right-angled triangle whose legs are x and y.
' OTHER MATH FUNCTIONS:
' _D2R (function) converts degrees to radian angle values.
' _G2R (function) converts gradient to radian angle values.
' _R2D (function) converts radians to degree angle values.
' _R2G (function) converts radians to gradient angle values.
' _D2G (function) converts degrees to gradient angle values.
' _G2D (function) converts gradient to degree angle values.
' EXP (function) returns the value of e to the exponential power specified.
' LOG (function) returns the natural logarithm of a specified numerical value
' SGN (function) returns -1 for negative, 0 for zero, and 1 for positive numerical values.
' SQR (function) returns the square root of a non-negative number.The left and right edges of the screen are black, and when it ends it says "press any key to continue":
![[Image: screensaver-bplus-psych-fullscreen-v12b.png]](https://i.ibb.co/tw6pMwPS/screensaver-bplus-psych-fullscreen-v12b.png)
I got it to fill more of the screen but the bottom left/right corners were still black:

