Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 326
» Latest member: hafsahomar
» Forum threads: 1,759
» Forum posts: 17,939

Full Statistics

Latest Threads
As technology rapidly evo...
Forum: Utilities
Last Post: Frankvab
Today, 06:09 AM
» Replies: 14
» Views: 29
Everybody's heard about t...
Forum: Utilities
Last Post: Frankvab
Today, 06:07 AM
» Replies: 22
» Views: 1,294
MBA Assignment Help in Du...
Forum: General Discussion
Last Post: hafsahomar
06-11-2025, 07:05 AM
» Replies: 0
» Views: 13
лучшие песни медляки слуш...
Forum: Petr
Last Post: WillieTop
06-08-2025, 02:21 AM
» Replies: 0
» Views: 29
пинк слушать онлайн беспл...
Forum: SMcNeill
Last Post: WillieTop
06-08-2025, 02:20 AM
» Replies: 0
» Views: 24
скачать музыку российскую...
Forum: madscijr
Last Post: WillieTop
06-08-2025, 02:18 AM
» Replies: 0
» Views: 23
нежная музыка mp3 скачать
Forum: Keybone
Last Post: WillieTop
06-08-2025, 02:17 AM
» Replies: 0
» Views: 24
лучшая песня слушать онла...
Forum: bplus
Last Post: WillieTop
06-08-2025, 02:16 AM
» Replies: 0
» Views: 27
пикник слушать онлайн луч...
Forum: Spriggsy
Last Post: WillieTop
06-08-2025, 02:15 AM
» Replies: 0
» Views: 23
какая сейчас популярная м...
Forum: RhoSigma
Last Post: WillieTop
06-08-2025, 02:14 AM
» Replies: 0
» Views: 19

 
  Image size, shape on Forum
Posted by: dcromley - 05-04-2022, 03:30 PM - Forum: Help Me! - Replies (7)

When I add an image, it gets truncated to be square.
The thread https://staging.qb64phoenix.com/showthre...ght=plasma has large and non-square images.
What am I missing?

Print this item

  TankDrum - Virtual tankdrum instrument to play record songs
Posted by: Dav - 05-04-2022, 03:10 PM - Forum: Dav - Replies (12)

TANKDRUM is a virtual instrument you can play and play & record little tunes with using the sound of a real Tankdrum.   It's easy to use - just click on the drum notes to play them.  Hit R to record your playing in real-time.  You can record over your song several times to add more notes and make more complex patterns (called overdubbing).  Hit P to play back your song.  Hit C to clear it and start over.   Your song can be saved to file and loaded again later.  Hit M to popup a MENU for a complete list of commands.

This is an updated & improved version of TankDrum.  Sounding notes are now highlighted for visual effect.  File saving/Loading is now included.  A few sample songs are now included.   Enjoy.

- Dav


.zip   TankDrum-v1d.zip (Size: 809.45 KB / Downloads: 97)

   

Print this item

  Huge Matrices Library [Updated]
Posted by: TarotRedhand - 05-04-2022, 07:57 AM - Forum: One Hit Wonders - Replies (8)

I initially created this library in the late 1990s. Having found QB64, I have now updated and expanded this library to work with it. At 2622 lines (including comments) it is obviously too large to post in a single code box. So the actual code is split into the six posts after this one. Also the sheer size and number of edits I made means that you should really treat this being a beta/release candidate version.

This library is all to do with matrices. There are six sections to it. Each section deals with matrix operations for arrays that contain a particular TYPE of data - Integer, Long Integer, _INTEGER64, Single precision floating point, Double precision floating point and _FLOAT. Overall this gives us 1 private routine and 114 public routines.

Having split it into 6 parts, I have made it so that each part should be able to be used independently of any other. The consequence of this is that if you want to use two (or more) parts you may well need to do minor editing on one (or more) parts.

Bug reports - either in here or pm me.

[Edit]

Now with a ridiculously small BI file that works all varieties of the library. '$INCLUDE: 'MATRIX.BI' at the top of the program that uses any of the library parts.

MATRIX.BI

Code: (Select All)
'$DYNAMIC

Option Base 1

Note all parts of this library have been updated to reflect this.

Next post Integer Matrices -

TR

Print this item

Photo Possible bug: Word-wrap oddity
Posted by: hanness - 05-04-2022, 06:41 AM - Forum: General Discussion - Replies (11)

I'm in the very early stages of writing a program that emulates one of my favorite screensavers of all time. The program simply displays a series of words on the screen, highlighting the appropriate words to spell out the time.

Below is a screenshot showing some sample output. Note that in every case, where a word would be cut off if printed on the current line, QB64 instead drops the word onto the next line. This is perfect and is exactly the behavior that I want, to avoid words being split across two lines. However, notice the second to last line of text in the screenshot below. For some reason, on only this one line, the word "fifty-six" is split across two lines.

Am I encountering some sort of bug here? Maybe something like the letter "x" at the end of the word is falling precisely on the 800 pixel width boundry and it's not being calculated precisely correctly?

Following the screenshot is the entire code, just in case this helps at all.

NOTE: I've done some testing and if I shift words around a bit I can get the error on other lines as well, where I have words that are not hyphenated. In other words, the hyphen in the word "fifty-six" has nothing to do with the problem.


It may also be worth noting that if I change the screen width from 800 to 799 the problem goes away.

[Image: Image1.jpg]

Code: (Select All)
Option _Explicit
Option Base 1

Dim AM_PM As String ' This flag will be set to either "AM" or "PM"
Dim CurrentDate As String ' Hold the entire date (Month / Day / Year) as a string
Dim CurrentTime As String ' Hold the entire time (Hours / Minutes / Seconds) as a string
Dim Day As Integer ' Day of the month (1-31) as a number
Dim DayOfWeek As Integer ' Day of the week (1-7) as a number
Dim DayOfWeekString(7) As String ' An array holding each day of the week as an English word
Dim DayString(31) As String ' An array holding each day of the month (1-31) as a string
Dim Decade As Integer ' The numerical value of the last 2 digits of the year
Dim font As Long
Dim fontpath As String
Dim handle As Long
Dim Hour As Integer ' Numerical value holding the current hour (0-23)
Dim HourString(12) As String ' The current hour as an English word. Since we use AM / PM this holds only one through twelve.
Dim LeapYear As Integer ' To to indicate if current year is a leap year. 1 = Leap Year, 0 = No Leap Year
Dim Minute As Integer ' The current minute as a numeral from 0 to 59
Dim MinuteString(59) As String ' An array hold minutes as English words from one to fifty-nine
Dim Month As Integer ' The current month as a number from 1 to 12
Dim MonthString(12) As String ' The current month as an English word (January, February, ... , November, December).
Dim MonthTable(12) As Integer ' A table with an offset for each month used to calculate what day of the week it is (Monday, Tuesday, etc).
Dim OldSecond As Integer ' A variable that is used to determine if the seconds have changed from the last time we checked
Dim Result1 As Integer ' A temporary variable
Dim Result2 As Integer ' A temporary variable
Dim Result3 As Integer ' A temporary variable
Dim Second As Integer ' The current seconds as a number (0-59)
Dim SecondString(59) As String ' The current seconds as an English word from one through fifty-nine
Dim Temp As Integer ' A temporary variable
Dim Temp2 As Integer ' A temporary variable

Dim x As Integer
Dim Year As Integer

handle& = _NewImage(800, 600, 256)
Screen handle&

'handle& = _NewImage(_DesktopWidth, _DesktopHeight, 256)
'Screen handle&
'_FullScreen




fontpath$ = Environ$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
font& = _LoadFont(fontpath$, 16)
_Font font&

' Read the spelled out version of various elements into arrays. This will save time later so that we don't have to constantly
' parse this over and over in out main program loop.

Restore DayOfWeek
For x = 1 To 7
    Read DayOfWeekString$(x)
Next x

Restore Day
For x = 1 To 31
    Read DayString$(x)
Next x

Restore Month
For x = 1 To 12
    Read MonthString$(x)
Next x

Restore Hour
For x = 1 To 12
    Read HourString$(x)
Next x

Restore Minute
For x = 1 To 59
    Read MinuteString$(x)
Next x

Restore Second
For x = 1 To 59
    Read SecondString$(x)
Next x

Restore MonthTable
For x = 1 To 12
    Read MonthTable(x)
Next x

Cls

' This is the main loop that retries the date and time, breaks it down into individual components, and then
' displays the time and date in words.

Do
    _Limit 60 ' Limit the number of times that we perform this loop to a maximum of 60 iterations per second

    CurrentDate$ = Date$
    CurrentTime$ = Time$
    Month = Val(Left$(CurrentDate$, 2))
    Day = Val(Mid$(CurrentDate$, 4, 3))
    Year = Val(Right$(CurrentDate$, 4))
    Decade = Val(Right$(CurrentDate$, 2))
    Hour = Val(Left$(CurrentTime$, 2))
    Minute = Val(Mid$(CurrentTime$, 4, 2))
    Second = Val(Right$(CurrentTime$, 2))

    ' At the end of the loop that displays the time on the screen, we set OldSecond to the current seconds. When we reach
    ' this point again, if the current seconds are still the same, we skip the display process since there are no changes.
    ' If the seconds have changed, then proceed with updating the display.

    If (OldSecond = Second) Then GoTo DisplayFinished

    ' Calculate the day of the week
    ' IMPORTANT: The calculations below are valid through 2099.

    ' Step 1: Add the day of the month and the number from the month table. We will read the values from the month table.

    Temp = Day + MonthTable(Month)

    ' Step 2: If the number calculated above is greater than 6, then subtract the highest multiple of 7 from this number.

    If Temp > 6 Then
        Temp2 = Int(Temp / 7)
        Temp = Temp - (Temp2 * 7)
    End If

    Result1 = Temp

    ' Step 3: From the last two digits of the year, subtract the year that has the highest multiple of 28.

    Temp = Decade

    If Decade > 27 Then
        Temp2 = Int(Temp / 28)
        Temp = Decade - (Temp2 * 28)
    End If

    Result2 = Temp

    ' Step 4: Take the last 2 digits of the year, divide by 4, and drop anything after the decimal point. Add that value to Result2.

    Temp = 0

    If Decade > 3 Then
        Temp = Int(Decade / 4)
    End If

    Result3 = Result2 + Temp

    ' Step 5: If the month is Jan or Feb AND the year is a leap year, subtract 1 from Result3.

    If Month < 3 Then

        If (Year / 4) = (Int(Year / 4)) Then
            LeapYear = 1
        Else
            LeapYear = 0
        End If

        Result3 = Result3 - LeapYear

    End If

    ' Step 6: Add Result1 and Result3. Subtract the highest multiple of 7. The result will be 0-6 with 0 being Sat, and 6 being Fri.

    Result3 = Result3 + Result1

    If Result3 > 6 Then
        Temp = Int(Result3 / 7)
        Result3 = Result3 - (Temp * 7)
    End If

    ' To make handling easier, we will add 1 to result so that the day of the week will now be a number from 1 to 7. The
    ' end result is that Sat = 1, Fri = 7.

    DayOfWeek = Result3 + 1

    ' End calculation of the day of the week.

    ' Set the default color of items printed to the screen to grey on black. Current values will be highlighted.
    ' Currently, this means white text on a red background, but we intend to allow customization later.

    Locate 1, 1
    Color 8, 0

    ' Print all days of the week

    For x = 1 To 7

        If x = DayOfWeek Then
            Color 15, 4: Print DayOfWeekString$(x);: Color 8, 0: Print " ";
        Else
            Print DayOfWeekString$(x); " ";
        End If

    Next x

    ' Always print the word "the" in the highlight color

    Color 15, 4: Print "the";: Color 8, 0: Print " ";

    ' Print the day of the month

    For x = 1 To 31

        If x = Day Then
            Color 15, 4: Print DayString$(x);: Color 8, 0: Print " ";
        Else
            Print DayString$(x); " ";
        End If

    Next x

    ' Always print the word "of" in the highlight color

    Color 15, 4: Print "of";: Color 8, 0: Print " ";

    ' Print the month

    For x = 1 To 12

        If x = Month Then
            Color 15, 4: Print MonthString$(x);: Color 8, 0: Print " ";
        Else
            Print MonthString$(x); " ";
        End If

    Next x

    ' Always print a comma (,) in the highlight color

    Color 15, 4: Print ",";: Color 8, 0: Print " ";

    ' Print the hour. Hours are numbered from 0 to 23. Since we are using AM and PM we need to manipulate the hours a little bit
    ' and set an AM / PM flag.

    ' Set an AM / PM Flag. AM_PM$ will be set to either "AM" or "PM".

    Select Case Hour
        Case 0 TO 11
            AM_PM$ = "AM"
        Case Else
            AM_PM$ = "PM"
    End Select

    ' Convert 24 hour time to AM / PM (12 hour) format

    Select Case Hour
        Case 0
            Hour = Hour + 12
            Exit Select
        Case 13 TO 23
            Hour = Hour - 12
            Exit Select
    End Select

    For x = 1 To 12

        If x = Hour Then
            Color 15, 4: Print HourString$(x);: Color 8, 0: Print " ";
        Else
            Print HourString$(x); " ";
        End If

    Next x

    ' If minutes are equal to zero, highlight the word "o'clock".

    If (Minute = 0) Then
        Color 15, 4: Print "o'clock";: Color 8, 0: Print " ";
    Else
        Print "o'clock ";
    End If

    ' Print the minute. Minutes are numbered from 0 to 59. If seconds are 0, then we highlight the word "precisely",
    ' otherwise we highlight the word "and" and the appropriate second following the minutes.

    For x = 1 To 59

        If x = Minute Then
            Color 15, 4: Print MinuteString$(x);: Color 8, 0: Print " ";
        Else
            Print MinuteString$(x); " ";
        End If

    Next x

    ' Print the AM and PM indicators.

    Select Case AM_PM$
        Case "AM"
            Color 15, 4: Print "AM";: Color 8, 0: Print " "; "PM"; " ";
        Case "PM"
            Print "AM";: Print " ";: Color 15, 4: Print "PM";: Color 8, 0: Print " ";
    End Select

    ' If seconds are 0, then highlight the word "precisely", otherwise, highlight the word "and".

    Select Case Second
        Case 0
            Print "and ";
            Color 15, 4: Print "precisely";: Color 8, 0: Print " ";
        Case Else
            Color 15, 4: Print "and";: Color 8, 0: Print " ";
            Print "precisely ";
    End Select

    ' Print the second. Seconds are numbered from 0 to 59.

    For x = 1 To 59

        Select Case x
            Case 1

                If Second = 1 Then
                    Color 15, 4: Print SecondString$(x);: Color 8, 0: Print " ";: Color 15, 4: Print "second";: Color 8, 0: Print " ";
                Else
                    Print SecondString$(x);: Print " ";: Print "second"; " ";
                End If

            Case Else

                If Second = x Then
                    Color 15, 4: Print SecondString$(x);: Color 8, 0: Print " ";
                Else
                    Print SecondString$(x); " ";
                End If

        End Select

    Next x

    ' Highlight the word "seconds" if Second > 1.

    Select Case Second
        Case 0, 1
            Print "seconds ";
        Case Else
            Color 15, 4: Print "seconds";: Color 8, 0: Print " ";
    End Select

    OldSecond = Second

    DisplayFinished:

Loop

End



DayOfWeek:
Data "Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"

Day:
Data "first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelfth","thirteenth"
Data "fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth","twentieth","twenty-first","twenty-second"
Data "twenty-third","twenty-fourth","twenty-fifth","twenty-sixth","twenty-seventh","twenty-eighth","twenty-ninth","thirtieth","thirty-first"

Month:
Data "January","February","March","April","May","June","July","August","September","October","November","December"

Hour:
Data "one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"

Minute:
Data "oh-one","oh-two","oh-three","oh-four","oh-five","oh-six","oh-seven","oh-eight","oh-nine","ten","eleven","twelve","thirteen"
Data "fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","twenty-one","twenty-two","twenty-three","twenty-four"
Data "twenty-five","twenty-six","twenty-seven","twenty-eight","twenty-nine","thirty","thirty-one","thirty-two","thirty-three"
Data "thirty-four","thirty-five","thirty-six","thirty-seven","thirty-eight","thirty-nine","forty","forty-one","forty-two","forty-three"
Data "forty-four","forty-five","forty-six","forty-seven","forty-eight","forty-nine","fifty","fifty-one","fifty-two","fifty-three"
Data "fifty-four","fifty-five","fifty-six","fifty-seven","fifty-eight","fifty-nine"

Second:
Data "one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen"
Data "fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","twenty-one","twenty-two","twenty-three","twenty-four"
Data "twenty-five","twenty-six","twenty-seven","twenty-eight","twenty-nine","thirty","thirty-one","thirty-two","thirty-three"
Data "thirty-four","thirty-five","thirty-six","thirty-seven","thirty-eight","thirty-nine","forty","forty-one","forty-two","forty-three"
Data "forty-four","forty-five","forty-six","forty-seven","forty-eight","forty-nine","fifty","fifty-one","fifty-two","fifty-three"
Data "fifty-four","fifty-five","fifty-six","fifty-seven","fifty-eight","fifty-nine"

MonthTable:
Data 0,3,3,6,1,4,6,2,5,0,3,5

Print this item

  The good news is we had a Google bot here most of the day.
Posted by: Pete - 05-04-2022, 03:50 AM - Forum: General Discussion - Replies (2)

The bad news is we rank #1 for "Farm Puns."

Kidding aside, nice to see more indexing is happening!

Pete


Keep ah postin', v
armints!

Print this item

  Creating a screen without a title bar and positioning it on monitor
Posted by: hanness - 05-04-2022, 02:21 AM - Forum: General Discussion - Replies (5)

I hope you will excuse me, I'm trying to figure out as much of this on my own as I can, but I'll likely still have several questions on this topic.

Let's say that I have a screen with a resolution of 2560 x 1440.
I want to create a screen that occupies the entire screen, preferably without a title bar.

I know that I could these commands:

handle& = _NewImage(2560, 1440, 256)
Screen handle&

This will create a 2560 x 1440 screen, but is it possible to somehow remove the title bar and to force this screen to be opened with the upper left corner located at the upper left of the actual screen?

Print this item

  Samples and Resources
Posted by: SMcNeill - 05-04-2022, 01:36 AM - Forum: Learning Resources and Archives - Replies (2)

A collection of various samples and resources which folks can download and link to, to use with examples and wiki code.

We'll build upon this topic as we gather and decide exactly what all resources need to be available here.  What we'd like to collect is a nice bunch of basic sound, image, font, and header files, and such, and then users can just point people to this post and say, "Go grab the proper resource from there to run this demo", rather than having 80 direntry.h files on the server and 412 different images around just to illustrate a simple putimage or rotozoom snippet.  Smile



Attached Files
.7z   common resource files.7z (Size: 8.08 MB / Downloads: 189)
.7z   Old QB45 and QB64 Samples.7z (Size: 3.89 MB / Downloads: 132)
Print this item

  How do I...
Posted by: TarotRedhand - 05-03-2022, 11:14 PM - Forum: General Discussion - Replies (2)

Include an archive (e.g. *.7z) in a post? Perhaps I have been spoiled by Discourse where I just drag and drop one into a post as long as it's < 4meg. Obviously that doesn't work here otherwise I wouldn't be asking Cool .

Thanks.

TR

Print this item

  Just Some Maths
Posted by: TarotRedhand - 05-03-2022, 10:29 PM - Forum: One Hit Wonders - No Replies

Just a few things I created back in the late 1990s. First a few constants that you may or may not find useful -

Code: (Select All)
REM ******************************************************************
REM * A number of maths constants that have been pre-calculated in  *
REM * order to save execution time.                                  *
REM ******************************************************************

CONST PI# = 3.14159265358979323846              'PI

CONST PITimes2# = 6.28318530717959              'PI * 2
CONST PITimes3# = 9.42477796076938              'PI * 3
CONST PITimes4# = 12.5663706143592              'PI * 4
CONST PITimes5# = 15.707963267949                'PI * 5
CONST PITimes6# = 18.8495559215388              'PI * 6

CONST PIDividedBy2# = 1.57079632679489661923    'PI / 2
CONST PIDividedBy3# = 1.04719755119659774615    'PI / 3
CONST PIDividedBy4# = 0.78539816339744830962    'PI / 4
CONST PIDividedBy5# = 0.628318530717959          'PI / 5
CONST PIDividedBy6# = 0.52359877559829887308    'PI / 6

CONST PISquared# = 9.86960440108936              'PI * PI
CONST PICubed#  = 31.0062766802998              'PI * PI * PI
CONST SQROfPI#  = 1.77245385090552              'SQR(PI)
CONST ReciprocalOfPI# = 0.31830988618379067154  '1 / PI

CONST TwoDividedByPI#  = 0.63661977236758134308 '2 / PI
CONST ThreeDividedByPI# = 0.954929658551372      '3 / PI
CONST FourDividedByPI#  = 1.27323954473516      '4 / PI
CONST FiveDividedByPI#  = 1.59154943091895      '5 / PI
CONST SixDividedByPI#  = 1.90985931710274      '6 / PI

CONST FourThirdsOfPI#  = 4.18879020478639      '4 / 3 * PI

CONST TheConstantE# = 2.71828182845905

CONST SquareOfE# = 7.38905609893065              'E * E
CONST SQROfE# = 1.64872127070013                'SQR(E)
CONST ReciprocalOfE# = 0.367879441171442        '1 / E

CONST LOG3DividedBy2# = 0.54930614433405484570  'LOG(3) / 2

CONST SQROfPnt5# = 0.70710678118654752440        'SQR(0.5)
CONST SQROf2# = 1.41421356227309504880          'SQR(2)
CONST SQROf3# = 1.73205080756887729353          'SQR(3)
CONST TwoMinusSQROf3# = 0.26794919243112270647  '2 - SQR(3)
CONST TwelthRootOf2# = 1.059463094              '12th root of 2

CONST FeigenbaumConstant# = 4.6692016090

REM ******************************************************************
REM * Distance travelled by light in 1 second, minute, hour, day,    *
REM * year.  Measured in Miles (approximately).                      *
REM ******************************************************************

CONST LightSecondInMiles# = 186271.0
CONST LightMinuteInMiles# = 11176260.0
CONST LightHourInMiles# = 670575600.0
CONST LightDayInMiles# = 16093814400.0
CONST LightYearInMiles# = 5797796637600.0

REM ******************************************************************
REM * Distance travelled by light in 1 second, minute, hour, day,    *
REM * year.  Measured in KiloMeters (approximately).                *
REM ******************************************************************

CONST LightSecondInKiloMeters# = 299774.0
CONST LightMinuteInKiloMeters# = 17986440.0
CONST LightHourInKiloMeters# = 1079186400.0
CONST LightDayInKiloMeters# = 25900473600.0
CONST LightYearInKiloMeters# = 9330645614400.0

Then there is this library of a number maths routines. First the documentation (comments also included in the code) -

Code: (Select All)
REM ******************************************************************
REM * The following routines are entirely devoted to logarithms for  *
REM * bases other than e, which is the base used by QB.  The base    *
REM * used in a particular routine is denoted by the number which    *
REM * suffixes Log in the name of the function, with the exception  *
REM * of LogX where the user supplies the base.                      *
REM ******************************************************************

FUNCTION Log2#(x AS DOUBLE)
FUNCTION Log8#(x AS DOUBLE)
FUNCTION Log10#(x AS DOUBLE)
FUNCTION Log16#(x AS DOUBLE)
FUNCTION LogX#(x AS DOUBLE, LogBase AS DOUBLE)

FUNCTION AntiLog2#(x AS DOUBLE)
FUNCTION AntiLog8#(x AS DOUBLE)
FUNCTION AntiLog10#(x AS DOUBLE)
FUNCTION AntiLog16#(x AS DOUBLE)
FUNCTION AntiLogX#(x AS DOUBLE, LogBase AS DOUBLE)

REM ******************************************************************
REM * Finds the y'th root of x.                                      *
REM ******************************************************************

FUNCTION Root#(x AS DOUBLE, y AS DOUBLE)

REM ******************************************************************
REM * Raise x to the power of y.                                    *
REM ******************************************************************

FUNCTION Power#(x AS DOUBLE, y AS DOUBLE)

REM ******************************************************************
REM * Returns x' = x * (x - 1) * (x - 2) ... * 1.  Non-recursive!    *
REM ******************************************************************

FUNCTION Factorial#(x AS DOUBLE)

REM ******************************************************************
REM * Returns the arithmetic mean (average) and the sample standard  *
REM * deviation of the values held in the array In.                  *
REM ******************************************************************

SUB MeanDeviation(Mean AS DOUBLE, StandardDeviation AS DOUBLE, In#())

REM ******************************************************************
REM * Returns a random number that is constrained to have a          *
REM * greater probability of falling within the centre of upper and  *
REM * lower bounds.                                                  *
REM ******************************************************************

FUNCTION GaussianRnd#(DesiredMean#, DesiredDeviation#)

Finally the code -

Code: (Select All)
OPTION BASE 0

REM ******************************************************************
REM * Pre-calculated constants for use by the logarithmic functions  *
REM ******************************************************************

CONST LOGOf2# = 0.6931471805599453094172321      'LOG(2)
CONST LOGOf8# = 2.07944154167984                  'LOG(8)
CONST LOGOf10# = 2.30258509299405                'LOG(10)
CONST LOGOf16# = 2.77258872223978                'LOG(16)

CONST Log2E# = 1.4426950408889634074              '1/LOG(2)
CONST Log8E# = 0.480898346962988                  '1/LOG(8)
CONST Log10E# = 0.43429448190325182765            '1/LOG(10.0)
CONST Log16E# = 0.360673760222241                '1/LOG(16)

REM ******************************************************************
REM * The following routines are entirely devoted to logarithms for  *
REM * bases other than e, which is the base used by QB.  The base    *
REM * used in a particular routine is denoted by the number which    *
REM * suffixes Log in the name of the function, with the exception  *
REM * of LogX where the user supplies the base.                      *
REM ******************************************************************

FUNCTION Log2#(x AS DOUBLE)
    IF x < 0.0 THEN
        Log2# = 0.0
    ELSE
        Log2# = LOG(x) * Log2E#
    END IF
END FUNCTION

FUNCTION Log8#(x AS DOUBLE)
    IF x < 0.0 THEN
        Log8# = 0.0
    ELSE
        Log8# = Log(x) * Log8E#
    END IF
END FUNCTION

FUNCTION Log10#(x AS DOUBLE)
    IF x < 0.0 THEN
        Log10# = 0.0
    ELSE
        Log10# = Log(x) * Log10E#
    END IF
END FUNCTION

FUNCTION Log16#(x AS DOUBLE)
    IF x < 0.0 THEN
        Log16# = 0.0
    ELSE
        Log16# = Log(x) * Log16E#
    END IF
END FUNCTION

FUNCTION LogX#(x AS DOUBLE, LogBase AS DOUBLE)
    IF ((x < 0.0) OR (LogBase <= 0.0)) THEN
        LogX# = 0.0
    ELSE
        LogX# = Log(x) / Log(LogBase)
    END IF
END FUNCTION

FUNCTION AntiLog2#(x AS DOUBLE)
    AntiLog2# = EXP(LOGOf2# * x)
END FUNCTION

FUNCTION AntiLog8#(x AS DOUBLE)
    AntiLog8# = EXP(LOGOf8# * x)
END FUNCTION

FUNCTION AntiLog10#(x AS DOUBLE)
    AntiLog10# = EXP(LOGOf10# * x)
END FUNCTION

FUNCTION AntiLog16#(x AS DOUBLE)
    AntiLog16# = EXP(LOGOf16# * x)
END FUNCTION

FUNCTION AntiLogX#(x AS DOUBLE, LogBase AS DOUBLE)
    IF ((x <= 0.0) OR (LogBase <= 0.0)) THEN
        AntiLogX# = 0.0
    ELSE
        AntiLogX# = EXP(Log(LogBase) * x)
    END IF
END FUNCTION

REM ******************************************************************
REM * Finds the y'th root of x.                                      *
REM ******************************************************************

FUNCTION Root#(x AS DOUBLE, y AS DOUBLE)
    IF ((x <= 0.0) OR (y = 0.0)) THEN
        Root# = 0.0
    ELSE
        Root# = EXP(LOG(x) / y)
    END IF
END FUNCTION

REM ******************************************************************
REM * Raise x to the power of y.                                    *
REM ******************************************************************

FUNCTION Power#(x AS DOUBLE, y AS DOUBLE)
    IF ((x <= 0.0) OR (y = 0.0)) THEN
        Power# = 0.0
    ELSE
        Power# = EXP(LOG(x) * y)
    END IF
END FUNCTION

REM ******************************************************************
REM * Returns x' = x * (x - 1) * (x - 2) ... * 1.  Non-recursive!    *
REM ******************************************************************

FUNCTION Factorial#(x AS DOUBLE)
    WorkingValue# = 2.0
    ReturnValue# = 1.0
    DO WHILE (WorkingValue# <= x)
        ReturnValue# = ReturnValue# * WorkingValue#
        WorkingValue# = WorkingValue# + 1.0
    LOOP
    Factorial# = ReturnValue#
END FUNCTION

REM ******************************************************************
REM * Returns the arithmetic mean (average) and the sample standard  *
REM * deviation of the values held in the array In.                  *
REM ******************************************************************

SUB MeanDeviation(Mean AS DOUBLE, StandardDeviation AS DOUBLE, In#())
    Sum# = 0.0#
    SumOfSquares# = 0.0#
    StartIndex% = LBOUND(In#)
    NumberOfValues% = UBOUND(In#)
    FOR Index% = StartIndex% TO NumberOfValues%
        Sum# = Sum# + In#(Index%)
        SumOfSquares# = SumOfSquares# + In#(Index%) * In#(Index%)
    NEXT Index%
    Mean = Sum# / NumberOfValues
    StandardDeviation = SQR(SumOfSquares# - Sum# * Sum# / NumberOfValues) / (NumberOfValues - 1.0)
END SUB

REM ******************************************************************
REM * Returns a random number that is constrained to have a          *
REM * greater probability of falling within the centre of upper and  *
REM * lower bounds.                                                  *
REM ******************************************************************

FUNCTION GaussianRnd#(DesiredMean#, DesiredDeviation#)
    RandomSum# = 0#
    FOR x% = 1 TO 12
        RandomSum# = RandomSum# + RND
    NEXT x%
    GausianRnd# = (RandomSum# - 6#) * DesiredDeviation# + DesiredMean#
END FUNCTION

Hope you have a use for these.

TR

Print this item

  Plasma Studies
Posted by: bplus - 05-03-2022, 08:03 PM - Forum: bplus - Replies (14)

Probably one of my signature code themes, I've played with Plasma the color sequencing method and with Plasma the 2D blobs. This thread is a study of the latter.
________________________________________________________________________________________________

The earliest QB64 file I can find is Ectoplasm more about Ghost busters than plasma the blobs but close enough:

Code: (Select All)
_Title "Ectoplasm" 'mod of Galileo's at Retro 2019-06-22 B+
'open window 256, 256
Screen _NewImage(256, 256, 32)
Randomize Timer
'sh=peek("winheight")
sh = _Height
'sw=peek("winwidth")
sw = _Width
d = 1
Do
    'tm = peek("secondsrunning")
    tm = Timer(.001)
    dr = ran(256): dg = ran(256): db = ran(256)
    w = w + 5 / 83 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< get things moving
    For y = 0 To sh
        For x = 0 To sw
            vl = Sin(distance(x + tm, y, 128, 128) / 8 + w)
            vl = vl + Sin(distance(x, y, 64, 64) / 8)
            vl = vl + Sin(distance(x, y + tm / 7, 192, 64) / 7)
            vl = vl + Sin(distance(x, y, 192, 100) / 8)
            clr = 255 / (1.00001 * Abs(vl))
            r = .9 * Abs(clr - dr): g = .4 * Abs(clr - dg): b = .5 * Abs(clr - db)
            'COLOR r, g, b
            'dot x, y
            PSet (x, y), _RGB32(r, g, b)
        Next
    Next
    If w > 1000 Or w < -1000 Then w = 0: d = d * -1
    _Display
    _Limit 200
Loop
Function distance (x1, y1, x2, y2) '//between two points x1,y1 and x2,y2
    distance = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5
End Function
Function ran% (sing)
    ran% = Int(Rnd * sing) + 1
End Function



Attached Files Thumbnail(s)
   
Print this item