Ulam Spiral Prime Numbers

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
nlexa
Posts: 26
Joined: Fri Aug 05, 2011 2:34 am

Ulam Spiral Prime Numbers

Post by nlexa » Tue Oct 01, 2013 7:48 am

Is there a limit to the number of points you can set in a graphic object?
Or perhaps you can't have more than 380000x2 lines in a variable?

I find that once I exceed around 380000 points that it forgets the first 380000 and continues drawing from there leaving a black square in the middle. Also if I show the progress bar updating as it goes through each loop it adds 10x the length of time for it to complete the function.

I've tried using the "select brush" and "drag from point to point" method for each dot but drawing pixels on the screen takes phenomenally long in live code and "select pencil" and "click at loc" takes even longer.

Anyway here is my stack. It makes a pretty ulam spiral of prime numbers
PrimeSpiral1.zip
(67.43 KiB) Downloaded 254 times

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Ulam Spiral Prime Numbers

Post by FourthWorld » Tue Oct 01, 2013 3:14 pm

nlexa wrote:I find that once I exceed around 380000 points that it forgets the first 380000 and continues drawing from there leaving a black square in the middle.
There's probably a limit on the number of points of some sort, but the first thing I'd check is the algo generating them.

One quick test is to add this line just before setting the points:

Code: Select all

put (cr&cr is in tList) -- NEW
set the points of graphic "Spiral" to tList
When a list of points contains a blank line, it will cause the resulting polygon to be discontiguous. Often this is very useful, but if it's not what you're looking for then you may need to review the script to find out why it's generating at least one blank line.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

nlexa
Posts: 26
Joined: Fri Aug 05, 2011 2:34 am

Re: Ulam Spiral Prime Numbers

Post by nlexa » Wed Oct 02, 2013 12:43 am

FourthWorld wrote:When a list of points contains a blank line, it will cause the resulting polygon to be discontiguous. Often this is very useful, but if it's not what you're looking for then you may need to review the script to find out why it's generating at least one blank line.
I checked it again. The variable can hold the points but it is the graphic object that cant hold much more than 65500 lines of coordinates. I guess a graphic object that has 32750 points is fairly complex.
Is there a way to increase this limit? Perhaps I simply have to split it across objects.

Post Reply