Skip to content

Commit

Permalink
updated so that it is standallone
Browse files Browse the repository at this point in the history
  • Loading branch information
huckl3b3rry87 committed Mar 26, 2017
1 parent effd5a1 commit 3648cc3
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 17 deletions.
Binary file added Batman.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions plot.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Plots
gr(leg = false, grid = false, xticks = nothing, yticks = nothing, size=(500,500))

function make_batman()
p = P2[(0,0), (0.5, 0.2), (1, 0), (1,2), (0.3,1.2), (0.2,2), (0,1.7)]
m = P2[(p[i]+p[i+1])/2 for i=1:length(p)-1]
m += P2[(0.2, 1), (0.4, 1), (2, 0), (0.5, -0.6), (0,0), (0,-0.15)]

pts = P2[]
for (i,mi) in enumerate(m)
append!(pts, curve_points(BezierCurve(P2[p[i], m[i], p[i+1]])))
end
x, y = Plots.unzip(pts)
Shape(vcat(x, -reverse(x)), vcat(y, reverse(y)))
end
plot(make_batman())

# background and limits
plt = plot(bg = :black, xlim = (0.1,0.9), ylim = (0.2,1.5))

# create an ellipse in the sky
pts = Plots.partialcircle(0,2π,100,0.1)
x, y = Plots.unzip(pts)
x = 1.5x + 0.7
y += 1.3
pts = collect(zip(x, y))

# beam
beam = Shape([(0.3, 0.0), pts[95], pts[50]])
plot!(beam, m=(:yellow,0.3))

# spotlight
plot!(Shape(x,y), c=:yellow)

# buildings
rect(w, h, x, y) = Shape(x + [0,w,w,0], y + [0,0,h,h])
gray(pct) = RGB(pct,pct,pct)
function windowrange(dim, denom)
linspace(0, 1, max(3, round(Int, dim/denom)))[2:end-1]
end

for k=1:50
w, h, x, y = 0.1rand()+0.05, 0.8rand()+0.3, rand(), 0.0
shape = rect(w, h, x, y)
graypct = 0.3rand()+0.3
plot!(shape, c = gray(graypct))

# windows
I = windowrange(w,0.015)
J = windowrange(h,0.04)
pts = vec([(Float64(x+w*i), Float64(y+h*j)) for i=I,j=J])
windowcolors = Symbol[rand()<0.2 ? :yellow : :black for i=1:length(pts)]
scatter!(pts, marker = (stroke(0), :rect, windowcolors))
end
plt

# Holy plotting, Batman!
batman = scale(make_batman(), 0.07, 0.07, (0,0))
batman = translate(batman, 0.7, 1.23)
plot!(batman, marker = (:black, stroke(0)), size=(500,500))

png("Batman.png")
16 changes: 0 additions & 16 deletions src/NLOptControl_plots.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
"""
resultsDir(results_dir)
# removes results folder and creates a new one
--------------------------------------------------------------------------------------\n
Author: Huckleberry Febbo, Graduate Student, University of Michigan
Date Create: 2/10/2017, Last Modified: 2/17/2017 \n
--------------------------------------------------------------------------------------\n
"""
function resultsDir(results_dir::String)
if isdir(results_dir)
rm(results_dir; recursive=true)
print("\n The old results have all been deleted! \n \n")
end
mkdir(results_dir)
cd(results_dir)
end

"""
Expand Down
2 changes: 1 addition & 1 deletion src/PrettyPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include("NLOptControl_plots.jl")

export
# basic functions
resultsDir, adjust_axis,
adjust_axis,

# NLOptControl.jl plots
statePlot, controlPlot, allPlots
Expand Down

0 comments on commit 3648cc3

Please sign in to comment.