Пример #1
0
 def render(self):
     Fractal.render(self)
     if not self.samples:
         self.set_samples(int(0.5 * self.w * self.h))
     for _ in xrange(self.samples):
         c = self.sample_point()
         n, path = self.in_mandelbrot(c)
         if n > self.min_path:
             self.draw_trajectory(path)
Пример #2
0
 def __init__(self, args = {}):
     default_vars = {"times": 10, "size": 1, "angle": 15, "z": 0, "zimp": 0, "w": 0, "wimp": 0, "value": 10, "color": "#000000"}
     self.variables = self.Define_Vars(args, default_vars)
     Fractal.__init__(self, [[0], [0]], [[0], [self.variables["size"]]])
     self.variables["theta"] = (self.variables["angle"] * math.pi) / 180
     self.variables["angle"] = [self.variables["theta"], -self.variables["theta"]]
     self.variables["z"] = 1 - self.variables["z"] / 100 + self.variables["z"] / 50
     self.variables["w"] = 1 - self.variables["w"] / 100 + self.variables["w"] / 50
     self.new_xx, self.new_yy = [], []
     self.property_x, self.property_y = [], []
Пример #3
0
 def __init__(self, x=[0, 0.5, -0.5], y=[3**0.5 / 2, 0, 0], args={}):
     Fractal.__init__(self, x, y)
     default_vars = {
         "times": 100000,
         "divader": 2,
         "color": "#000000",
         "value": 10
     }
     self.variables = self.Define_Vars(args, default_vars)
     self.property_x, self.property_y = [], []
Пример #4
0
 def __init__(self, args={}):
     Fractal.__init__(self, [], [])
     default_vars = {
         "color": "#000000",
         "depth": 500,
         "initiator": 0,
         "resolution": 40,
         "limit": 2,
         "reach": 50
     }
     self.variables = self.Define_Vars(args, default_vars)
Пример #5
0
 def __init__(self, args={}):
     Fractal.__init__(self, [], [])
     default_vars = {
         "depth": 1000,
         "real_numbers": 2,
         "imaginary_numbers": 2,
         "density": 200,
         "amount_of_colors": 12,
         "value": 10
     }
     self.variables = self.Define_Vars(args, default_vars)
Пример #6
0
 def __init__(self, args={}):
     default_vars = {
         "times": 5,
         "amount_of_sides": 3,
         "size": 1,
         "color": "#000000",
         "value": 10
     }
     self.variables = self.Define_Vars(args, default_vars)
     Fractal.__init__(self, [0, self.variables["size"]], [0, 0])
     self.property_x, self.property_y = [], []
Пример #7
0
 def __init__(self, args={}):
     default_vars = {
         "times": 10,
         "scale": 1,
         "color": "#000000",
         "value": 10
     }
     self.variables = self.Define_Vars(args, default_vars)
     Fractal.__init__(self, [[0, self.variables["scale"]]], [[0, 0]])
     self.iteration_number = 0
     self.property_x, self.property_y = [], []
     self.passing = self.variables["scale"] / self.variables["value"]
Пример #8
0
 def __init__(self,
              w=512,
              h=512,
              real_bounds=(-2.0, 1.0),
              imag_bounds=(-1.5, 1.5),
              iterations=512):
     Fractal.__init__(self, w, h)
     self.rb = real_bounds
     self.ib = imag_bounds
     self.threshold = abs(
         max(real_bounds + imag_bounds, key=lambda x: abs(x)))
     self.iterations = iterations
Пример #9
0
 def __init__(self, args={}):
     default_vars = {
         "times": 5,
         "scale": 1,
         "color": "#000000",
         "value": 10
     }
     self.variables = self.Define_Vars(args, default_vars)
     x = [0, 0, self.variables["scale"], self.variables["scale"]]
     y = [self.variables["scale"], 0, 0, self.variables["scale"]]
     Fractal.__init__(self, x, y)
     self.iteration_number = 0
     self.property_x, self.property_y = [], []
Пример #10
0
 def render(self):
     """ Renders the mandelbrot set on pixel_mat
     >>> m = Mandelbrot()
     >>> m.render()
     """
     Fractal.render(self)
     lutx = [
         j * (self.rb[1] - self.rb[0]) / (self.w - 1) + self.rb[0]
         for j in xrange(self.w)
     ]
     for y in xrange(self.h):
         cy = y * (self.ib[1] - self.ib[0]) / (self.h - 1) + self.ib[0]
         for x in xrange(self.w):
             c = complex(lutx[x], cy)
             iters = self.in_mandelbrot(0, c)
             if iters > 0:
                 self.set_point(x, y, iters)
Пример #11
0
 def __renderCallback(self, factory, *args):
     self.__dataChangedCallback()
     if not self.fractal_data.isValid():
         return
     fractal = Fractal(self.fractal_data.getExpression(),
                       self.fractal_data.getRadius(),
                       self.fractal_data.getIterations())
     self.rendererManager.renderFractal(factory, fractal)
Пример #12
0
def gen_fractal(run_count, dry_fire, point_count, scaling_factor, selection_limiter, save):
    mat_points = Fractal(run_count=run_count, dry_fire=dry_fire, point_count=point_count,
                         scaling_factor=scaling_factor, selection_limiter=selection_limiter).execute()
    img = mat_to_color(point_to_image_mat(mat_points))
    if save:
        io.imsave(save, img)
    else:
        plt.imshow(img)
        plt.show()
    """
Пример #13
0
    def __generate_movie(self, fractal_params):
        """
        Inner class to generate movie quickly. Users should not run this.
        This class calls the required function to generate a fractal
        :param fractal_params: Initial params for Fractal class
        :return: Generator of matrices to be produced frame-by-frame
        """
        # Separate Fractal class params here
        params = deepcopy(fractal_params)
        while True:

            fractal = Fractal(**params)
            yield fractal
Пример #14
0
    def __init__(self, attr, context_name, value_function, attr_names,
                 background_image, index):
        self.index = index
        self.attr = attr
        self.attr_names = attr_names
        self.name = '%s-%0.3d' % (context_name, index)
        self.image_file = './images/items/%s.png' % (self.name)
        self.value = value_function(np.array(list(attr) + [1.0]))
        self.marginal_value = (value_function(np.array([attr[0], 0.0, 1.0])),
                               value_function(np.array([0.0, attr[1], 1.0])))

        background = cv2.imread(background_image)
        background = 255 * (background < 100).astype('uint8')

        if not os.path.exists(self.image_file):

            f = Fractal()
            f.generate(self.image_file,
                       width=background.shape[0],
                       height=background.shape[1])
            myimage = cv2.imread(self.image_file)
            myimage = cv2.bitwise_and(background, myimage)
            myimage[background == 0] = 130
            cv2.imwrite(self.image_file, myimage)
def main_interactive():
    global frac
    frac = Fractal()
    frac.nx = 256
    frac.ny = 256
    frac.compute()
    C = frac.get_color_array()
    dpi = 100
    fig=plt.figure(figsize=(frac.nx/dpi, frac.ny/dpi), dpi=dpi, facecolor='w', edgecolor='k')
    ax = fig.add_subplot(111)
    img = plt.imshow(C,interpolation='nearest')
    plt.axis('off')
    global coords
    coords = []

    cid1 = fig.canvas.mpl_connect('button_press_event', button_press)
    cid2 = fig.canvas.mpl_connect('button_release_event', lambda event: button_release(event,img))
        
    plt.show()
Пример #16
0
from fractal import Fractal 

f = Fractal()
f.generate()
Пример #17
0
import pyimgur, tweepy, sys, pymysql
from datetime import date
from imgur import Imgur
from database import Database
from twitter import Twitter
from fractal import Fractal

# Generate the Fractal of the Day
fract = Fractal()
fract.generate(fotd=True)

# Upload
im = Imgur()
image = im.api.upload_image("fotd.png",
                            title="Fractal of the day (1080p) - " +
                            str(date.today()))
print(image.title)
print(image.link)
print(image.size)
print(image.type)
print "deletion link: imgur.com/delete/" + str(image._delete_or_id_hash)

if image.link == "":
    print("no link")
    sys.exit(0)

# Log the Fractal of the Day
db = Database()
db.log_fotd(image.link, image._delete_or_id_hash, image.size)

# Tweet
Пример #18
0
# If on linux, be sure to do:
#   sudo apt-get install python3-tk
# https://stackoverflow.com/questions/56656777/userwarning-matplotlib-is-currently-using-agg-which-is-a-non-gui-backend-so

from fractal import Fractal

dim = (1080, 1920)  # resolucion de la imagen

frac = Fractal('mandelbrot', 100, dim, -3.3, 1.9, -1.5, 1.5)

# el intento mamalon (8 horas)
#frac = Fractal('mandelbrot', 8000, dim, -3.3 + 0.693333, 1.9 - 0.693333, -1.1, 1.1)

# un julia set bien chido (pero no tan mamalon como el mandelbrot anterior)
#frac = Fractal('julia', 8000, dim, -3.3 + 0.693333, 1.9 - 0.693333, -1.1, 1.1)

frac.generate()  # genera el fractal
frac.show_fractal()  # muestra el fractal en una ventana
frac.save_fractal(
    'fractal', 'png'
)  # guarda el fractal con el nombre y tipo de imagen dados (si no se da el tipo se guarda en png automaticamente)
Пример #19
0
        self.addMargin()
        self.addToSource("x = iteration(x);")
        self.addBreakCondition()
        self.addMargin()
        self.addToSource("result = i;")
        self.addToSource("break;")
        self.removeMargin()
        self.addToSource("}")
        self.removeMargin()
        self.addToSource("}")
        self.addToSource("if(result < 0) {")
        self.addMargin()
        self.addToSource("gl_FragColor = inColor;")
        self.removeMargin()
        self.addToSource("}else{")
        self.addMargin()
        self.addToSource("gl_FragColor = outColor;")
        self.removeMargin()
        self.addToSource("}")
        self.removeMargin()
        self.addToSource("}")


if __name__ == "__main__":
    from expression_processor import DefaultExpressionProcessor
    proc = DefaultExpressionProcessor()
    fract = Fractal(proc.getParsedExpression("x * x + pos"), 2.0, 100.0)
    gen = GLFractalSourceGenerator()
    gen.generateSource(fract)
    gen.printSource()
Пример #20
0
from fractal import Fractal


####################### Window stuff ###################
def redraw(xOffset, yOffset, zoom):
    newImg = ImageTk.PhotoImage(fractal.genFractImg())
    pic.configure(image=newImg)
    pic.image = newImg


# create window for image
windw = tk.Tk()
#windw.geometry("400x300");
#fractal = Fractal(400, 300, 100, 2);
windw.geometry("400x300")
fractal = Fractal(400, 300, 100, 2)

#separate window into image and controls frames
fract = tk.Frame(windw)
fract.pack(side="top")

cont = tk.Frame(windw)
cont.pack(side="bottom")

# place image in window
img = ImageTk.PhotoImage(fractal.returnImg())
pic = tk.Label(windw, image=img)
pic.pack(side="left", fill="both", expand="yes")

#Controls
cLabel = tk.Label(cont,
Пример #21
0
    iPACFDiag = statObj.getDiagACF()

    iBox = statObj.getDiagnosticLjungBox(20)
    iMeanDiag = statObj.getMeanDiagnostic()

    print("mean: {} Var: {} Skewness: {} Kurt: {}".format(iArrMean,iArrVar,iArrSkewness,iArrKurt))
    print(iBox)
    
    plt.axhline(iPACFDiag[0], c="red")
    plt.axhline(iPACFDiag[1], c="red")
    plt.axhline(iMeanDiag, c = "blue")
    plt.axhline(-iMeanDiag, c = "blue")
    #plt.axhline(iArrMean, c = "green")
    '''
    #fra = Fractal(iArr[-20:])
    fra = Fractal(iArr)
    print(len(iArr))
    sample = [3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
    #sample = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
    #sample = [3, 4, 5]

    #sample = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 21, 23, 28, 36, 50, 70, 90]
    #sample = [3,20]
    #iHArrX = math.log10(sample)
    initCtr = True
    iAxisLen = 0

    #dimArrayX = np.array((len(sample),2))
    #dimArrayY = np.array((len(sample),1))
    dimArrayX = []
    dimArrayY = []
Пример #22
0
 def __init__(self, x=[], y=[], args={}):
     Fractal.__init__(self, x, y)
     self.Create_Vars(args)
Пример #23
0
 def __init__(self, x=[[0, 1]], y=[[0, 0]], args={}):
     Fractal.__init__(self, x, y)
     default_vars = {"times": 8, "color": "#000000", "value": 10}
     self.variables = self.Define_Vars(args, default_vars)
     self.property_x, self.property_y = [], []
Пример #24
0
    json_data = json.loads(data)
    send_fractal(json_data)
    return True
  def on_error(self, status):
    log("Error!")
    log(status)
    db._disconnect()
    sys.exit()
  def on_timeout(self):
    log("Timed out")
    return True
  def on_disconnect(self, notice):
    log("disconnected")
    log(str(notice))
    return

# Start Fractal generator
fractal = Fractal()

# Start database
db = Database()

# Start Twitter
twitter = Twitter()
stream = Stream(twitter.auth, Listener())

# Start reading stream
log("reading mentions")
stream.filter(track=["fractal_bot"])
log("script stopped running")
Пример #25
0
 def __init__(self, args = {}):
     Fractal.__init__(self, [], [])
     default_vars = {"end": 18, "color": "#000000", "value": 10}
     self.variables = self.Define_Vars(args, default_vars)
     self.initiator = 0
     self.property_x, self.property_y = [], []
Пример #26
0
import pyimgur, tweepy, sys, pymysql
from datetime import date
from imgur import Imgur
from database import Database
from twitter import Twitter
from fractal import Fractal

# Generate the Fractal of the Day
fract = Fractal()
fract.generate(fotd=True)

# Upload
im = Imgur()
image = im.api.upload_image("fotd.png", title="Fractal of the day (1080p) - " + str(date.today()))
print(image.title)
print(image.link)
print(image.size)
print(image.type)
print "deletion link: imgur.com/delete/" + str(image._delete_or_id_hash)

if image.link == "":
  print("no link")
  sys.exit(0)

# Log the Fractal of the Day
db = Database()
db.log_fotd(image.link, image._delete_or_id_hash, image.size)

# Tweet
twitter = Twitter()
twitter.api.update_with_media("fotd.png", "Fractal of the day " + str(image.link) + " #fractal")
    def __kill(self):
        self.drawFlag = False
        if (self.drawThread.daemon):
            self.drawThread.join()
        try:
            self.setting.window.destroy()
        except Exception:
            pass

        try:
            self.win.window.destroy()
        except Exception:
            pass

    def destroy(self, *args):
        thread = Thread()
        thread.run = self.__kill
        thread.start()
        self.killThread = thread


if __name__ == '__main__':
    proc = DefaultExpressionProcessor()
    fractal = Fractal(proc.getParsedExpression("x * x * x + pos + time"), 2.0,
                      100)
    root = tk.Tk()
    renderer = PyFractalRenderer(root, fractal)
    renderer.runDrawThread()
    root.mainloop()
Пример #28
0
"""Displays output from the fractal module within a notebook or hydrogen using jupyter."""

import IPython.display
from fractal import Fractal


def display(f):
    """Render and displays the fractal into jupyter (ipython) for jupyter notebooks or hydrogen."""
    buf = io.BytesIO()
    f.render().save(buf, 'PNG')
    img = IPython.display.Image(data=buf.getvalue())
    IPython.display.display(img)


f = Fractal()
display(f)