Basicprogramming(.org) > General questions and discussions

Method or Madness ;-))

<< < (2/4) > >>

 The speed of Small Basic for drawing circles, was unexpected.


--- Quote from: Rick3137 on May 27, 2017, 09:23:12 pm ---The speed of Small Basic for drawing circles, was unexpected.
--- End quote ---

Your 156 ms on top of the image are realistic. This is roughly what I get on my core i5 with the attached code, which simply uses the built-in Windows function GdipAddPathEllipse. What is your cpu?

Note that GdipAddPathEllipse is a slow Gdi+ function. The standard GDI Ellipse function is about ten times as fast.

Rick your numbers are shockingly weird to me, wow!

For me SdlBasic circle fill tests ran a bit slower which was surprising because usually SB graphics translations run faster in SdlBasic.

But Rick you have SB 10 times faster than I and SdlBasic many times slower??? yikes, that is crazy different and you use Windows 10 as I recall, maybe your much newer machine explains difference (but why would SdlBasic be so much slower than my results?)

BTW the Bresenham algo in Sdlbasic did not show improved results over my new circle algo but for me ran in between my old and new cilrcle algos. I posted code at SdlBasic forum to see if my translation was missing something.

Rick could I see your SdlBasic translation for the numbers you posted?

Hi JJ,

--- Quote ---{\rtf1\ansi\ansicpg1252\deff0\deflang1036{\fonttbl{\f0\fnil\fcharset0 System;}}
{\colortbl ;\red0\green0\blue0;\red0\green0\blue255;\red112\green112\blue112;\red255\green0\blue0;}
{\*\generator Riched20;}\viewkind4\uc1\pard\sl360\slmult1\tx1000\tx1400\tx4800\tx5800\tx0\cf1\v\f0\fs24\lang1040\'b0B$;00FR00FR0G222b1i6212105Y001dA100034.errameeP2x4echoameeP2x7penNameeP2x5isArrneeP2x4tmp$eneeP2x6gdiPeneeP205argC$seeP207ellipseeP2x8MyCircleP20n000Bb020D00Dh000A00DG000A00C7000E00DA000G00Ak000Gu00zc0Vn#\cf0\protect\'b0B5\cf2\protect0\v0 GuiParas\cf1  equ "Fast circles", w700, h720\par
include \\masm32\\MasmBasic\\Res\\MbGui.asm\tab\cf3 ; \cf0\protect\v \protect0\v0 MasmBasic\protect\v \cf1\protect0\v0\par
\pard\sl240\slmult1\tx1000\tx1400\tx4800\tx5800\tx0   \cf2 Dim\cf1  Pens() As DWORD\par
  \cf2 Dim\cf1  Brushes() As DWORD\par
  \cf2 For_\cf1  ct=0 To 99\par
\tab\cf2 MakePen\cf1  Pens(ct), \cf2 Rand\cf1(-1), width 5\tab\cf3 ; use random colours\cf1\par
\tab\cf2 MakeBrush\cf1  Brushes(ct), \cf2 Rand\cf1(-1)\tab\cf3 ; also for the fill\cf1\par
\cf2   Next\cf1\par
\pard\sl360\slmult1\tx1000\tx1400\tx4800\tx5800\tx0   \cf2 MakePath\cf1\tab 123, Circle(500)\cf3\tab ; ID, type circle: radius 50%, i.e. n/1000 of window rect\cf0\par
\pard\tx1000\tx1400\tx4800\tx5800\tx0\protect\v\'b0B8\cf2\protect0\v0 Event\cf1  Key\par
\pard\sl360\slmult1\tx1000\tx1400\tx4800\tx5800\tx0   \cf2 GuiCls\cf1\par
\pard\tx1000\tx1400\tx4800\tx5800\tx0\cf0\protect\v\'b0B8\cf2\protect0\v0 Event\f1  cPaint\par
  \cf2 NanoTimer\cf1()\par
\pard\tx600\tx1000\tx1400\tx1800\tx2133\tx2466\tx2800\tx3050\tx3300\tx3550\tx3800\tx4800\tx0   \cf2 For_\cf1  ct=0 \cf2 To\cf1  99\tab\cf3 ; ID\tab\tab pen/brush\tab\tab\tab x\tab\tab y\tab\tab(\cf4 no\cf3  scaleX\tab scaleY)\cf1\par
\pard\tx1000\tx1400\tx4800\tx5800\tx0\cf2\tab GuiDraw\cf1  123, <Pens(ct)/Brushes(ct)>, <\cf2 Rand\cf1(500).>, <\cf2 Rand\cf1(500).>\tab\cf3 ; , eax, <Rand(1000)>\tab ; ScaleX is eax, same as scaleY\par
\cf1   \cf2 Next\cf1\par
  \cf2 GuiText\cf1  100.0-205, 100.0-24, \cf2 Str$\cf1("%i ms (hit any key to refresh)", \cf2 NanoTimer\cf1(ms))\tab\cf3 ; ca 150 ms on a Core i5\cf1\par
\cf0\protect\v\lang1036\'b0B3\cf2\protect0\v0 GuiEnd\cf1\par
--- End quote ---

Are you just using Paint to fill the circle?


--- Quote from: B+ on May 28, 2017, 05:19:40 pm ---Are you just using Paint to fill the circle?
--- End quote ---

No, it's GdipAddPathEllipse, a Windows Gdi+ function. As mentioned above, Ellipse is an even faster option, if you just want simple low quality circles.

The file is RTF, it opens in RichMasm, WordPad, MS Word, LibreOffice, ...


[0] Message Index

[#] Next page

[*] Previous page

Go to full version