File:Barnsley fern 1024x1024.png

From testwiki
Jump to navigation Jump to search
    Original file (1,024 × 1,024 pixels, file size: 311 KB, MIME type: image/png)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: Barnsley Fern colour-toned for natural leaf appearance
    Date
    Source

    Own work

    I took the Turtle-Graphics based Python code from the Barnsley Fern's Wikipedia page and adapted it to use Python's "Tkinter" GUI library instead. (This has been included in Python's standard library since Python 3.7 so no external libraries are needed.) This gave a higher resolution image, allowed me to finesse the colour map, and save the image in PNG format. Python code is below, Python 3.7+ interpreter or Pypy 3.7+ JIT-compiler is required.
    Author Farry
    Permission
    (Reusing this file)
    Public domain (CC0 1.0)
    Other versions High resolution Barnsley fern created in Processing
    PNG development
    InfoField
     This PNG graphic was created with Python.

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
    The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

    Source code (python)

    import random
    import tkinter as tk
    width, height = 1024, 1024
    pixels = [0] * (width * height)
    
    x, y = 0, 1
    for n in range(60 * width * height):
    
        r = random.random() * 100
        xn, yn = x, y
        if r < 1:
            x = 0
            y = 0.16 * yn
        elif r < 86:
            x = 0.85 * xn + 0.04 * yn
            y = -0.04 * xn + 0.85 * yn + 1.6
        elif r < 93:
            x = 0.20 * xn - 0.26 * yn
            y = 0.23 * xn + 0.22 * yn + 1.6
        else:
            x = -0.15 * xn + 0.28 * yn
            y = 0.26 * xn + 0.24 * yn + 0.44
    
        x_pix = int(width * (0.45 + 0.195 * x))
        y_pix = int(height * (1 - 0.099 * y ))
        pixels[x_pix + y_pix * width] += 1
    
    greys = [ max(0, (256 - p) / 256) for p in pixels]
    colors = [int(c * 255) for g in greys for c in [g ** 6, g, g ** 6]]
    root = tk.Tk()
    p6header = bytes("P6\n{} {}\n255\n".format(width, height), "ascii")
    img = tk.PhotoImage(master=root, data=p6header + bytes(colors))
    tk.Label(root, image=img).pack()
    img.write("barnsley-fern.png", format='png')
    tk.mainloop()
    

    Captions

    Barnsley fern colour-toned for natural leaf appearance

    Items portrayed in this file

    depicts

    6 February 2021

    image/png

    9092b693f157cd8b40c585fe88d6e34c0d400e47

    318,295 byte

    1,024 pixel

    1,024 pixel

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current11:29, 6 February 2021Thumbnail for version as of 11:29, 6 February 20211,024 × 1,024 (311 KB)wikimediacommons>FarryUploaded own work with UploadWizard

    There are no pages that use this file.