Skip to content

Instantly share code, notes, and snippets.

View santhoshtr's full-sized avatar
👷‍♂️
Work in progress

Santhosh Thottingal santhoshtr

👷‍♂️
Work in progress
View GitHub Profile
@santhoshtr
santhoshtr / main.mp
Created February 13, 2026 10:04
Diwali #metapost-sandbox
beginfig(0);
width:=100;
rotation:=-40;
pen calligraphypen;
calligraphypen := makepen((0,0)--(width,0) rotated rotation);
z0 = (300, 500);
z1 = (x0, y0-150);
@santhoshtr
santhoshtr / main.mp
Created February 13, 2026 10:04
Untitled Metapost Sample #metapost-sandbox
beginfig(0);
width:=100;
rotation:=45;
pen calligraphicpen ;
calligraphicpen := makepen ((0, 0)--(width,0 ) rotated rotation) ;
z0 = (x1+150, 0);
z1 = (0, y0+250);
@santhoshtr
santhoshtr / main.mp
Created February 13, 2026 10:04
Untitled Metapost Sample #metapost-sandbox
verbatimtex
\documentclass{minimal}
\begin{document}
etex
beginfig(2);
% Store the text in a picture variable
picture p;
p := thelabel("Another example", origin);
@santhoshtr
santhoshtr / main.mp
Created February 13, 2026 10:04
Untitled Metapost Sample #metapost-sandbox
beginfig(0);
width:=100;
rotation:=45;
pen calligraphicpen ;
calligraphicpen := makepen ((0, 0)--(width,0 ) rotated rotation) ;
z0 = (x1+150, 0);
z1 = (0, y0+250);
@santhoshtr
santhoshtr / main.mp
Created February 13, 2026 10:04
Untitled Metapost Sample #metapost-sandbox
beginfig(1);
u := 1cm;
% Нарисуем уровневые линии V1 и V
draw fullcircle scaled 2.4u shifted (0,0) withpen pencircle scaled 1pt; % V
label("$V$", (1.2u, 1.2u));
draw fullcircle xscaled 1.8u yscaled 1.2u shifted (0,0) withpen pencircle scaled 1pt; % V1
label("$V_1$", (0.8u, -1u));
@santhoshtr
santhoshtr / main.mp
Created February 13, 2026 10:04
Untitled Metapost Sample #metapost-sandbox
outputtemplate := "%j.eps";
beginfig(1);
% Единица измерения
u := 1cm;
% Определяем точки
pair center, left, right;
center := (5u, 3u);
left := (2u, 3u);
@santhoshtr
santhoshtr / main.mp
Created February 13, 2026 10:04
Brownian motion #metapost-sandbox
beginfig(1);
% randomseed := uniformdeviate infinity;
randomseed := 2141.34242;
numeric u, v; u = 5; v = 4;
for n=1 upto 4:
numeric x, y; x = y = 0;
path w; w = (x, y) for i=1 upto 2048:
hide(x := x + normaldeviate * u ; y := y + normaldeviate * v)
.. (x, y)
endfor;
@santhoshtr
santhoshtr / main.mp
Created February 13, 2026 10:04
Tiling with gray color variations #metapost-sandbox
beginfig(0);
numeric s; s = 10;
%First a basic path (named atom) is defined,
path atom;
atom = origin
-- (2s,0) rotated -30 -- (2s,0) rotated -30 + (0,s)
-- ( s,0) rotated 30 -- ( s,0) rotated 30 + (0,s)
-- (0,2s) -- cycle;
@santhoshtr
santhoshtr / main.mp
Created February 13, 2026 10:04
Color - hex color code usage #metapost-sandbox
vardef hexrgb(expr Spec) =
save r, g, b;
numeric r, g, b;
r = hex substring (1,3) of Spec;
g = hex substring (3,5) of Spec;
b = hex substring (5,7) of Spec;
1/256(r,g,b)
enddef;
@santhoshtr
santhoshtr / main.mp
Created February 13, 2026 10:04
hsl_colors #metapost-sandbox
vardef hsl_color(expr h, s, l) =
save chroma, hh, x, m;
chroma = (1 - abs(2 * l - 1)) * s;
hh = h / 60;
x = chroma * (1 - abs(hh mod 2 - 1));
m = l - chroma / 2;
if hh < 1: (chroma,x,0)+(m,m,m)
elseif hh < 2: (x,chroma,0)+(m,m,m)
elseif hh < 3: (0,chroma,x)+(m,m,m)
elseif hh < 4: (0,x,chroma)+(m,m,m)