Post Reply 
Python: Mandelbrot explorer 0.9 now save and resume update Jan 23 /2022
01-23-2022, 10:52 PM
Post: #15
RE: Python: Mandelbrot explorer now interactive update 15.08.2021
Most of what's described in post#1 still applies.

While it's really fun to chew on my Mandelbrot Explorer, my major objective is to explore ways to almost seamlessly interface with the HOME environment. In this update special observation is dedicated to output of text in graphics.

major changes:

1. Solid Guess
2. More information on bottom line on current progress
3. Time out
4. Auto Save / Resume
5. using "TEXTOUT_P() from HOME without to much hassle

1. SOLID GUESS

Pass 1 calculates blocs of 4x4 pixels and assigns the color found for the top/left pixel to the entire bloc. then it checks its 3 right hand and lower neighbor blocs. Once they all have the same color this bloc is marked as completed. As the term "guess" indicates, this is not perfect but works pretty good specifically once you zoom in deeper and deeper. And it doesn't waist to much time in the "real" Mandelbrot set, The "blue sea".

Pass 1 and 2 fill those blocs which were not marked as completed. That could be done in one pass, but the "checker board" approach gives a nicer appearance.

But if you wish, there is a brute force approach with [Plot]. That takes its time specifically when large parts of the real Mandelbrot set are within the image. Try it yourself. Zoom in so that the entire screen is the "blue sea". The info screen should give an elapsed time of about 3.3 seconds( on a G2) press [Plot] and wait ... The info screen should give you an elapsed time of about 35 seconds. Quite a difference! Now try this with a depth of 300. Time t o get a coffee Smile

2. BOTTOM LINE

The extended possibilities of text output led me to redesign the bottom line. Just for fun. Once the image is finished you still can invoke it with pushing [B] or ([Mem] if that's easier to recall)

   

3. TIME OUT

As far as I've seen Python doesn't have a time out. Thus if you forgot that "Mandelbrot Explorer" is still running you could end up with a calculator completely out of power. This is now prevented from by taking care of the run time. The help screen, the info screen, and the manually invoked bottom info automatically time out after ~60 seconds. The major loop adds 0.2 seconds during each round, once 240 seconds are reached the program terminates. This may lead to some lag when touching the screen or pushing a button. Simply be more determined.

4. Auto SAVE / RESUME

When the program finishes, either by time out or [Esc] the current Image with its parameters (color, depth, zoomstack) is saved. Upon restart you resume where you left the last run. (Doesn't work) if you leave by pressing [On]

5. TEXTOUT_P()

The textout() function of the module hpprime is rather limited compared to the TEXTOUT_P() function of HOME. This adds optional font (size) selection, a max_width parameter and background color. As I have explained elsewhere the interface is rather cumbersome. In order to make life easier I've created a few function to serve this objective:

Code:


from hpprime import *

def string(arg):                #create a string understood by HOME environment
    return '"' + str(arg) +'"'
    
def RGB(r,g,b):                 #make RGB understood by HOME environment
    return (r*256+g)*256+b
    
def strip(arg):                 #strip parantheses from a tuple converted to string
    return str(arg)[1:-1]

def TxtOut(t,x,y,f,c,*args):    #provide an easy to handle interface to TEXTOUT_P in HOME
    if len(args)>2:             #Syntax: TxtOut(string,x,y,font,color[,max_width[,background color]]
       raise(SyntaxError("too many arguments"))
    if True in [isinstance(i,list) for i in t]:
       raise(TypeError("can't convert 'list' object to str implicitly"))
    parms=(int(x),int(y),int(f),int(c))
    if len(args)>0:parms+=(int(args[0]),) #add max_width
    if len(args)>1:parms+=(int(args[1]),) #add background color
    return eval('TEXTOUT_P('+string(t)+','+strip(parms)+')')

This function doesn't implement a choice of the graphic. It always writes to G0, and it doesn't know anything about "2D" functions. But I think it is valuable and easy to use.

Comments, suggestions


.zip  MandelExpl.hpappdir.zip (Size: 27.21 KB / Downloads: 44)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Python: Mandelbrot explorer now interactive update 15.08.2021 - Guenter Schink - 01-23-2022 10:52 PM



User(s) browsing this thread: 1 Guest(s)