wrench
All checks were successful
/ test_checkout (push) Successful in 2m2s

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2025-10-24 18:35:32 +02:00
parent 10c1d5ec24
commit 34e2ee3631
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
2 changed files with 208 additions and 41 deletions

View file

@ -1,4 +1,43 @@
#let mark(x, y) = {
place(line(start: (x - 5pt, y - 5pt), end: (x + 5pt, y + 5pt)))
place(line(start: (x + 5pt, y - 5pt), end: (x - 5pt, y + 5pt)))
}
#let polar(
x0: 0pt, y0: 0pt,
r: 0pt,
th: 0deg,
) = {
(
x0 + r * calc.cos(th),
y0 + r * calc.sin(th),
)
}
#let arc(
center: (0pt, 0pt),
r: 0pt,
th0: 0deg,
th1: 0deg,
) = {
let (x0, y0) = center
let (x1, y1) = polar(x0: x0, y0: y0, r: r, th: th0)
let (x2, y2) = polar(x0: x0, y0: y0, r: r, th: th1)
let (x_u1, y_u1) = polar(x0: 0pt, y0: 0pt, r: 1pt, th: th0 + 90deg)
let (x_u2, y_u2) = polar(x0: 0pt, y0: 0pt, r: 1pt, th: th1 + 90deg)
let th = th1 - th0
let l = 4 * r / 3 * calc.tan(th / 4) / 1pt
let x_q1 = x1 + l * x_u1
let y_q1 = y1 + l * y_u1
let x_q2 = x2 - l * x_u2
let y_q2 = y2 - l * y_u2
((x1, y1), (x_q1, y_q1), (x_q2, y_q2), (x2, y2))
}
#let phone( #let phone(
width: 200pt, width: 200pt,
height: 400pt, height: 400pt,
@ -75,17 +114,6 @@
) )
} }
#let polar(
x0: 0pt, y0: 0pt,
r: 0pt,
th: 0deg,
) = {
(
x0 + r * calc.cos(th),
y0 + r * calc.sin(th),
)
}
#let gear( #let gear(
//x0: 0pt, y0: 0pt, //x0: 0pt, y0: 0pt,
out-rad: 100pt, out-rad: 100pt,
@ -184,7 +212,173 @@
}) })
} }
#let wrench(height: 200pt) = rotate(45deg, image("imgs/ico/wrench.svg", height: height)) #let wrench(
length: 200pt,
hex_side: none,
handle_width: none,
head_rad: none,
stroke: 3pt+black,
fill: luma(70%),
) = {
let handle_width = if handle_width == none { length * 0.15 } else { handle_width }
let handle_rad = handle_width / 2
let head_rad = if head_rad == none { handle_rad * 2.2 } else { head_rad }
let hex_side = if hex_side == none { head_rad * 0.6 } else { hex_side }
let hex_angle = 360deg / 6
let head_width = hex_side * 0.2
let hex_h = hex_side * calc.cos(hex_angle * 2 - 90deg)
let pommel_center = (handle_rad, 0pt)
let head_neck_half_angle = calc.asin(handle_rad / head_rad)
let head_face_half_angle = calc.asin((hex_h + head_width) / head_rad)
let head_center = (length - calc.sqrt(
head_rad / 1pt * head_rad / 1pt -
(hex_h + head_width) / 1pt * (hex_h + head_width) / 1pt
) * 1pt , 0pt)
let handle_length = head_center.at(0) - calc.sqrt(
head_rad/1pt*head_rad/1pt - handle_rad/1pt*handle_rad/1pt
) * 1pt
let (
pommel_p0,
pommel_q0,
pommel_q1,
pommel_p1
) = arc(
center: pommel_center,
r: handle_rad,
th0: 90deg,
th1: 180deg
)
let (
_,
pommel_q2,
pommel_q3,
pommel_p3
) = arc(
center: pommel_center,
r: handle_rad,
th0: 180deg,
th1: 270deg
)
let neck_dw = (handle_length, handle_rad)
let neck_up = (handle_length, -handle_rad)
let (
head_neck_up_p0,
head_neck_up_q0,
head_neck_up_q1,
head_neck_up_p1
) = arc(
center: head_center,
r: head_rad,
th0: -90deg + head_neck_half_angle - 90deg,
th1: - 90deg
)
let (
head_fup_p0,
head_fup_q0,
head_fup_q1,
head_fup_p1
) = arc(
center: head_center,
r: head_rad,
th0: - 90deg,
th1: - head_face_half_angle,
)
let (
head_fdw_p0,
head_fdw_q0,
head_fdw_q1,
head_fdw_p1,
) = arc(
center: head_center,
r: head_rad,
th0: head_face_half_angle,
th1: 90deg,
)
let (
head_neck_dw_p0,
head_neck_dw_q0,
neck_dw_q1,
_
) = arc(
center: head_center,
r: head_rad,
th0: 90deg,
th1: 180deg - head_neck_half_angle
)
let hex_thi = -hex_angle
let hex_pi = (length - (1 + calc.cos(hex_angle)) * hex_side - head_width, 0pt)
let hex = (
..for i in range(6) {
let last_hex_p = hex_pi
hex_pi = polar(
x0: hex_pi.at(0),
y0: hex_pi.at(1),
r: hex_side,
th: hex_thi,
)
hex_thi = hex_thi + hex_angle
(last_hex_p,)
}
)
let head_fup_in = head_fup_p1
head_fup_in.at(1) += head_width
let head_fdw_in = head_fdw_p0
head_fdw_in.at(1) -= head_width
box(
width: 200pt,
height: 200pt,
//stroke: black,
place(left+horizon, {
place(curve(
stroke: stroke,
fill: fill,
curve.move(neck_dw),
curve.line(pommel_p0),
curve.cubic(pommel_q0, pommel_q1, pommel_p1),
curve.cubic(pommel_q2, pommel_q3, pommel_p3),
curve.line(neck_up),
//curve.line(head_neck_up_p0),
curve.cubic(head_neck_up_q0, head_neck_up_q1, head_neck_up_p1),
curve.cubic(head_fup_q0, head_fup_q1, head_fup_p1),
curve.line(head_fup_in),
..for i in (1, 0, 5) { //(2, 1, 0, 5, 4) {
(curve.line(hex.at(i)),)
},
curve.line(head_fdw_in),
curve.line(head_fdw_p0),
curve.cubic(head_fdw_q0, head_fdw_q1, head_fdw_p1),
//curve.line(head_neck_dw_p0),
curve.cubic(head_neck_dw_q0, neck_dw_q1, neck_dw),
curve.close(mode: "straight")
))
/*
mark(..pommel_center)
mark(..pommel_p0)
mark(..pommel_p1)
mark(..pommel_p3)
mark(..neck_up)
mark(..neck_dw)
mark(..head_fdw_p0)
mark(..head_fdw_p1)
for p in hex {
mark(..p)
}
mark(..head_center)
*/
}))
}
#let apk(height: 100pt) = image("imgs/ico/apk.svg", height: height) #let apk(height: 100pt) = image("imgs/ico/apk.svg", height: height)
#let apks(height: 100pt) = { #let apks(height: 100pt) = {
place(apk(height: height)) place(apk(height: height))
@ -272,14 +466,13 @@
th, th,
) )
) )
} }
#gear() #gear()
/* //#phone(body: [Hello World!])
#phone(body: [Hello World!])
#wrench() #wrench()
/*
#apk() #apk()
#v(4em) #v(4em)
#apks() #apks()

View file

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="46mm"
height="118.93759mm"
viewBox="0 0 46 118.93759"
version="1.1"
id="svg1"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<g
id="layer1"
transform="translate(-7,-7)">
<path
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.9;stroke-linejoin:round"
d="m 17,53.004 -10,-10 v -26 L 17,7 h 6 V 25 L 30.181528,33 37,25 V 7 h 6 l 10,10 v 26 l -9.818,10.004 c 0,0 2.724623,66.2426 -3.182,70 -5.906623,3.7574 -13.147338,4.06253 -20,0 -6.852662,-4.06253 -3,-70 -3,-70 z"
id="path1-6" />
<path
style="fill:#ababab;fill-opacity:1;stroke:#000000;stroke-width:1.9;stroke-linejoin:round"
d="M 20,50 10,40 V 20 20 L 20,10 V 28 L 30,38 40,28 V 10 L 50,20 V 40 L 40,50 c 0,0 2.906623,66.2426 -3,70 -5.906623,3.7574 -7.147338,4.06253 -14,0 -6.852662,-4.06253 -3,-70 -3,-70 z"
id="path1" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1 KiB