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)
from fractal import Fractal f = Fractal() f.generate()
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")
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
# 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)