From: Svjatoslav Agejenko Date: Sat, 26 Oct 2024 07:43:47 +0000 (+0300) Subject: Using AI to improve code readability X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=487d0bfcc13e663f439896d476e276ad8d68ec77;p=qbasicapps.git Using AI to improve code readability --- diff --git a/Graphics/Animations/movdna.bas b/Graphics/Animations/movdna.bas index 70c45d6..61b4d7e 100755 --- a/Graphics/Animations/movdna.bas +++ b/Graphics/Animations/movdna.bas @@ -1,53 +1,75 @@ -' Program to render animated DNA. +' Program to render animated DNA as seen in the movies. +' ' By Svjatoslav Agejenko. ' Email: svjatoslav@svjatoslav.eu ' Homepage: http://www.svjatoslav.eu ' +' Changelog: +' ?, Initial version +' 2024, Improved program readability using AI -DEFINT A-Y - -DIM SHARED cx(1 TO 100) -DIM SHARED cy(1 TO 100) -DIM SHARED cz(1 TO 100) -DIM SHARED cc(1 TO 100) +DIM SHARED xCoordinates(1 TO 100) +DIM SHARED yCoordinates(1 TO 100) +DIM SHARED zCoordinates(1 TO 100) +DIM SHARED colorCodes(1 TO 100) SCREEN 7, , , 1 -f = 0 1: b = 0 -zf = zf + 0.1 +rotationAngle = rotationAngle + 0.1 FOR a = 1 TO 20 b = b + 1 - cx(b) = SIN(a / 2 + zf) * 30 + 150 - cz(b) = SIN(a / 2 + zf + 1.6) * 2 + 2 - cy(b) = a * 8 + cz(b) - cc(b) = 3 + ' Calculate x-coordinate using sine function and add to array + xCoordinates(b) = SIN(a / 2 + rotationAngle) * 30 + 150 + ' Calculate z-coordinate using sine function and add to array + zCoordinates(b) = SIN(a / 2 + rotationAngle + 1.6) * 2 + 2 + ' Calculate y-coordinate by multiplying a with 8 and adding z-coordinate + yCoordinates(b) = a * 8 + zCoordinates(b) + ' Assign color code to the current point + colorCodes(b) = 3 b = b + 1 - cx(b) = SIN(a / 2 + zf + 2.5) * 30 + 150 - cz(b) = SIN(a / 2 + zf + 1.6 + 2.5) * 2 + 2 - cy(b) = a * 8 + cz(b) - cc(b) = 4 + ' Calculate x-coordinate using sine function and add to array + xCoordinates(b) = SIN(a / 2 + rotationAngle + 2.5) * 30 + 150 + ' Calculate z-coordinate using sine function and add to array + zCoordinates(b) = SIN(a / 2 + rotationAngle + 1.6 + 2.5) * 2 + 2 + ' Calculate y-coordinate by multiplying a with 8 and adding z-coordinate + yCoordinates(b) = a * 8 + zCoordinates(b) + ' Assign color code to the current point + colorCodes(b) = 4 NEXT a +' Clear the screen CLS + +' Draw lines and circles based on z-coordinate FOR b = 0 TO 4 IF b = 1 THEN FOR a = 1 TO 40 STEP 2 - LINE (cx(a), cy(a))-(cx(a + 1), cy(a + 1)), 15 + ' Draw line between consecutive points + LINE (xCoordinates(a), yCoordinates(a))-(xCoordinates(a + 1), yCoordinates(a + 1)), 15 NEXT a END IF FOR a = 1 TO 40 - IF cz(a) = b THEN - CIRCLE (cx(a), cy(a)), b + 5, cc(a) - PAINT (cx(a), cy(a)), cc(a) - CIRCLE (cx(a), cy(a)), b + 5, 0 + ' Check if the current z-coordinate matches the loop variable b + IF int(zCoordinates(a)) = b THEN + ' Draw circle with specified color code + CIRCLE (xCoordinates(a), yCoordinates(a)), b + 5, colorCodes(a) + PAINT (xCoordinates(a), yCoordinates(a)), colorCodes(a) + ' Draw an black outline of the circle + CIRCLE (xCoordinates(a), yCoordinates(a)), b + 5, 0 END IF NEXT a NEXT b + +' Copy the screen to buffer and clear the screen PCOPY 0, 1 CLS + +' Check if any key is pressed IF INKEY$ = "" THEN GOTO 1 + +' End the program SYSTEM