As you never posted any example code, I put together a small demo for myself (it's the first time I think i've used the Sprite library).
I'll be honest with you, I couldn't see too much jaggedness with the sprite rendering, but I do have natures anti-aliasing algorithm running (poor eyesight
).
SpriteOutput was slow as you described & for reasons already explained - I couldn't find a way to use VectorDrawing library with it either, or find a command that creates a sprite from an existing image, which was surprising.
As always there are workarounds for these limitations - The workround I found was ~50% faster than SpriteOutput() on my PC; draw to an image, EncodeImage() to a bitmap buffer and then Catchsprite from that buffer:
Code: Select all
; Sprite test - PJ 23.
EnableExplicit
Define event, exit, frames, nextSecond.q, max, Rotation.f
#Size = 768
Enumeration
#MySpr_BG
#MySpr_Needle
EndEnumeration
Procedure CatchSpriteFromImage(Sprite, Image)
Protected *mem = EncodeImage(Image,#PB_ImagePlugin_BMP)
CatchSprite(Sprite,*mem,#PB_Sprite_AlphaBlending)
FreeMemory(*mem)
EndProcedure
Procedure DrawSpriteImages()
Protected ang, hx = #Size / 2, hy = #Size / 2, txt.s, shadow = hy * 0.01
CreateImage(#MySpr_BG,#Size,#Size,32) : CreateImage(#MySpr_Needle,#Size,#Size,32)
LoadFont(0,"Arial",32,#PB_Font_HighQuality|#PB_Font_Bold)
; face
StartVectorDrawing(ImageVectorOutput(#MySpr_BG))
VectorSourceColor(RGBA(60,70,80,255)) : FillVectorOutput()
VectorSourceColor(RGBA(30,50,70,240)) : AddPathCircle(hx,hy,hy * 0.99) : FillPath()
VectorSourceColor(RGBA(30,30,30,255)) : AddPathCircle(hx,hy,hy * 0.99,149,391) : StrokePath(hy * 0.04)
VectorSourceColor(RGBA(200,220,240,255)) : AddPathCircle(hx,hy,hy * 0.99,149,391) : StrokePath(hy * 0.02)
VectorFont(FontID(0),hx / 5.5)
For ang = 150 To 400 Step 24
If ang > 310 : VectorSourceColor(RGBA(230,40,70,255)) : EndIf
MovePathCursor(hx + (hy * 0.97) * Cos(Radian(ang)),hy + (hy*0.97) * Sin(Radian(ang)))
AddPathLine(hx + (hy * 0.825) * Cos(Radian(ang)),hy + (hy * 0.825) * Sin(Radian(ang))) : StrokePath(7.5)
txt = Str((Ang - 150) / 24)
VectorSourceColor(RGBA(30,30,30,255))
MovePathCursor((hx + shadow + (hy * 0.7) * Cos(Radian(ang))) - (VectorTextWidth(txt)/2), (hy + shadow + (hy * 0.7) * Sin(Radian(ang))) - (VectorTextHeight(txt)/2))
DrawVectorText(txt)
VectorSourceColor(RGBA(220,225,240,255)) : If ang > 310 : VectorSourceColor(RGBA(230,30,60,255)) : EndIf
MovePathCursor((hx + (hy * 0.7) * Cos(Radian(ang))) - (VectorTextWidth(txt)/2), (hy + (hy * 0.7) * Sin(Radian(ang))) - (VectorTextHeight(txt)/2))
DrawVectorText(txt)
Next
VectorSourceColor(RGBA(200,220,240,255))
For ang = 150 To 390 Step 4
If ang > 314 : VectorSourceColor(RGBA(230,40,70,255)) : EndIf
MovePathCursor(hx + (hy * 0.97) * Cos(Radian(ang)),hy + (hy * 0.97) * Sin(Radian(ang)))
AddPathLine(hx + (hy * 0.88) * Cos(Radian(ang)),hy + (hy * 0.88) * Sin(Radian(ang)))
StrokePath(2.5)
Next
StopVectorDrawing()
; needle
StartDrawing(ImageOutput(#MySpr_Needle))
DrawingMode(#PB_2DDrawing_AllChannels) : Box(0,0,OutputWidth(),OutputHeight(),RGBA(0,0,0,0))
StopDrawing()
StartVectorDrawing(ImageVectorOutput(#MySpr_Needle))
VectorSourceColor(RGBA(230,50,80,255))
MovePathCursor(hx + (hy * 0.825) * Cos(Radian(225)),hy + (hy * 0.825) * Sin(Radian(225)))
AddPathLine(hx + (hy * 0.2) * Cos(Radian(45)),hy + (hy * 0.2) * Sin(Radian(45)))
StrokePath(hy * 0.075, #PB_Path_RoundEnd)
VectorSourceColor(RGBA(0,0,0,255)) : AddPathCircle(hx,hy,48) : FillPath()
VectorSourceColor(RGBA(80,80,80,255)) : AddPathCircle(hx,hy,32) : FillPath()
VectorSourceColor(RGBA(24,20,24,255)) : AddPathCircle(hx,hy,8) : FillPath()
StopVectorDrawing()
CatchSpriteFromImage(#MySpr_BG,#MySpr_BG)
CatchSpriteFromImage(#MySpr_Needle,#MySpr_Needle)
EndProcedure
Procedure Init_Main()
InitSprite()
OpenWindow(0, 0,0,#Size / DesktopResolutionX(),#Size / DesktopResolutionY(),"Tacho - standard sprite",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, #Size, #Size, 0, 0, 0,#PB_Screen_SmartSynchronization)
SpriteQuality(#PB_Sprite_BilinearFiltering)
DrawSpriteImages()
EndProcedure
Init_Main()
nextSecond = ElapsedMilliseconds() + 1000
Repeat
Repeat
event = WindowEvent()
Select event
Case #PB_Event_CloseWindow : exit = #True
EndSelect
Until Event = 0
ClearScreen(0)
DisplaySprite(#MySpr_BG,0,0)
Rotation = Cos(Radian((ElapsedMilliseconds() + 1400) / 8.0)) * 150
If Rotation > 90 : Rotation = 90 : Rotation - Abs(Sin(Radian((ElapsedMilliseconds() + 60))) * 50) : EndIf
RotateSprite(#MySpr_Needle,Rotation + 75,#PB_Absolute)
DisplayTransparentSprite(#MySpr_Needle,0,0)
FlipBuffers()
frames + 1
If ElapsedMilliseconds() >= nextSecond
If frames > max : max = frames : EndIf
nextSecond = ElapsedMilliseconds() + 1000
SetWindowTitle(0,Str(frames)+ " fps - Max: "+Str(max))
frames = 0
EndIf
Until exit = #True