Last active
January 7, 2018 11:31
-
-
Save cormullion/8880c53bcb7766f50aca6c024ea845f8 to your computer and use it in GitHub Desktop.
Make StackOverflow ad for Julia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env julia | |
using Luxor, Colors | |
Drawing(600, 500, "/tmp/stackad.png") | |
origin() | |
background("white") | |
# background textifying, not for reading, fortunately | |
function background_text(str_array, fontsz, beginning::Point, ending::Point) | |
gsave() | |
sethue("grey75") | |
x = beginning.x | |
y = beginning.y | |
fontsize(fontsz) | |
counter=1 | |
while y < ending.y | |
s = str_array[counter] * " " | |
text(s, x, y) | |
counter = mod1(counter + 1, length(str_array)) | |
se = textextents(s) | |
x += se[5] # move to the right | |
if x > ending.x | |
x = beginning.x # next row | |
y += fontsz # no linespacing required | |
end | |
# fade text gradually as we descend | |
setopacity(rescale(y, (beginning.y, ending.y), (1.0, 0.0))) | |
end | |
grestore() | |
end | |
# packages are scraped from https://juliaobserver.com 2017-05-11 08:35:33 Top packages | |
top30packages = ["IJulia:", "Julia", "kernel", "and", "magics", "for", "Jupyter", "Gadfly:", "Crafty", "statistical", "graphics", "Mocha:", "Deep", "Learning", "framework", "for", "Julia", "DataFrames:", "library", "for", "working", "with", "tabular", "data", "DSGE:", "Solve", "and", "estimate", "Dynamic", "Stochastic", "General", "Equilibrium", "models", "JuMP:", "Modeling", "language", "for", "Mathematical", "Optimization", "PyCall:", "Package", "to", "call", "Python", "functions", "Cxx:", "The", "Julia", "C++", "Interface", "Escher:", "Composable", "Web", "UIs", "Plots:", "Powerful", "convenience", "visualizations", "and", "data", "analysis", "Distributions:", "probability", "distributions", "Optim:", "Optimization", "functions", "MXNet", "MXNet:", "flexible", "and", "efficient", "deep", "learning", "ParallelAccelerator:", "The", "ParallelAccelerator", "package", "part", "of", "the", "High", "Performance", "Scripting", "project", "at", "Intel", "Labs", "Knet:", "Koç", "University", "deep", "learning", "framework", "DifferentialEquations:", "suite", "for", "high-performance", "solvers", "of", "differential", "equations", "Convex:", "disciplined", "convex", "programming", "Interact:", "Interactive", "widgets", "Bio:", "Bioinformatics", "and", "Computational", "Biology", "Infrastructure", "Graphs:", "Working", "with", "graphs", "PyPlot:", "Plotting", "based", "on", "matplotlib.pyplot", "Images:", "An", "image", "library", "Lazy:", "Functional", "programming", "GLM:", "Generalized", "linear", "models", "QuantEcon:", "Julia", "implementation", "of", "QuantEcon", "routines", "Winston:", "2D", "plotting", "OpenCL:", "OpenCL", "bindings", "Klara:", "MCMC", "inference", "HDF5:", "Saving", "and", "loading", "data", "in", "the", "HDF5", "file", "format"] | |
background_text(top30packages, 18, Point(-295, -235), Point(295, 160)) | |
# julia logo (of course) | |
gsave() | |
scale(1.2, 1.2) | |
translate(Point(-170, -190)) | |
julialogo() | |
grestore() | |
# slogans | |
sethue("darkslateblue") | |
box(Point(0, 120), 600, 100, :fill) | |
sethue("white") | |
fontsize(26) | |
fontface("GothamBold") | |
text("modern, fast, and open source", 0, 112, halign=:center) | |
fontsize(19) | |
text("for data science and technical computing", Point(0, 145), halign=:center) | |
# github logo file GitHub-Mark-32px.png will need to be downloaded from | |
# https://github.com/logos | |
githublogo = readpng("GitHub-Mark-32px.png") | |
sethue("black") | |
fontsize(28) | |
text("Contribute on Github", Point(-10, 220), halign=:center) | |
placeimage(githublogo, Point(150, 195)) | |
# don't forget that 2 pixel black border | |
sethue("black") | |
setline(4) # ! aargh, at this low res, we've got pixel antialiasing problems... | |
box(O, 600, 500, :stroke) | |
finish() | |
preview() |
Author
cormullion
commented
Jan 27, 2017
•
using Luxor, Colors
Drawing(600, 500, "/tmp/stackad.png")
origin()
background("white")
# background textifying, not for reading, fortunately
function background_text(str_array, fontsz, beginning::Point, ending::Point)
@layer begin
sethue("grey65")
fadeline(linenumber, linetext, startpos, height) = begin
setopacity(rescale(startpos.y, beginning.y, ending.y, 1.0, 0.4))
# I forgot a leading option for textwrap... :(
translate(0, -10)
end
fontsize(fontsz)
textwrap(join(vcat(str_array, str_array), " "), 650,
beginning - (0, fontsz), fadeline)
end
end
# packages are scraped from https://juliaobserver.com 2017-01-27 16:10:13 Top packages
top30packages = ["IJulia:", "Julia", "kernel", "and", "magics", "for", "Jupyter", "Gadfly:", "Crafty", "statistical", "graphics", "Mocha:", "Deep", "Learning", "framework", "for", "Julia", "DataFrames:", "library", "for", "working", "with", "tabular", "data", "DSGE:", "Solve", "and", "estimate", "Dynamic", "Stochastic", "General", "Equilibrium", "models", "JuMP:", "Modeling", "language", "for", "Mathematical", "Optimization", "PyCall:", "Package", "to", "call", "Python", "functions", "Cxx:", "The", "Julia", "C++", "Interface", "Escher:", "Composable", "Web", "UIs", "Plots:", "Powerful", "convenience", "visualizations", "and", "data", "analysis", "Distributions:", "probability", "distributions", "Optim:", "Optimization", "functions", "MXNet", "MXNet:", "flexible", "and", "efficient", "deep", "learning", "ParallelAccelerator:", "The", "ParallelAccelerator", "package", "part", "of", "the", "High", "Performance", "Scripting", "project", "at", "Intel", "Labs", "Knet:", "Koç", "University", "deep", "learning", "framework", "DifferentialEquations:", "suite", "for", "high-performance", "solvers", "of", "differential", "equations", "Convex:", "disciplined", "convex", "programming", "Interact:", "Interactive", "widgets", "Bio:", "Bioinformatics", "and", "Computational", "Biology", "Infrastructure", "Graphs:", "Working", "with", "graphs", "PyPlot:", "Plotting", "based", "on", "matplotlib.pyplot", "Images:", "An", "image", "library", "Lazy:", "Functional", "programming", "GLM:", "Generalized", "linear", "models", "QuantEcon:", "Julia", "implementation", "of", "QuantEcon", "routines", "Winston:", "2D", "plotting", "OpenCL:", "OpenCL", "bindings", "Klara:", "MCMC", "inference", "HDF5:", "Saving", "and", "loading", "data", "in", "the", "HDF5", "file", "format"]
background_text(top30packages, 20, Point(-295, -235), Point(295, 160))
# julia logo (of course)
gsave()
scale(1.2, 1.2)
translate(Point(-170, -190))
julialogo()
grestore()
# slogans
sethue("darkslateblue")
box(Point(0, 120), 600, 100, :fill)
sethue("white")
fontsize(25)
fontface("GothamBold")
text("modern, fast, and open source", 0, 110, halign=:center)
fontsize(18)
text("for data science and technical computing", Point(0, 142), halign=:center)
# github logo file GitHub-Mark-32px.png will need to be downloaded from
# https://github.com/logos
githublogo = readpng("GitHub-Mark-32px.png")
sethue("black")
fontsize(28)
text("Contribute on Github", Point(-10, 220), halign=:center)
placeimage(githublogo, Point(150, 195))
# don't forget that 2 pixel black border
sethue("black")
setline(4) # ! aargh, at this low res, we've got pixel antialiasing problems...
box(O, 600, 500, :stroke)
finish()
preview()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment