Circles would be hard, but here's a single line drawing function...
SetVirtualResolution(1024, 768)
` The line start and end coordinates,
` using center screen as line start point.
` The line will be drawn from a point located
` at x1#,y1# on the screen to the point located
` at x2#,y2# on the screen.
x1# as float = 512.0
y1# as float = 384.0
x2# as float
y2# as float
` This determines how wide the line is.
lineWidth as Integer = 1
` This determines what color the line will be drawn with.
` Each color value can range from 0 to 255, with 0 being
` no intensity, and 255 being maximum intensity for that color.
` The three values (red, green, blue) are combined to make
` the final color.
lineColorRed as Integer
lineColorGreen as Integer
lineColorBlue as Integer
` This determines the transparency of the line, and can
` range from 0 (totally transparent) to 255 (totally opaque).
lineColorAlpha as Integer = 255
` Load the one-pixel image, make a sprite from it, and position the sprite.
` The variable pixelSpr is set to global because it is used by our function.
global pixelSpr
` The image should be a single white pixel. You can make this in MS Paint
` or any other drawing program. It can be a .png, .jpg, or .bmp format.
pixelImg = LoadImage("Pixel.png")
` This creates the sprite, using the loaded pixel image.
pixelSpr = CreateSprite(pixelImg)
` This locates the sprite at our starting coordinate.
SetSpritePosition(pixelSpr, x1#, y1#)
` Main program loop.
do
` This checks to see if the pointer has been clicked/pressed and then released.
` The pointer will be the mouse on a computer, or your finger on a tablet.
if GetPointerReleased()
` This captures the screen coordinates of where the pointer was when it was released.
x2# = GetPointerX()
y2# = GetPointerY()
` This picks a random color for the line.
lineColorRed = Random(0,255)
lineColorGreen = Random(0,255)
lineColorBlue = Random(0,255)
` This picks a random width for the line.
lineWidth = Random(1,10)
`This calls the function that resizes the pixel and points it at the pointer location.
drawPixelLine(x1#, y1#, x2#, y2#, lineWidth, lineColorRed, lineColorGreen, lineColorBlue, lineColorAlpha)
endif
Sync()
loop
` Drawing the line. Note that this function as written only works for drawing one line/sprite. It would certainly
` be possible to put more lines on the screen, but this function only does one.
function drawPixelLine(x1#, y1#, x2#, y2#, lineWidth, lineColorRed, lineColorGreen, lineColorBlue, lineColorAlpha)
` Distance is from the first coordinate pair to the second pair.
` We'll use it determine how far we stretch the sprite.
distance# as float
` Angle is the direction we point the sprite. The sprite points from
` the first coordinate pair to the second coordinate pair.
angle# as float
` Calculate the distance.
distance#=sqrt((x1#-x2#)^2+(y1#-y2#)^2)
` Calculate the angle, and adjust it to point correctly.
angle#=ATAN((y1#-y2#)/(x1#-x2#))
if x2# <= x1# then angle# = angle# - 90.0 else angle# = angle# + 90.0
` Stretch the sprite to have a width equal to our line width value,
` and a height equal to the distance between coordinate pairs.
SetSpriteSize(pixelSpr, lineWidth, distance#)
` Offset the origin and position of the sprite to account for the stretching.
SetSpriteOffset(pixelSpr, 0, distance#)
SetSpritePositionByOffset(pixelSpr, x1#, y1#)
` Point the sprite at the target location.
SetSpriteAngle(pixelSpr, angle#)
` And make the sprite match our color choice!
SetSpriteColor(pixelSpr, lineColorRed, lineColorGreen, lineColorBlue, lineColorAlpha)
endfunction