avancée+
This commit is contained in:
327
composants.typ
327
composants.typ
@ -174,44 +174,117 @@
|
||||
}
|
||||
|
||||
// Schema Shannon
|
||||
// #let canal_shannon_intro() = {
|
||||
// cetz.canvas({
|
||||
// import cetz.draw: *
|
||||
//
|
||||
// // Styles
|
||||
// let s = (stroke: 2pt + black)
|
||||
// let s_fleche = (stroke: 2pt + black)
|
||||
// let pointe_pleine = (end: "stealth", fill: black)
|
||||
//
|
||||
// let espacement = 5.5
|
||||
//
|
||||
// // Blocs
|
||||
// content((0, 0), [Source], name: "src", frame: "rect", ..s, padding: .3)
|
||||
// content((espacement, 0), [Emetteur], name: "em", frame: "rect", ..s, padding: .3)
|
||||
// content((espacement * 2, 0), [Canal], name: "chan", frame: "rect", ..s, padding: .3)
|
||||
// content((espacement * 3, 0), [Récepteur], name: "rec", frame: "rect", ..s, padding: .3)
|
||||
// content((espacement * 4, 0), [Destinataire], name: "dest", frame: "rect", ..s, padding: .3)
|
||||
//
|
||||
// // Bruit
|
||||
// content((rel: (0, 1.8), to: "chan"), [Bruit], name: "bruit", frame: "rect", ..s, padding: .3)
|
||||
//
|
||||
// // Codage / Décodage
|
||||
// content((rel: (0, 1), to: "em"), [*Codage*])
|
||||
// content((rel: (0, 1), to: "rec"), [*Décodage*])
|
||||
//
|
||||
// // Flèches (On utilise s_fleche et pointe_pleine)
|
||||
// line("src.east", "em.west", mark: pointe_pleine, ..s_fleche)
|
||||
// line("em.east", "chan.west", mark: pointe_pleine, ..s_fleche)
|
||||
// line("chan.east", "rec.west", mark: pointe_pleine, ..s_fleche)
|
||||
// line("rec.east", "dest.west", mark: pointe_pleine, ..s_fleche)
|
||||
// line("bruit.south", "chan.north", mark: pointe_pleine, ..s_fleche)
|
||||
//
|
||||
// // Annotation
|
||||
// let note-style = (size: 0.75em, style: "italic")
|
||||
// content((espacement * 0.5, -0.5), text(..note-style)[Message])
|
||||
// content((espacement * 1.5, -0.5), text(..note-style)[Signal])
|
||||
// content((espacement * 2.5, -0.5), text(..note-style)[Signal])
|
||||
// content((espacement * 3.5, -0.5), text(..note-style)[Message])
|
||||
// })
|
||||
// }
|
||||
|
||||
#let canal_shannon_intro() = {
|
||||
cetz.canvas({
|
||||
// Couleurs
|
||||
let col-u = blue // Signal propre
|
||||
let col-p = orange // Signal bruité
|
||||
let C_MAIN = black
|
||||
let C_BG = rgb("#f8f9fa") // Le gris très clair demandé
|
||||
let C_LABEL = black
|
||||
|
||||
cetz.canvas(length: 1cm, {
|
||||
import cetz.draw: *
|
||||
|
||||
// Styles
|
||||
let s = (stroke: 2pt + black)
|
||||
let s_fleche = (stroke: 2pt + black)
|
||||
let pointe_pleine = (end: "stealth", fill: black)
|
||||
let x_left = 4.0 ; let x_right = 16.0 ; let x_noise = 22.5
|
||||
let y_top = 14.5 ; let y_mid = 9.0 ; let y_bot = 3.5
|
||||
|
||||
let espacement = 5.5
|
||||
// Style des lignes avec flèches
|
||||
let s_ligne = (stroke: 1.5pt + C_MAIN, mark: (end: "stealth", fill: C_MAIN, size: 0.25))
|
||||
let s_bruit_fleche = (stroke: (paint: black, thickness: 1.5pt, dash: "dashed"), mark: (end: "stealth", fill: black, size: 0.25))
|
||||
|
||||
// Blocs
|
||||
content((0, 0), [Source], name: "src", frame: "rect", ..s, padding: .3)
|
||||
content((espacement, 0), [Emetteur], name: "em", frame: "rect", ..s, padding: .3)
|
||||
content((espacement * 2, 0), [Canal], name: "chan", frame: "rect", ..s, padding: .3)
|
||||
content((espacement * 3, 0), [Récepteur], name: "rec", frame: "rect", ..s, padding: .3)
|
||||
content((espacement * 4, 0), [Destinataire], name: "dest", frame: "rect", ..s, padding: .3)
|
||||
// Fonction de bloc avec le nouveau fond
|
||||
let bloc(pos, txt, stxt, n) = {
|
||||
content(pos, [#set align(center); #text(C_MAIN, weight: "bold", size: 1.2em)[#txt] \ #text(C_MAIN, size: 0.85em, style: "italic")[#stxt]],
|
||||
frame: "rect", fill: C_BG, stroke: C_MAIN + 1.5pt, padding: 0.7, radius: 0.3, name: n)
|
||||
}
|
||||
|
||||
// Bruit
|
||||
content((rel: (0, 1.8), to: "chan"), [Bruit], name: "bruit", frame: "rect", ..s, padding: .3)
|
||||
// --- ONDES (Bruit dosé : "tremblement" au lieu de "chaos") ---
|
||||
let wave_vert(x, y_start, y_end, is_noisy) = {
|
||||
let n_points = 200
|
||||
let color = if is_noisy { col-p } else { col-u }
|
||||
|
||||
line(..range(n_points + 1).map(i => {
|
||||
let t = i / n_points
|
||||
let y = y_start + t * (y_end - y_start)
|
||||
|
||||
// Enveloppe pour raccord propre
|
||||
let env = if t < 0.05 { t/0.05 } else if t > 0.95 { (1-t)/0.05 } else { 1.0 }
|
||||
|
||||
let signal = 0.35 * calc.sin(t * 6 * calc.pi)
|
||||
|
||||
// Bruit dosé : on a baissé les fréquences et l'amplitude
|
||||
let bruit = if is_noisy {
|
||||
(0.08 * calc.sin(t * 45 * calc.pi) + 0.05 * calc.cos(t * 97 * calc.pi))
|
||||
} else { 0 }
|
||||
|
||||
(x + (signal + bruit) * env, y)
|
||||
}), stroke: color + 1.6pt)
|
||||
}
|
||||
|
||||
// Codage / Décodage
|
||||
content((rel: (0, 1), to: "em"), [*Codage*])
|
||||
content((rel: (0, 1), to: "rec"), [*Décodage*])
|
||||
wave_vert(x_right, y_top - 1.5, y_mid + 1, false) // Bleu
|
||||
wave_vert(x_right, y_mid - 1, y_bot + 1.5, true) // Orange
|
||||
|
||||
// Flèches (On utilise s_fleche et pointe_pleine)
|
||||
line("src.east", "em.west", mark: pointe_pleine, ..s_fleche)
|
||||
line("em.east", "chan.west", mark: pointe_pleine, ..s_fleche)
|
||||
line("chan.east", "rec.west", mark: pointe_pleine, ..s_fleche)
|
||||
line("rec.east", "dest.west", mark: pointe_pleine, ..s_fleche)
|
||||
line("bruit.south", "chan.north", mark: pointe_pleine, ..s_fleche)
|
||||
// --- BLOCS ---
|
||||
bloc((x_left, y_top), "Source", "Information", "src")
|
||||
bloc((x_right, y_top), "Émetteur", "Codage", "em")
|
||||
bloc((x_right, y_mid), "Canal", "", "canal")
|
||||
bloc((x_noise, y_mid), "Bruit", "", "bruit")
|
||||
bloc((x_right, y_bot), "Récepteur", "Décodage", "rec")
|
||||
bloc((x_left, y_bot), "Destinataire", "Information", "dest")
|
||||
|
||||
// Annotation
|
||||
let note-style = (size: 0.75em, style: "italic")
|
||||
content((espacement * 0.5, -0.5), text(..note-style)[Message])
|
||||
content((espacement * 1.5, -0.5), text(..note-style)[Signal])
|
||||
content((espacement * 2.5, -0.5), text(..note-style)[Signal])
|
||||
content((espacement * 3.5, -0.5), text(..note-style)[Message])
|
||||
// --- CONNEXIONS ---
|
||||
line("src.east", "em.west", ..s_ligne)
|
||||
line("bruit.west", "canal.east", ..s_bruit_fleche)
|
||||
line("rec.west", "dest.east", ..s_ligne)
|
||||
|
||||
// --- ANNOTATIONS ---
|
||||
let lab(pos, body, color: C_LABEL, anchor: "center") = content(pos, text(size: 0.95em, fill: color, style: "italic", weight: "medium")[#body], anchor: anchor)
|
||||
|
||||
lab(((x_left + x_right)/2 - 0.3, y_top + 0.7), "Message")
|
||||
lab((x_right + 1.2, (y_top + y_mid)/2), "Signal", color: col-u, anchor: "west")
|
||||
lab((x_right + 1.2, (y_mid + y_bot)/2), "Signal + Bruit", color: col-p, anchor: "west")
|
||||
lab(((x_left + x_right)/2 + 0.3, y_bot - 0.7), "Message reçu")
|
||||
})
|
||||
}
|
||||
|
||||
@ -500,3 +573,199 @@
|
||||
]
|
||||
}
|
||||
|
||||
#let decor_matrice_etoilee() = {
|
||||
// Ajuste length (ex: 0.6mm ou 0.7mm) selon ta diapo
|
||||
cetz.canvas(length: 0.7mm, {
|
||||
import cetz.draw: *
|
||||
|
||||
// --- 1. Paramètres de la Matrice ---
|
||||
let nx = 430
|
||||
let ny = 265
|
||||
|
||||
// --- 2. Paramètres de la Loupe ---
|
||||
let loupe_x = nx * 0.70
|
||||
let loupe_y = -ny / 2.0
|
||||
let R = 50.0
|
||||
let zoom = 3.0
|
||||
|
||||
// --- 3. Paramètre d'Estompage (Gauche uniquement) ---
|
||||
let fade_left = 220.0
|
||||
|
||||
// Palette de couleurs
|
||||
let col_focus = rgb("#0284c7")
|
||||
let col_fade = rgb("#64748b")
|
||||
let col_grid = rgb("#e2e8f0")
|
||||
|
||||
// --- Fonction pseudo-aléatoire ---
|
||||
let pseudo_rand(x, y) = {
|
||||
let v = x * 7919 + y * 104729 + (x * x) * 313 + (y * y) * 991 + (x * y) * 101
|
||||
calc.rem(calc.abs(v), 100)
|
||||
}
|
||||
|
||||
// --- ÉTAPE A : Dessin de la matrice (Fade à gauche uniquement) ---
|
||||
for x in range(nx) {
|
||||
for y in range(ny) {
|
||||
let hash = pseudo_rand(x, y)
|
||||
let is_active = hash < 12
|
||||
|
||||
if is_active {
|
||||
// L'intensité ne dépend plus que de la position X
|
||||
let intensity = calc.min(1.0, x / fade_left)
|
||||
|
||||
if intensity > 0.05 {
|
||||
let radius = 0.20 + 0.15 * intensity
|
||||
let c = col_fade.lighten((1.0 - intensity) * 80%)
|
||||
circle((x, -y), radius: radius, fill: c, stroke: none)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- ÉTAPE B : Dessin de la Loupe ---
|
||||
circle((loupe_x, loupe_y), radius: R, fill: white, stroke: none)
|
||||
|
||||
// Grille zoomée
|
||||
let limit = 20
|
||||
for k in range(-limit, limit + 1) {
|
||||
let offset = k * zoom
|
||||
if calc.abs(offset) < R {
|
||||
let half_chord = calc.sqrt(R * R - offset * offset)
|
||||
line((loupe_x + offset, loupe_y + half_chord), (loupe_x + offset, loupe_y - half_chord), stroke: 0.5pt + col_grid)
|
||||
line((loupe_x - half_chord, loupe_y + offset), (loupe_x + half_chord, loupe_y + offset), stroke: 0.5pt + col_grid)
|
||||
}
|
||||
}
|
||||
|
||||
// Points zoomés
|
||||
let search_r = int(R / zoom) + 2
|
||||
let lx_int = int(loupe_x)
|
||||
let ly_idx = int(-loupe_y)
|
||||
|
||||
for x in range(lx_int - search_r, lx_int + search_r + 1) {
|
||||
for y in range(ly_idx - search_r, ly_idx + search_r + 1) {
|
||||
let hash = pseudo_rand(x, y)
|
||||
if hash < 12 {
|
||||
let dx = x - loupe_x
|
||||
let dy = -y - loupe_y
|
||||
let d_orig = calc.sqrt(dx * dx + dy * dy)
|
||||
let d_zoom = d_orig * zoom
|
||||
|
||||
if d_zoom <= R - 1.2 {
|
||||
circle((loupe_x + dx * zoom, loupe_y + dy * zoom), radius: 1.1, fill: col_focus, stroke: none)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bordures de la Loupe
|
||||
circle((loupe_x, loupe_y), radius: R, stroke: 1.8pt + col_focus.lighten(20%))
|
||||
circle((loupe_x, loupe_y), radius: R + 1.5, stroke: 1.0pt + col_focus.lighten(50%))
|
||||
circle((loupe_x, loupe_y), radius: R + 3.5, stroke: 0.5pt + col_focus.lighten(80%))
|
||||
})
|
||||
}
|
||||
|
||||
#let hldpc() = {
|
||||
import cetz.draw: *
|
||||
|
||||
let points = (
|
||||
(7,0), (10,0), (15,0), (22,0), (24,0), (29,0), (3,1), (6,1), (18,1), (19,1), (25,1), (27,1),
|
||||
(5,2), (9,2), (13,2), (14,2), (17,2), (28,2), (0,3), (8,3), (11,3), (16,3), (20,3), (26,3),
|
||||
(1,4), (2,4), (4,4), (12,4), (21,4), (23,4), (5,5), (6,5), (8,5), (10,5), (21,5), (29,5),
|
||||
(14,6), (15,6), (16,6), (18,6), (22,6), (28,6), (0,7), (1,7), (4,7), (9,7), (20,7), (26,7),
|
||||
(2,8), (3,8), (11,8), (12,8), (17,8), (19,8), (7,9), (13,9), (23,9), (24,9), (25,9), (27,9),
|
||||
(0,10), (6,10), (15,10), (18,10), (21,10), (26,10), (2,11), (7,11), (10,11), (17,11), (22,11), (27,11),
|
||||
(8,12), (11,12), (14,12), (20,12), (23,12), (29,12), (4,13), (5,13), (9,13), (13,13), (16,13), (19,13),
|
||||
(1,14), (3,14), (12,14), (24,14), (25,14), (28,14)
|
||||
)
|
||||
|
||||
cetz.canvas(length: 0.45cm, {
|
||||
let nx = 30
|
||||
let ny = 15
|
||||
let cell_size = 1.0
|
||||
let h_width = nx * cell_size
|
||||
let h_height = ny * cell_size
|
||||
|
||||
// Palette unifiée
|
||||
let color_blue = blue
|
||||
let color_orange = orange
|
||||
let col_dot_base = gray.darken(30%)
|
||||
|
||||
// Définition des couleurs de fond (lighten)
|
||||
let col_row_bg = color_blue.lighten(90%)
|
||||
let col_col_bg = color_orange.lighten(90%)
|
||||
// Calcul du mélange pour l'intersection
|
||||
let col_mix_bg = col_row_bg.mix(col_col_bg)
|
||||
|
||||
// Label "H ="
|
||||
content((-3.4, -h_height / 2), text(size: 1.6em, weight: "bold")[$bold(H) = $])
|
||||
|
||||
// Sélection visuelle (Focus)
|
||||
let sel_row = 7
|
||||
let sel_col = 10
|
||||
|
||||
// Rectangles de fond
|
||||
rect((0, -sel_row), (h_width, -sel_row - 1), fill: col_row_bg, stroke: none)
|
||||
rect((sel_col, 0), (sel_col + 1, -h_height), fill: col_col_bg, stroke: none)
|
||||
rect((sel_col, -sel_row), (sel_col + 1, -sel_row - 1), fill: col_mix_bg, stroke: none)
|
||||
|
||||
// Grands crochets matriciels
|
||||
let b_w = 0.6
|
||||
set-style(stroke: (thickness: 1.5pt, cap: "round"))
|
||||
line((b_w, 0.3), (0, 0.3), (0, -h_height - 0.3), (b_w, -h_height - 0.3))
|
||||
line((h_width - b_w, 0.3), (h_width, 0.3), (h_width, -h_height - 0.3), (h_width - b_w, -h_height - 0.3))
|
||||
|
||||
// Dessin des points
|
||||
for (x, y) in points {
|
||||
let px = x + 0.5
|
||||
let py = -y - 0.5
|
||||
|
||||
let is_row = (y == sel_row)
|
||||
let is_col = (x == sel_col)
|
||||
|
||||
let d_col = col_dot_base
|
||||
let r = 0.16
|
||||
|
||||
if is_row {
|
||||
d_col = color_blue
|
||||
r = 0.24
|
||||
} else if is_col {
|
||||
d_col = color_orange
|
||||
r = 0.24
|
||||
}
|
||||
|
||||
circle((px, py), radius: r, fill: d_col, stroke: none)
|
||||
}
|
||||
|
||||
// 5. Légendes w_r et w_c
|
||||
content((h_width + 0.5, -sel_row - 0.5), anchor: "west", text(fill: color_blue, weight: "bold", size: 1.1em)[$w_r = 6$])
|
||||
content((sel_col + 0.5, 0.8), anchor: "south", text(fill: color_orange, weight: "bold", size: 1.1em)[$w_c = 3$])
|
||||
})
|
||||
}
|
||||
|
||||
#let hldpc_dual(row1: 0, row2: 14) = {
|
||||
import cetz.draw: *
|
||||
let points = ((7,0), (10,0), (15,0), (22,0), (24,0), (29,0), (3,1), (6,1), (18,1), (19,1), (25,1), (27,1), (5,2), (9,2), (13,2), (14,2), (17,2), (28,2), (0,3), (8,3), (11,3), (16,3), (20,3), (26,3), (1,4), (2,4), (4,4), (12,4), (21,4), (23,4), (5,5), (6,5), (8,5), (10,5), (21,5), (29,5), (14,6), (15,6), (16,6), (18,6), (22,6), (28,6), (0,7), (1,7), (4,7), (9,7), (20,7), (26,7), (2,8), (3,8), (11,8), (12,8), (17,8), (19,8), (7,9), (13,9), (23,9), (24,9), (25,9), (27,9), (0,10), (6,10), (15,10), (18,10), (21,10), (26,10), (2,11), (7,11), (10,11), (17,11), (22,11), (27,11), (8,12), (11,12), (14,12), (20,12), (23,12), (29,12), (4,13), (5,13), (9,13), (13,13), (16,13), (19,13), (1,14), (3,14), (12,14), (24,14), (25,14), (28,14))
|
||||
|
||||
cetz.canvas(length: 0.35cm, {
|
||||
let nx = 30; let ny = 15
|
||||
let col_1 = orange; let col_2 = blue
|
||||
|
||||
content((-3.4, -7.5), text(size: 1.6em )[$H = $])
|
||||
|
||||
// Fonds de lignes
|
||||
rect((0, -row1), (nx, -row1 - 1), fill: col_1.lighten(90%), stroke: none)
|
||||
if row2 != none { rect((0, -row2), (nx, -row2 - 1), fill: col_2.lighten(90%), stroke: none) }
|
||||
|
||||
// Crochets
|
||||
set-style(stroke: (thickness: 1.2pt))
|
||||
line((0.5, 0.3), (0, 0.3), (0, -ny - 0.3), (0.5, -ny - 0.3))
|
||||
line((nx - 0.5, 0.3), (nx, 0.3), (nx, -ny - 0.3), (nx - 0.5, -ny - 0.3))
|
||||
|
||||
for (x, y) in points {
|
||||
let d_col = gray.darken(30%)
|
||||
let r = 0.15
|
||||
if y == row1 { d_col = col_1; r = 0.22 }
|
||||
else if y == row2 { d_col = col_2; r = 0.22 }
|
||||
circle((x + 0.5, -y - 0.5), radius: r, fill: d_col, stroke: none)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user