Okay been messing with this some more, the code below doesn't need a brush loading in now but just change the following line in the code to make a square or circle brush to see the difference.
//iBrush = GetImage( 0, 0, 128, 128 )
iBrush = CreateImageColor(255,255,255,255) // If you change this line for the one above you can see it doesn't do it on a square.
It has to be something in rendering the curve of the line of the circle.
Global w,h,rw,rh,screenTop as integer
w = 1280
h = 800
SetWindowTitle( "Paint" )
SetScreenResolution( w, h)
SetSyncRate( 0, 0 )
SetVirtualResolution( w, h )
//SetScissor( 0, 0, 0, 0 )
SetClearColor(0,0,0)
SetPrintSize(20)
rendW = 2048
rendH = 1024
// create two render targets and swap between them
global buffer as integer[1]
buffer[0] = CreateRenderImage( rendW, rendH, 0, 0 ) // currently render targets must be a power of 2
buffer[1] = CreateRenderImage( rendW, rendH, 0, 0 ) // luckily they don't have to match the current screen size to work
global currBuffer as integer = 0
// clear them both
SetRenderToImage( buffer[currBuffer], 0 )
ClearScreen()
SetRenderToImage( buffer[1-currBuffer], 0 )
ClearScreen()
SetRenderToScreen()
// create the screen sprite, this will be used to display the final image and draw the
// background of the next render image
global screen as integer
screen = CreateSprite(buffer[currBuffer])
SetSpriteDepth(screen,1000)
SetSpriteTransparency(screen,0)
// these positions only matter if you have black borders, the render image will also have
// them so the sprite displaying it must be in the true top left corner of the screen
// if you can guarantee no black borders then you can use 0,0 and w,h
SetSpritePosition(screen,GetScreenBoundsLeft(),GetScreenBoundsTop())
SetSpriteSize(screen, GetScreenBoundsRight()-GetScreenBoundsLeft(),GetScreenBoundsBottom()-GetScreenBoundsTop())
ClearScreen()
DrawEllipse( 64, 64, 64, 64, MakeColor(255,255,255), MakeColor(255,255,255), 1)
//iBrush = GetImage( 0, 0, 128, 128 )
iBrush = CreateImageColor(255,255,255,255) // If you change this line for the one above you can see it doesn't do it on a square.
Global Brush as integer
Brush = CreateSprite(iBrush)
setspritesize(Brush,128,128)
SetSpriteOffset(Brush, GetSpriteWidth(brush)/2,GetSpriteHeight(brush)/2)
clearscreen()
SetSpritePosition(brush,-200,0)
SetSpriteVisible(Brush,0)
Do
Print("FPS:"+str(ScreenFPS(),0))
if getpointerpressed()
SetSpriteColor(brush, Random(0,255), Random(0,255), Random(0,255), 255)
endif
if GetPointerState()=1
x = GetPointerX()
y = GetPointerY()
Paint(x,y)
endif
sync()
Loop
function Paint(x,y)
// Draw the current screen with the old render image onto the new render image
// Draw the new brush onto the new render image
// Set the new render image as the screen image and swap the buffers ready to do it again
// make sure the background image is in the right place just in case
SetSpriteImage( screen, buffer[1-currBuffer] )
SetSpritePosition(screen,GetScreenBoundsLeft(),GetScreenBoundsTop())
SetSpriteSize(screen, GetScreenBoundsRight()-GetScreenBoundsLeft(),GetScreenBoundsBottom()-GetScreenBoundsTop())
// clear the image and draw the background (the current scene)
SetRenderToImage( buffer[currBuffer], 0 )
ClearScreen()
DrawSprite(screen)
// draw the new brush
SetSpritePositionByOffset(Brush,x,y)
SetSpriteAngle(Brush, random(0,360))
SetSpriteVisible(Brush,1)
DrawSprite(Brush)
SetSpriteVisible(Brush,0)
SetRenderToScreen()
// set the new render image as the current scene and swap the buffers for next time
SetSpriteImage( screen, buffer[currBuffer] )
currBuffer = 1-currBuffer
endfunction