Skip to content

Instantly share code, notes, and snippets.

View adrhill's full-sized avatar
🌱

Adrian Hill adrhill

🌱
View GitHub Profile
@adrhill
adrhill / img2ppm.jl
Created September 9, 2022 15:04
Convert image to PPM
using Images, TestImages
img = testimage("cameraman")
img = convert.(RGB{N0f8}, img)
open("cameraman.ppm", "w+") do io
println(io, "P6")
println(io, size(img, 2), " ", size(img, 1))
println(io, 255)
@adrhill
adrhill / cameraman.ppm
Created September 9, 2022 14:59
Cameraman test image in PPM P6 format
This file has been truncated, but you can view the full file.
P6
512 512
255
œœœ   ŸŸŸžžžœœœ›››œœœžžžœœœŸŸŸžžžžžžœœœžžžžžžŸŸŸŸŸŸ               žžžžžž   £££¢¢¢¢¢¢¢¢¢¢¢¢      ¡¡¡£££¡¡¡   ¢¢¢¦¦¦¤¤¤£££¡¡¡¡¡¡¢¢¢£££¡¡¡¡¡¡¢¢¢¤¤¤¥¥¥¦¦¦¤¤¤¢¢¢      ¢¢¢¥¥¥¥¥¥¥¥¥¤¤¤¥¥¥¥¥¥§§§¦¦¦¤¤¤£££¤¤¤¤¤¤¥¥¥¦¦¦§§§¦¦¦¥¥¥¥¥¥¥¥¥££££££¦¦¦ªªª¨¨¨¦¦¦¦¦¦§§§¦¦¦§§§¨¨¨ªªª©©©¨¨¨¨¨¨©©©§§§¦¦¦§§§©©©¨¨¨¦¦¦§§§ªªª©©©©©©¨¨¨©©©ªªª«««ªªª©©©ªªª¬¬¬ªªª©©©ªªª«««ªªª©©©¨¨¨©©©«««­­­­­­®®®®®®­­­«««««««««­­­®®®°°°¯¯¯®®®®®®°°°²²²´´´³³³³³³²²²²²²±±±²²²³³³¶¶¶µµµµµµµµµµµµ²²²°°°²²²¶¶¶³³³²²²²²²³³³³³³´´´´´´´´´´´´´´´²²²±±±µµµ¸¸¸¶¶¶µµµµµµ¶¶¶¶¶¶···¶¶¶¶¶¶¶¶¶···¶¶¶¶¶¶µµµ¶¶¶¶¶¶···¶¶¶¶¶¶···¹¹¹¸¸¸···µµµµµµ´´´µµµµµµ···¸¸¸¹¹¹·········¸¸¸·········¹¹¹¹¹¹ºººººº»»»¹¹¹¸¸¸¶¶¶¶¶¶¶¶¶¸¸¸¸¸¸ººº¹¹¹¹¹¹···¶¶¶¶¶¶···¸¸¸»»»¹¹¹¶¶¶¶¶¶¸¸¸¹¹¹»»»ººº¹¹¹ººº¼¼¼ººº¹¹¹¸¸¸¹¹¹ººº»»»¹¹¹¸¸¸···¸¸¸µµµµµµ···ººººººººººººººº¶¶¶´´´···»»»¹¹¹¶¶¶µµµµµµ···¹¹¹¸¸¸···µµµ³³³³³³µµµµµµ¶¶¶µµµµµµ···¹¹¹···¶¶¶¸¸¸ººº¸¸¸¶¶¶µµµµµµ¶¶¶···¶¶¶¶¶¶µµµµµµµµµ¶¶¶µµµ´´´³³³³³³´´´¶¶¶³³³±±±²²²´´´´´´µµµ³³³²²²±±±²²²³³³´´´³³³³³³³³³´´´²²²±±±±±±²²²³³³µµµ´´´²²²°°°°°°±±±²²²¯¯¯®®®¯¯¯±±±²²²²²²¯¯¯­
@adrhill
adrhill / Mandelbrot_zoom_color.jl
Last active June 11, 2021 15:13
Mandelbrot set in terminal
# ]add https://github.com/IanButterworth/VideoInTerminal.jl
# ]add ImageCore
# ]add ColorSchemes
using VideoInTerminal
using ImageCore
using ColorSchemes
"""
Count number of Mandelbrot iterations until `threshold` is crossed,
up to a maximum of `maxits`.
@adrhill
adrhill / mandelbrot_zoom.jl
Last active May 21, 2021 15:28
Zoom in on the Mandelbrot set from the comfort of your terminal!
# ]add https://github.com/IanButterworth/VideoInTerminal.jl
# ]add ImageCore
using VideoInTerminal
using ImageCore
"""
Run n Mandelbrot iterations.
"""
function mb_iterations(c::AbstractArray{T}; n=50) where {T<:Complex}
z = zeros(T, size(c))