Skip to content

Commit

Permalink
set always_use_return to false in formatter (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wikunia authored Jan 8, 2021
1 parent 1fe251c commit 88db409
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 26 deletions.
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ annotate_untyped_fields_with_any = false
always_for_in = true
whitespace_in_kwargs = true
whitespace_ops_in_indices = true
always_use_return = false
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Javis.jl - Changelog

## v0.4.0
- added ImageIO and ImageMagick as dependencies

## v0.3.4 (23rd of December 2020)
- Bugfix: `get_latex_svg` assumed a `LaTeXString` always includes `$$`
- changed color palette for gif rendering
Expand Down
8 changes: 4 additions & 4 deletions examples/follow_path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ using Javis, Animations

function ground(args...)
background("white")
return sethue("black")
sethue("black")
end

function circle_with_color(pos, radius, color)
sethue(color)
return circle(pos, radius, :fill)
circle(pos, radius, :fill)
end

# the safest option is to declare the Video first all the time
Expand Down Expand Up @@ -39,8 +39,8 @@ Background(1:220, ground)

# let the points appear one by one
objects = [
Object(frame_start:200, (args...) -> circle(O, 10, :fill), points[i])
for (frame_start, i) in zip(1:2:(2 * npoints), 1:npoints)
Object(frame_start:200, (args...) -> circle(O, 10, :fill), points[i]) for
(frame_start, i) in zip(1:2:(2 * npoints), 1:npoints)
]

# easiest to move canvas to draw at origin
Expand Down
8 changes: 4 additions & 4 deletions examples/fourier.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using TravelingSalesmanHeuristics

function ground(args...)
background("black")
return sethue("white")
sethue("white")
end

function circ(; r = 10, vec = O, action = :stroke, color = "white")
Expand Down Expand Up @@ -43,7 +43,7 @@ function draw_line(
sethue(color)
setdash(edge)
setline(linewidth)
return line(p1, p2, action)
line(p1, p2, action)
end

function draw_path!(path, pos, color)
Expand Down Expand Up @@ -89,8 +89,8 @@ function get_points(npoints, options)
portion = len / total_distance
nlocalpoints = floor(Int, portion * npoints)
new_points = [
Javis.get_polypoint_at(shape, i / (nlocalpoints - 1))
for i in 0:(nlocalpoints - 1)
Javis.get_polypoint_at(shape, i / (nlocalpoints - 1)) for
i in 0:(nlocalpoints - 1)
]
append!(points, new_points)
new_i = start_i + length(new_points) - 1
Expand Down
4 changes: 2 additions & 2 deletions examples/projection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ nframes = 200

function ground(args...)
background("white") # canvas background
return sethue("black") # pen color
sethue("black") # pen color
end

myvideo = Video(300, 300)
Expand All @@ -13,7 +13,7 @@ Background(1:200, ground)
function draw_line(p1 = O, p2 = O, color = "black", action = :stroke, edge = "solid")
sethue(color)
setdash(edge)
return line(p1, p2, action)
line(p1, p2, action)
end

# Draw the coordinate lines with solid in the positive side and dashed in the negative one
Expand Down
10 changes: 7 additions & 3 deletions src/Javis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ function preprocess_frames!(objects::Vector{<:AbstractObject})
end
frames = unique(frames)
if !(frames CURRENT_VIDEO[1].background_frames)
@warn("Some of the frames don't have a background. In this case: $(setdiff(frames, CURRENT_VIDEO[1].background_frames)))")
@warn(
"Some of the frames don't have a background. In this case: $(setdiff(frames, CURRENT_VIDEO[1].background_frames)))"
)
end

if isempty(CURRENT_OBJECT)
Expand Down Expand Up @@ -239,8 +241,10 @@ function render(
ffmpeg_exe(`-loglevel $(ffmpeg_loglevel) -i $(tempdirectory)/%10d.png -vf
palettegen $(tempdirectory)/palette.png`)
# then apply the palette to get better results
ffmpeg_exe(`-loglevel $(ffmpeg_loglevel) -framerate $framerate -i $(tempdirectory)/%10d.png -i
$(tempdirectory)/palette.png -lavfi paletteuse -y $pathname`)
ffmpeg_exe(
`-loglevel $(ffmpeg_loglevel) -framerate $framerate -i $(tempdirectory)/%10d.png -i
$(tempdirectory)/palette.png -lavfi paletteuse -y $pathname`,
)
elseif ext == ".mp4"
finishencode!(video_encoder, video_io)
close(video_io)
Expand Down
18 changes: 12 additions & 6 deletions src/Shape.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ function get_angles(p)
pB = p[1]
pC = p[2]
end
ang = rad2deg(acos(clamp(
dotproduct(u, v) / (sqrt(u.x^2 + u.y^2) * sqrt(v.x^2 + v.y^2)),
-1,
1,
)))
ang = rad2deg(
acos(
clamp(
dotproduct(u, v) / (sqrt(u.x^2 + u.y^2) * sqrt(v.x^2 + v.y^2)),
-1,
1,
),
),
)
if ang < 179.8
push!(simplified, pB)
end
Expand Down Expand Up @@ -210,7 +214,9 @@ end

function print_basic(s::Shape)
println("Shape: #Points: $(length(s.points))")
println("Angles: #Acute: $(s.num_acute_angles) #Obtuse: $(s.num_obtuse_angles) #Right: $(s.num_right_angles)")
println(
"Angles: #Acute: $(s.num_acute_angles) #Obtuse: $(s.num_obtuse_angles) #Right: $(s.num_right_angles)",
)
println("#Holes: $(length(s.subpaths))")
end

Expand Down
6 changes: 5 additions & 1 deletion src/structs/Frames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ function get_frames(parent, elem, frames::Symbol, last_frames::UnitRange; is_fir
end
return last_frames
else
throw(ArgumentError("Currently the only symbol supported for defining frames is `:same`"))
throw(
ArgumentError(
"Currently the only symbol supported for defining frames is `:same`",
),
)
end
end

Expand Down
10 changes: 6 additions & 4 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ function compute_frames!(
end
last_frames = get_frames(elem)
if !(get_frames(elem) available_subframes)
@warn("Action defined outside the frame range of the parent object.
Action #$counter for Object #$parent_counter is defined for frames
$(get_frames(elem)) but Object #$parent_counter exists only for $(available_subframes).
(Info: Background is counted as Object #1)")
@warn(
"Action defined outside the frame range of the parent object.
Action #$counter for Object #$parent_counter is defined for frames
$(get_frames(elem)) but Object #$parent_counter exists only for $(available_subframes).
(Info: Background is counted as Object #1)"
)
end
is_first = false
counter += 1
Expand Down
5 changes: 3 additions & 2 deletions test/svg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ end
video = Video(400, 200)
Background(1:1, latex_ground)
Object(
(args...) ->
latex(L"$\begin{equation}\left[\begin{array}{ccc}1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \\\end{array}\right]\end{equation}$"),
(args...) -> latex(
L"$\begin{equation}\left[\begin{array}{ccc}1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \\\end{array}\right]\end{equation}$",
),
)
render(video; tempdirectory = "images", pathname = "")
@test_reference "refs/latex_3x3_matrix.png" load("images/0000000001.png")
Expand Down

0 comments on commit 88db409

Please sign in to comment.