Skip to content

Commit

Permalink
deleted: Manifest.toml
Browse files Browse the repository at this point in the history
modified:   Project.toml               0.5.0
modified:   README.md                  Status, todo
modified:   examples/pluto_1.jl        empty_figure syntax
modified:   src/MechanicalSketch.jl    import snapshot
modified:   src/autodiff_unitfu.jl     Docstring
modified:   src/labels.jl              Drop fixed color, use active color
modified:   src/latex.jl               Prepare_latexify, drop some postprocessing,
                                       draw_expr, draw_single_expr, guard_latexify
new file:   src/macros.jl              @ev_draw, @eq_draw, draw_init,
                                       assertions, place_msg!, place_eqs!
modified:   src/matrix_interpolation.jl Duck typing matrix_to_function
modified:   src/place_image.jl         Docstring
modified:   test/Manifest.toml
modified:   test/Project.toml          Add ChainRules (temporary)
modified:   test/test_1.jl        empty_figure syntax
modified:   test/test_10.jl        empty_figure syntax
modified:   test/test_11.jl        empty_figure syntax
modified:   test/test_12.jl        empty_figure syntax
modified:   test/test_13.jl        empty_figure syntax
modified:   test/test_14.jl        empty_figure syntax
modified:   test/test_15.jl        empty_figure syntax
modified:   test/test_16.jl        empty_figure syntax
modified:   test/test_17.jl        empty_figure syntax, unit array conversion
modified:   test/test_18.jl        empty_figure syntax, unit array conversion
modified:   test/test_19.jl        empty_figure syntax
modified:   test/test_2.jl         empty_figure  syntax
modified:   test/test_20.jl        empty_figure, @import_expand syntax
modified:   test/test_21.jl        empty_figure, @import_expand syntax
modified:   test/test_22.jl        empty_figure, @import_expand syntax
modified:   test/test_23.jl        empty_figure, @import_expand syntax
modified:   test/test_25.png
modified:   test/test_26.jl
modified:   test/test_26.png
modified:   test/test_27.jl        empty_figure, @import_expand syntax
modified:   test/test_27.png
modified:   test/test_28.jl        empty_figure, @import_expand syntax
modified:   test/test_29.jl        empty_figure, @import_expand syntax
modified:   test/test_3.jl        empty_figure, @import_expand syntax
modified:   test/test_3.png
modified:   test/test_30.jl        empty_figure, @import_expand syntax
modified:   test/test_30.png        empty_figure, @import_expand syntax
modified:   test/test_31.jl        empty_figure, @import_expand syntax
modified:   test/test_31.png
modified:   test/test_32.jl        empty_figure, @import_expand syntax
modified:   test/test_33.jl        empty_figure, @import_expand syntax
modified:   test/test_33.png       @import_expand syntax
modified:   test/test_34.jl        empty_figure, @import_expand syntax
modified:   test/test_35.jl        empty_figure, @import_expand syntax
modified:   test/test_36.jl        empty_figure, @import_expand syntax
modified:   test/test_36.png
modified:   test/test_37.jl        Could now use MechGluePlots, not fully impl.
modified:   test/test_37.png
modified:   test/test_38.jl        empty_figure, @import_expand, use macros
modified:   test/test_38.png
modified:   test/test_39.jl        empty_figure, @import_expand syntax
modified:   test/test_4.jl         empty_figure syntax
modified:   test/test_4.png
new file:   test/test_40.jl        macros, unfinished
new file:   test/test_40.png
new file:   test/test_41.jl        test snapshot development
new file:   test/test_41.png
modified:   test/test_5.jl
modified:   test/test_6.jl
modified:   test/test_7.jl
modified:   test/test_8.jl
modified:   test/test_9.jl
modified:   test/test_functions_24.jl
modified:   test/test_functions_25.jl
modified:   test/test_functions_37.jl
new file:   test/test_functions_40.jl
  • Loading branch information
hustf committed May 8, 2021
1 parent adf9582 commit e65a228
Show file tree
Hide file tree
Showing 69 changed files with 1,011 additions and 1,203 deletions.
863 changes: 0 additions & 863 deletions Manifest.toml

This file was deleted.

4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MechanicalSketch"
uuid = "183f2c95-4b91-4df3-9bd2-197e8f9edb13"
authors = ["hustf <[email protected]> and contributors"]
version = "0.4.1"
version = "0.5.0"

[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Expand All @@ -18,9 +18,11 @@ LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
MechGluecode = "3017d99d-ab52-4519-99a2-fa9ddc4637fe"
MechanicalUnits = "e6be9192-89dc-11e9-36e6-5dbcb28f419e"
NodeJS = "2bd173c7-0d6d-553b-b6af-13a54713934c"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ There's no intention to make this very general, rather to add functionality as t

Sketches should look good and be in a consistent pallette. The test images are in .png format, but .svg is better for zooming. For post-editing figures, not all svg editors handle fonts. 'Inkscape' seems to work well. You might need to install additional fonts for some test images.

# Status
The current release is somewhat forced. Newly introduced functions could simplify the tests / examples, but this has not been fully implemented.

Also, Luxor has introduced some new functions which are not imported here.

Some functionality may be covered both here and in 'MechGluecode'.

We have not picked an interface. Nothing is as of yet exported.

TODO:
- Drop unnecessary dependencies.
- Use baremodules to export a subset of functions.
- Consider adding terminalmenus for picking functions, at least a way of listing those.

# Installation
pkg> registry add github.com/hustf/M8
pgk> add MechanicalSketch
Expand Down
2 changes: 1 addition & 1 deletion examples/pluto_1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ l7 = for i in 1:200
# ╔═╡ 53105580-6894-11eb-3af3-3feadd3c43bf
begin
l1, l2, l3, l4, l5, l6, l7
this_fig = empty_figure(joinpath(@__DIR__, "pluto_1.png"))
this_fig = empty_figure(filename = joinpath(@__DIR__, "pluto_1.png"))
background("green")
end

Expand Down
36 changes: 28 additions & 8 deletions src/MechanicalSketch.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module MechanicalSketch
# TODO import new Luxor functions from latest revision.
import Luxor
import Luxor: Drawing,Turtle, Pencolor, Penwidth, Forward, Turn, HueShift, SVGimage,
paper_sizes,
Tiler, Partition,
rescale,

finish, preview,
finish, preview, snapshot,
origin, rulers, background,

@png, @pdf, @svg, @eps, @draw, @imagematrix,
Expand Down Expand Up @@ -230,10 +231,29 @@ Initial scale is set with set_scale_sketch()
pt height = 70m/s
pt height = 20kN
"""
function empty_figure(filename = "HiThere.png";
function empty_figure(;filename = :rec,
backgroundcolor = color_with_lumin(PALETTE[8], 10),
hue = PALETTE[8], height = missing, width = missing)
fig = Drawing(WI, HE, filename)
configure_mechanical(;backgroundcolor, hue, height, width)
fig
end
"""
configure_mechanical(;
backgroundcolor = color_with_lumin(PALETTE[8], 10),
hue = PALETTE[8], height = missing, width = missing)
Establish a drawing sized for A4 300 dpi figures (WI, HE),
black on white figure, line width 3 pt default.
Initial scale is set with set_scale_sketch()
pt height = 20m
pt height = 70m/s
pt height = 20kN
"""
function configure_mechanical(;
backgroundcolor = color_with_lumin(PALETTE[8], 10),
hue = PALETTE[8], height = missing, width = missing)
# Font for the 'toy' text interface
# (use e.g. JuliaMono for unicode symbols like ∈. There are no nice fonts for text AND math.
fontface("Calibri")
Expand All @@ -247,8 +267,9 @@ function empty_figure(filename = "HiThere.png";
setdash("solid")
# Origo at centre
origin()
# Scale and rotation in pixels - x right, y up ('z' is in.). And rotations may
# clockwise. Just deal with it. Or stick to using dimensions.
# Scale and rotation in pixels - x right, y up ('z' is in.). And rotations
# are clockwise. Just deal with it. Or stick to using quantities. Functions taking
# e.g. angles convert to ccw rotations.
setmatrix([1, 0, 0, 1, WI / 2, HE / 2])
@assert !ismissing(width) + !ismissing(height) < 2 "Width or height can be specified here."
if ismissing(width) && ismissing(height)
Expand All @@ -258,16 +279,14 @@ function empty_figure(filename = "HiThere.png";
else
set_scale_sketch(width, WI)
end
fig
end

end

"""
text(t, pt::Point, angle::T; kwargs) where {T <: Angle}
For angles with unit, use rotation around z axis.
"""
text(t, pt::Point, angle::T) where {T <: Angle} = text(t, pt; angle = - ustrip( angle |> rad))
# TODO collect luxor functions with angle arguments in separate file.

polyrotate!(f, ang::Angle) = polyrotate!(f, - ustrip( ang |> rad))


Expand Down Expand Up @@ -295,4 +314,5 @@ include("colorlegends_vector.jl")
include("place_image.jl")
include("latex.jl")
include("chart.jl")
include("macros.jl")
end # module
2 changes: 1 addition & 1 deletion src/autodiff_unitfu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ end

"""
∇(f; physwidth, physheight)
→ derivative function based on linear interpolation between pixels.
→ derivative function (x, y) based on linear interpolation between pixels.
The values of the output function varies linearly between pixels. Take
care if differentiating twice!
Expand Down
6 changes: 3 additions & 3 deletions src/labels.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
box_fill_outline(pt_topleft, colfill;
box_fill_outline(pt_topleft, colfill;
height = row_height(), width = EM, luminfac = 2,
opacity = missing)
Expand All @@ -9,7 +9,7 @@ Outline color luminosity is 200% the luminosity of fill color, if possible.
For dark backgrounds, consider luminfac = 0.5.
By default, opacity is not changed from the current state. Range 0-1, where 1 is opaque.
"""
function box_fill_outline(pt_topleft, colfill;
function box_fill_outline(pt_topleft, colfill;
height = row_height(), width = EM, luminfac = 2, boxopacity = missing)
gsave()
!ismissing(boxopacity) && setopacity(boxopacity)
Expand All @@ -32,7 +32,7 @@ function label_boxed(pt, str; colfill = color_with_lumin(get_current_RGBA(), 0.5
luminfac = 1.0, boxopacity = 0.75, valign = :bottom)
@layer begin
box_fill_outline(pt, colfill; luminfac, height = -FS / 2, width = pixelwidth(str), boxopacity)
sethue(PALETTE[10])
#sethue(PALETTE[10])
text(str, pt; valign)
end
end
Expand Down
Loading

0 comments on commit e65a228

Please sign in to comment.