Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Pinstripe-Printer/Julia/pinstripe-printer.julia
Normal file
26
Task/Pinstripe-Printer/Julia/pinstripe-printer.julia
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using FileIO, ImageIO
|
||||
|
||||
function getnumberwithprompt(prompt, t::Type)
|
||||
s = ""
|
||||
while (x = tryparse(t, s)) == nothing
|
||||
print("\n", prompt, ": -> ")
|
||||
s = strip(readline())
|
||||
end
|
||||
return x
|
||||
end
|
||||
|
||||
dpi = getnumberwithprompt("Printer DPI (dots per inch)", Int)
|
||||
pwidth = getnumberwithprompt("Printer width (inches)", Float64)
|
||||
plength = 10.0
|
||||
|
||||
imgwidth, imgheight = Int(round(pwidth * dpi)), Int(round(plength * dpi))
|
||||
|
||||
img = zeros(UInt8, Int(round(imgheight)), Int(round(imgwidth)))
|
||||
|
||||
for row in 1:imgheight, col in 1:imgwidth
|
||||
stripewidth = div(row, dpi) + 1
|
||||
img[row, col] = rem(col, stripewidth * 2) < stripewidth ? 0 : 255
|
||||
end
|
||||
|
||||
save("temp.png", img)
|
||||
run(`print temp.png`) # the run statement may need to be set up for the installed device
|
||||
Loading…
Add table
Add a link
Reference in a new issue