09-02-2025, 08:00 PM
I figured it was important after my little b*tch moment recently that i participate so I made AI write this!!! It took longer to correct it than if id done it myself and still its not what i wanted....but its close! It's inspired by the arecibo disk...I hope it's okay...I'm not sorry i used AI as its something im very much into to expand/improve my coding.
As always, Happy coding!
Unseen
Code: (Select All)
' Main program
SCREEN _NEWIMAGE(1024, 768, 32) ' Create a high-resolution window
COLOR _RGB32(255, 255, 255) ' Set default text color to white
CLS
DIM message AS STRING
' Get user input
LOCATE 1, 1
PRINT "Enter your message to convert into a binary crop circle:"
INPUT message
' Clear screen for graphics
CLS
' Draw the alien face and the main encompassing circle
CALL DrawAlienFace(300, 384)
CIRCLE (750, 384), 250, _RGB(250, 0, 0) ' The main circle boundary
' Draw the text as binary blocks inside the large circle
CALL TextToBinaryBlocks(message)
' Keep the program running until a key is pressed
DO: LOOP UNTIL INKEY$ <> ""
END
SUB TextToBinaryBlocks (message$)
DIM binaryString AS STRING
DIM totalBits AS INTEGER
DIM i AS INTEGER
DIM j AS INTEGER
DIM centerX AS INTEGER, centerY AS INTEGER
DIM lineCount AS INTEGER
DIM lineBits AS INTEGER
DIM radiusStep AS SINGLE
DIM bitAngleStep AS DOUBLE
DIM lineRadius AS SINGLE
DIM angle AS DOUBLE
DIM colorCode AS LONG
DIM blockSize AS INTEGER
DIM blockAngularWidth AS DOUBLE
centerX = 750
centerY = _HEIGHT / 2
' Concatenate the binary representations of all characters
FOR i = 1 TO LEN(message$)
binaryString = binaryString + GetBinary(MID$(message$, i, 1))
NEXT i
totalBits = LEN(binaryString)
lineCount = 5
lineBits = INT(totalBits / lineCount) ' Number of bits per circle line
IF totalBits MOD lineCount > 0 THEN lineBits = lineBits + 1
radiusStep = 20 ' Distance between concentric circles
' Loop through the number of lines
FOR i = 1 TO lineCount
lineRadius = 100 + (i - 1) * radiusStep ' Start with an inner radius and step out
angle = 0
' Adjust the block size (radial height) based on the radius
blockSize = 5 + (i - 1) * 3
' The desired angular width of each block in radians (assuming constant size at a reference radius)
blockAngularWidth = .05 ' Adjust this constant for desired width
' Calculate the angular step needed to fit all blocks without overlapping
bitAngleStep = (2 * 3.14159) / lineBits
' Loop through the bits for the current line
FOR j = 1 TO lineBits
IF (i - 1) * lineBits + j <= totalBits THEN
' Set the color based on the binary digit
IF MID$(binaryString, (i - 1) * lineBits + j, 1) = "1" THEN
colorCode = _RGB(255, 0, 0) ' Solid Red
ELSE
colorCode = _RGB(255, 70, 70) ' Light Red
END IF
' Draw a filled, rotated block at the calculated position
CALL DrawFilledRotatedBlock(centerX, centerY, lineRadius, angle, blockSize, blockAngularWidth, colorCode)
END IF
angle = angle + bitAngleStep ' Increment angle for the next bit
NEXT j
NEXT i
END SUB
' ==========================================================
' Subroutine to draw a filled, rotated block
SUB DrawFilledRotatedBlock (centerX AS INTEGER, centerY AS INTEGER, radius AS SINGLE, angle AS DOUBLE, blockSize AS INTEGER, blockAngleWidth AS DOUBLE, colorCode AS LONG)
DIM x1 AS INTEGER, y1 AS INTEGER
DIM x2 AS INTEGER, y2 AS INTEGER
' Use a loop to draw lines from the inner radius to the outer radius, filling the segment
FOR i = 0 TO blockSize - 1 STEP 1
x1 = centerX + ((radius + i) * COS(angle - blockAngleWidth))
y1 = centerY + ((radius + i) * SIN(angle - blockAngleWidth))
x2 = centerX + ((radius + i) * COS(angle + blockAngleWidth))
y2 = centerY + ((radius + i) * SIN(angle + blockAngleWidth))
LINE (x1, y1)-(x2, y2), colorCode
NEXT i
END SUB
' ==========================================================
' Function to convert a single character to its 8-bit binary string
FUNCTION GetBinary$ (char AS STRING)
DIM ascValue AS INTEGER
DIM binaryResult AS STRING
DIM i AS INTEGER
ascValue = ASC(char)
binaryResult = ""
FOR i = 7 TO 0 STEP -1
IF (ascValue AND (2 ^ i)) THEN
binaryResult = binaryResult + "1"
ELSE
binaryResult = binaryResult + "0"
END IF
NEXT i
GetBinary = binaryResult
END FUNCTION
' ==========================================================
' Subroutine to draw a basic alien face
SUB DrawAlienFace (centerX AS INTEGER, centerY AS INTEGER)
' Head (ellipse)
CIRCLE (centerX, centerY - 50), 100, _RGB(0, 100, 0), , , 1.5
PAINT (centerX, centerY - 50), _RGB(0, 100, 0)
' Eyes (black ellipses with white glints)
CIRCLE (centerX - 40, centerY - 60), 20, _RGB(0, 0, 0), , , 0.5
PAINT (centerX - 40, centerY - 60), _RGB(0, 0, 0)
CIRCLE (centerX + 40, centerY - 60), 20, _RGB(0, 0, 0), , , 0.5
PAINT (centerX + 40, centerY - 60), _RGB(0, 0, 0)
' Glints
CIRCLE (centerX - 35, centerY - 65), 3, _RGB(255, 255, 255)
PAINT (centerX - 35, centerY - 65), _RGB(255, 255, 255)
CIRCLE (centerX + 45, centerY - 65), 3, _RGB(255, 255, 255)
PAINT (centerX + 45, centerY - 65), _RGB(255, 255, 255)
' Mouth (simple line)
LINE (centerX - 20, centerY + 30)-(centerX + 20, centerY + 30), _RGB(0, 0, 0)
' Neck (shaded rectangle)
LINE (centerX - 25, centerY + 50)-(centerX + 25, centerY + 80), _RGB(0, 100, 0), BF
END SUB
As always, Happy coding!
Unseen

