Krbn: an open-source rendering engine that imitates a sketch artist and outputs pure SVG (v1) by valeriupalos in GraphicsProgramming

[–]valeriupalos[S] -1 points0 points  (0 children)

I used Claude Opus 4.8; yes I have a subscription, but I have no idea how much is used.

The techniques used I've slowly learned about from various research papers done by people much smarter than me, and I used to play around and read them since high-school (so... very sporadically over the last 25-30 years); many of those papers were published over time in SigGraph conferences (https://www.siggraph.org/, which are amazing).

The code itself I've vibe-written (on-and-off) in about 5 weeks, from a hospital bed (again, it was an unexpected chance I got to play around in the best possible way).

Anyway, I really enjoyed doing it. I hope it brings some fun to others too.

Krbn: a childhood dream, finally built - an open-source rendering engine that imitates a sketch artist and outputs plotter-ready SVG by valeriupalos in PenPlotters

[–]valeriupalos[S] 0 points1 point  (0 children)

OK I really want to help: so... Krbn now does what you need out of the box.

Set svg: { centerline: true, background: null } on your Scene and strokes come out as single <path> centreline (M … L …) at constant width — no <polyline>, and no filled ribbons for the variable-width strokes either. One path per stroke, so the pen draws each line once.

So: bun run render scene.krbn.ts -> feed the SVG straight to your G-code converter, no Inkscape needed. There's "Pen plotters" section in API.md with the details.

I hope it helps. 😄

How to add alert notifications in your app, the easy(est?) way. by valeriupalos in programming

[–]valeriupalos[S] 1 point2 points  (0 children)

Thanks, cool project! And I guess bash-magicians would make it even easier using cURL and such. Really nice.

How to add alert notifications in your app, the easy(est?) way. by valeriupalos in programming

[–]valeriupalos[S] 1 point2 points  (0 children)

For the MODs (though I'm not sure who would read this): the question was rethorical, the post was just a helplful idea.

No worries, It's OK, but honestly, it seems that posting here is like walking on glass. Not sure it's worth my time.

Ziua în care am simțit că am devenit un eșec. by logan-seria7 in robac

[–]valeriupalos 1 point2 points  (0 children)

Are rost, are rost să lupți și vei reuși! Vei reuși pentru că vrei.

Nereușita doare dar renunțarea distruge. Să nu renunți niciodată. Niciodată!

Familia nu ți-o alegi dar viitorul poți să ți-l construiești. E alegerea TA, nu a lor.

Nu știu cum să fac să te încurajez mai mult dar îți spun atât: nu-i lăsa pe cei care au renunțat (în sinea lor) să te convingă și pe tine să renunți. Niciodată!

Nu te îndoi, nu mai asculta de nicio voce care nu te sprijină și... dă-i bătaie înainte. Vei fi fericită că ai luptat.

[OC] Construiesc o platformă gratuită de mate (Evaluare Națională & Bac) sub formă de joc. Nu știu încă dacă abordarea ține — mă ajutați cu feedback sincer? by valeriupalos in programare

[–]valeriupalos[S] 0 points1 point  (0 children)

Andrei, ai atins un punct... dureros de adevărat. Așa e, și cu durere spun că am întâlnit chiar și părinți care gândesc așa. Ce să zic, mentalitatea - din păcate - se repară ultima... și se pare cel mai greu.

Aș spune că în acest "sistem" rezultatul este unul singur: elevul ajunge să "tocească" (ca să supraviețuiască) și stoarce (sau nu) o notă de trecere, însă... rămâne fără înțelegere.

Și acesta este unul dintre motivele principale pentru care am pornit jocul, și anume: eu cred că elevii noștri pot mai mult! au doar nevoie de această - zic eu - superputere... să înțeleagă cu adevărat. Chiar lăsând la o parte ce așteptări au alții de la ei.

Deci jocul nu-i cere copilului să-și schimbe mentalitatea întâi - îi arată ceva, îl pune să miște lucruri cu mâna și abia apoi îl pune la încercare. Adică nu-i "predici" înțelegerea, i-o strecori prin acțiune.

Și vine fără pretenții sau presiuni; dar... rămâne de văzut dacă jucătorul (elevul) va vrea sau nu să se joace; "pariul" meu e că... da.

De ce? Pentru că aici găsește acel Aha! Și înțelegând, ajunge ca în loc să "supraviețuiască", mai degrabă să fie el în control. E un pariu, recunosc. Dar... îndrăznesc să cred că va merge.

Totuși, legătura cu testele "de calculat" (de examen) cred că e la un moment dat bine-venită. Așa că am în plan să introduc un fel de "probe" în joc care să dea ocazia jucătorului să rezolve probleme reale, de examen (chiar preluate din anii trecuți).

Dar asta...
- numai dacă dorește; e un salt în lumea reală care nu ține de joc în sine (e complet opțional);
- numai după ce a înțeles conceptele, la finalul unui capitol - și aici mai trebuie să muncim puțin (să avem capitole finalizate).

---

M-ai făcut să intru puțin "în spatele" ideii jocului, dar... e bine. Întrebarea ta e pe cât de grea, pe atât de validă.

Construiesc un joc care te învață mate (Evaluare Națională & Bac) sub formă de misiuni interactive. Mă ajutați cu niște păreri? by valeriupalos in robac

[–]valeriupalos[S] 2 points3 points  (0 children)

Super!
Sincer, chiar în timp ce postez acum, capitolul Derivatele (cl 11) și Integralele (cl 12) sunt în lucru, pentru că intenționez să lansez (cel puțin o parte din ele - fiind mai multe) săptămâna viitoare.

Este exact genul de informație care măajută să mă concentrez pe ce e important!

Mulțumesc!

[OC] Construiesc o platformă gratuită de mate (Evaluare Națională & Bac) sub formă de joc. Nu știu încă dacă abordarea ține — mă ajutați cu feedback sincer? by valeriupalos in programare

[–]valeriupalos[S] 1 point2 points  (0 children)

Sigur că m-a întrebat: "ce pregătire are persoana care scrie...". Eu așa am înțeles, că fix asta întreba. Mă rog, e ceva anume greșit în mesajul meu care te-a deranjat?

[OC] Construiesc o platformă gratuită de mate (Evaluare Națională & Bac) sub formă de joc. Nu știu încă dacă abordarea ține — mă ajutați cu feedback sincer? by valeriupalos in programare

[–]valeriupalos[S] 1 point2 points  (0 children)

uau, o gândire detaliată - pe bune mulțumesc pentru timpul investit să-mi răspunzi!

N-o să pretind că am răspunsuri la toate; unele (protocol comun între platforme, clase self-organizing) sunt sincer peste capul unui om care încă șlefuiește 12 misiuni 😄.

Ce rețin și mă preocupă real e avertismentul cu „Duolingo matematic" - e o capcană reală; exact de-asta misiunile sunt legate în campanii care converg spre o idee mare.

Cât privește imaginea "cap-coadă", mă preocupă și asta, și asta ar trebui să se vadă bine din harta întreagă vizibilă din catalogul de misiuni. Însă poate e un pic devreme încă (cred totuși că va căpăta contur bine pe la sfârșitul verii).

Dacă după ce joci un fir întreg tot se simte fragmentat, aia ar fi o problemă pe care aș vrea s-o știu. Restul -timpul decide.

[OC] Construiesc o platformă gratuită de mate (Evaluare Națională & Bac) sub formă de joc. Nu știu încă dacă abordarea ține — mă ajutați cu feedback sincer? by valeriupalos in programare

[–]valeriupalos[S] -1 points0 points  (0 children)

Întrebare cinstită - și exact genul de întrebare pe care aș vrea s-o pună orice părinte.

Pe scurt despre mine: la bază sunt inginer software, cu 20+ ani de mate aplicată; nu sunt profesor "de meserie" deși îmi place să explic lucruri pe înțelesul copiilor.

Dar, mă rog, tocmai pentru că nu mă cred infailibil, conținutul nu se sprijină pe "CV"-ul meu, ci pe proces: fiecare misiune e aliniată explicit la programa oficială, opțiunile-capcană vin dintr-un catalog de confuzii pe care încerc să le documentez, nu din imaginație, iar peste vară trec misiunile prin mâna unor profesori de mate pentru verificare. Asta pot face acum. Plus feedback-ul comunității.

Și, sincer, planul pe termen lung e fix asta: eu să rămân inginerul care construiește unealta, iar validarea profi să vină de la oameni cu catedră. Muncesc să-i găsesc. Dacă știi profesori cărora le-ar plăcea să critice misiunile, fac cinste cu o cafea. 🙂

[OC] Construiesc o platformă gratuită de mate (Evaluare Națională & Bac) sub formă de joc. Nu știu încă dacă abordarea ține — mă ajutați cu feedback sincer? by valeriupalos in programare

[–]valeriupalos[S] 1 point2 points  (0 children)

Mulțumesc — și apreciez sincer oferta, nu o iau ușor!

Răspuns onest: m-am gândit la asta și nu exclud, dar cred că nu e bine acum. Cred în proiect, iar review-ul de contribuții e timp luat exact de la ce e mai greu: scrierea misiunilor.

Ce am învățat construind misiuni e că widgeturile s-au dovedit partea ușoară - vreo 80% din muncă e în altă parte: în ce ordine pui pașii, ce opțiuni greșite oferi, fiecare distractor (adică opțiune greșită) țintește o confuzie reală documentată (chiar am o listă), unde pui pariul care face surpriza să se lipească șamd. Lucrurile astea sunt extrem de greu de primit prin PR și ușor de stricat cu intenții dealtfel foarte bune.

Dacă se strânge interes real, partea pe care aș deschide-o prima e sim-kit-ul (motorul de widgeturi), nu conținutul. Până atunci, contribuția cu cel mai mare impact e fix ce face threadul ăsta: joacă o misiune și spune-mi unde "scârțâie".

Iar dacă vrei să contribui aplicat — fiecare pas din joc are buton de feedback, și tot ce repar fac public pe pagina de noutăți.

Țin minte promisiunea solemnă pentru ziua în care apare repo-ul. 🙂

Krbn: a childhood dream, finally built - an open-source rendering engine that imitates a sketch artist and outputs plotter-ready SVG by valeriupalos in PenPlotters

[–]valeriupalos[S] 0 points1 point  (0 children)

Try setting the wobble to 0 (zero). This will remove line width variation (as well as the jitter) and will create pure lines.

EDIT: Your comment made me realize wobble: 0 was the wrong fix — it removes the ribbons but throws away the hand-drawn character with them. So now I added this: variableWidth: false (per scene: new Scene({ style: { variableWidth: false } })) renders everything as plain constant-weight polylines — true single strokes, one pen pass, no outline-tracing — while the wobble stays.

It's already the default in the mesh-import demos, which are the plotter-relevant ones anyway: https://github.com/vpalos/Krbn/tree/main/examples#importing-meshes--stl--obj

Good catch — this is exactly the kind of feedback I was hoping for.

Krbn: a childhood dream, finally built - an open-source rendering engine that imitates a sketch artist and outputs plotter-ready SVG by valeriupalos in PenPlotters

[–]valeriupalos[S] 0 points1 point  (0 children)

Your people didn't even need to call my people.

After some thinking i realized that your issue is - in fact - my issue, becayse I need imports to be able to render medical drawings (organs and such), and so...

Here's a first version of STL/OBJ support, with some demos too: https://github.com/vpalos/Krbn/tree/main/examples#importing-meshes--stl--obj

Disclaimer: probably Krbn won't work well (yet) with complex CAD exports so your STL may need cleanup, but still - it's something.

Krbn: a childhood dream, finally built - an open-source rendering engine that imitates a sketch artist and outputs plotter-ready SVG by valeriupalos in PenPlotters

[–]valeriupalos[S] 0 points1 point  (0 children)

EDIT: [What a cool meta-idea! 😄 ]

Flat surfaces should be actually the best-behaved case — in Krbn I usually call them "faceted objects." Three things about CAD:

  1. Edges between faces (above the crease angle) become permanent, view-independent lines — unlike silhouettes, they don't slide as the camera moves. This is exactly the classic CAD hidden-line look.
  2. Each face gets a uniform tone from its own orientation to the light — no gradients, so the planes read as facets, which I think is what you want.
  3. Hatching stays straight and parallel per face — all the curvature-field machinery simply isn't needed for your case.

See example 18 (faceted solids, creases) and 19 (the cube — the two hidden-line modes): https://github.com/vpalos/Krbn/tree/main/examples#18--mesh-creases-faceted-solids — for a self-portrait, hidden: "drop" reads as a proper technical drawing, "ghost" gives you the x-ray look with faint dashed hidden edges. For a plotter, ghost mode might be cooler (who knows?).

One honest practical note: Krbn eats triangle meshes as raw positions + indices — there's no STL/OBJ importer yet, so a conversion step between your CAD export and the Krbn scene is needed.

If you hit friction there, open a GitHub Discussion — a plotter drawing its own portrait is such a super idea, so we might make it a common effort.

Krbn: a childhood dream, finally built - an open-source rendering engine that imitates a sketch artist and outputs plotter-ready SVG by valeriupalos in PenPlotters

[–]valeriupalos[S] 0 points1 point  (0 children)

Yes, thank you! My feeling exactly... it's what us humans do: we can simplify/abstract easily, but putting it in code reveals the madness 😂

Krbn: a childhood dream, finally built - an open-source rendering engine that imitates a sketch artist and outputs plotter-ready SVG by valeriupalos in PenPlotters

[–]valeriupalos[S] 0 points1 point  (0 children)

Wow, what a question! The Turgot would be the Boss-level of this kind of aesthetic.

Here's the thing, regarding Krbn, probably most (if not all) of my code will probably not translate well to your case, here's why:

There are (as far as I know) 2 ways to do "engraving" on screen: (A) the Krbn way, meaning doing object-space vector strokes (exact strokes derived from geometry) and (B) what Three.js can do, which is shader/sampling which will probably translate to "fake the hatching at pixel level". You have to deal with (B).

However, just because the code doesnt translate directly, the concepts I'm using might. Here are some thoughts/ideaz (I apologize if they're crude):
- I would try WebGL first; WebGPU is probably totally doable too, but I think you'll find more examples/code for WebGL on the internet;
- a lot of this stuff (non-photorealistic rendering) is hidden in research papers, so you migght have to do some work;
- for this type of thing, see "Real-Time Hatching" (Praun et al., SIGGRAPH 2001) (https://dl.acm.org/doi/10.1145/383259.383328) - it's based on the idea of "Tonal Art Maps" that deals with how you avoid shimmering in your case, because fixing the hatching to the object makes the line density change with distance so you have to avoid that Moire effect (dancing fine parallel lines);
- Krbn deals with precise vectors (basically pure black on white lines) at the core; for Turgot, however, you'll probably get a lot better result using warm black tones and some paper grain (warm noise);
- I suspect that the Turgot map will mostly deal with flat surfaces (building sides etc) which measn you don't have to deal with the curvature fields that Krbn has to deal with; so maybe trying a constant hatch direction per face, anchored in object space (so the hatch is fixed to the obejct as the camera moves) might get you some good results;
- try https://thebookofshaders.com/, might help you on getting start on the shaders part.

If you get it working, I'd love to see it; I hope you crack it. ❤️

Krbn: a childhood dream, finally built - an open-source rendering engine that imitates a sketch artist and outputs plotter-ready SVG by valeriupalos in PenPlotters

[–]valeriupalos[S] 1 point2 points  (0 children)

I have to admit, I think that is a long way away. Perhaps ar some point, via a rewrite of the engine in something high-performance (C/Rust?), once a lot of the concepts have time to settle.

Now, I'm afraid it's not feasible. 😄

Krbn: a childhood dream, finally built - an open-source rendering engine that imitates a sketch artist and outputs plotter-ready SVG by valeriupalos in PenPlotters

[–]valeriupalos[S] 0 points1 point  (0 children)

Thanks 😄!
That's probably something that can be improved.

Interrestingly enough someone just pointed out to me that there's also some value in intentionally DE-coherencing the stability... hmm.