I almost have something. With shader
uniform sampler2D texture0;
varying mediump vec2 uvVarying;
varying mediump vec4 colorVarying;
uniform float StartAngle;
uniform float EndAngle;
void main()
{
float x = uvVarying.x-0.5;
float y = uvVarying.y-0.5;
float angle = atan(y,x);
if ((sqrt(x*x+y*y) <= 0.5) && ((angle >= StartAngle) && (angle <= EndAngle)))
{
gl_FragColor = colorVarying;
}
else
{
gl_FragColor = vec4(0.0,0.0,0.0,0.0);
}
}
and AppGameKit code
// Project: DrawCircle
// Created: 2018-12-16
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "DrawCircle" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetResolutionMode( 1 )
global shader as integer
shader = LoadSpriteShader("CircleArc.ps")
global circleSprite as integer
circleSprite = CreateSprite(CreateImageColor(255,255,255,255))
SetSpriteShader(circleSprite,Shader)
SetSpriteTransparency(circleSprite,1)
colorRed As Integer
colorRed = MakeColor(255,0,0)
angle As Float
do
angle = PointDirection(1024/2,768/2, GetRawMouseX(), GetRawMouseY())
DrawCircle(1024/2,768/2,768/2, colorRed, 0, -angle)
Print( ScreenFPS() )
Print( angle )
Sync()
loop
// Source https://qb64.org/wiki/Alternative_circle_routine
Function DrawCircle(cx As Integer, cy As Integer, r As Float, color As Integer, s# As Float, e# As Float)
// Local variables used
st As Float
en As Float
SetSpriteSize(circleSprite,r*2,r*2)
SetSpritePosition(circleSprite,cx-r,cy-r)
SetSpriteColor(circleSprite,GetColorRed(color),GetColorBlue(Color),GetColorGreen(Color),255)
st = s# * 0.01745329252 // convert start angle to radian and copy to local variable
en = e# * 0.01745329252 // convert end angle to radian and copy to local variable
if st < en
SetShaderConstantByName(shader,"StartAngle",st,0,0,0)
SetShaderConstantByName(shader,"EndAngle",en,0,0,0)
else
SetShaderConstantByName(shader,"StartAngle",en,0,0,0)
SetShaderConstantByName(shader,"EndAngle",st,0,0,0)
endif
EndFunction
Function PointDirection(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer)
angle As Float
angle = ATanFull(y1 - y2, x1 - x2)
EndFunction angle
It works well and quick up to 180 degrees. For some reason, it wont render above that.