Files
hcie-rust-v3.05/graphite_hcie_porting_report.md
T
2026-07-09 02:59:53 +03:00

12 KiB
Executable File
Raw Blame History

Graphite → HCIE 3: Taşınabilir Özellikler ve Rust'tan Rust'a Dönüşüm Analizi

Tarih: 2026-05-24
Kaynak: /run/media/hc/data/Downloads/Graphite-master (Graphite, Rust)
Hedef: /home/hc/Documents/00_PROJECTS/hcie-rust-v3 (HCIE Rust v3)


1. Yürütme Özeti

Graphite, Rust ile yazılmış node-graph tabanlı bir 2D grafik düzenleyicidir. Krita'dan (C++) farklı olarak Graphite tamamen Rust ekosisteminde olduğu için HCIE'ye taşıma maliyeti çok daha düşüktür. Doğrudan kod alıntısı, crate referansı veya algoritma kopyası yapılabilir.

Fayda seviyeleri:

  • Yüksek: Doğrudan kullanılabilir algoritmalar (renk ayarları, gaussian blur, node-graph compiler)
  • Orta: Uyarlanması gereken sistemler (brush engine, message passing, tool sistemi)
  • Düşük: Mimari fark nedeniyle port edilmesi zor (frontend/WebAssembly, node-graph runtime)

2. Mevcut HCIE Mimarisi ile Kıyaslama

Bileşen Graphite HCIE 3 Taşınabilirlik
Pixel Storage DynamicImage / ImageFrame<Color> KisTile (64×64 tile) Düşük — farklı yaklaşım
Blend Modes BlendMode enum (nodes/blending) ~27 blend mode (hcie-blend) Orta — port edilebilir
Color RGB, HSL, LinearRGB, sRGB dönüşümleri sRGB, HSL, Lab Yüksek — color math doğrudan alınabilir
Filters Gaussian blur, dehaze 7 temel filter Yüksek
Node Graph Full compiler + executor Yok Stratejik — yeni mimari
Brush Stamp-based + stroke rendering Temel brush engine Orta
Vector Path boolean, SVG, fill/stroke Temel vector shapes Yüksek — port edilebilir
Text Font cache, text-to-path fontdue-based Orta
GUI WebAssembly + Svelte + WebGL egui/eframe Düşük — toolkit farkı
Message System Dispatcher + Message trait EventBus Orta
Tool System Message-based tool routing ToolState + match Orta
Animation Keyframe timeline Yok Yüksek — başlangıç için
File I/O image crate tabanlı image, psd, zip Düşük — benzer seviyede
Camera Raw rawkit (Sony ARW) Yok Yüksek — bağımsız crate

3. Doğrudan Alınabilecek Kodlar (Kategori 1: Copy-Paste Uyumlu)

3.1 Renk Ayarlarınode-graph/nodes/raster/src/adjustments.rs

Graphite'deki renk ayarlama algoritmaları saf Rust fonksiyonlarıdır, doğrudan hcie-filter crate'ine taşınabilir:

Fonksiyon Graphite Kaynağı HCIE Hedefi Zorluk
brightness_contrast raster/src/adjustments.rs hcie-filter 1/10 — LUT tabanlı, bağımlılık yok
levels raster/src/adjustments.rs hcie-filter 1/10
hue_saturation raster/src/adjustments.rs hcie-filter 1/10
channel_mixer raster/src/adjustments.rs hcie-filter 1/10
selective_color raster/src/adjustments.rs hcie-filter 2/10
vibrance raster/src/adjustments.rs hcie-filter 1/10
exposure raster/src/adjustments.rs hcie-filter 1/10
black_and_white raster/src/adjustments.rs hcie-filter 1/10
threshold raster/src/adjustments.rs hcie-filter 1/10
posterize raster/src/adjustments.rs hcie-filter 1/10
invert raster/src/adjustments.rs hcie-filter 1/10
// Graphite: brightness_contrast (doğrudan kullanılabilir)
pub fn brightness_contrast(image: &Image, brightness: f32, contrast: f32) -> Image {
    // LUT-based implementation
    let mut output = image.clone();
    // ...
    output
}

Toplam: 11 yeni filter, hiçbir external bağımlılık gerektirmez.

3.2 Gaussian Blur — node-graph/nodes/raster/src/filter.rs

Graphite'in Gaussian blur'u two-pass separable ve gamma/sRGB-aware. HCIE'nin mevcut blur'undan daha kaliteli.

// İmza (doğrudan taşınabilir):
fn gaussian_blur(image: &Image, radius: f64) -> Image

Zorluk: 2/10

3.3 Dehaze (Dark Channel Prior) — node-graph/nodes/raster/src/dehaze.rs

Single-image dehazing algoritması, fotoğraf düzenlemede değerli bir özellik.

Zorluk: 3/10

3.4 Gradient Map — node-graph/nodes/raster/src/gradient_map.rs

Luminance değerlerini gradient color ramp üzerinden eşleyen algoritma.

Zorluk: 2/10

3.5 Procedural Pattern — node-graph/nodes/raster/src/std_nodes.rs

Perlin, OpenSimplex, Cellular, Value noise + Mandelbrot set renderer.

Zorluk: 3/10

3.6 Math Expression Parser — libraries/math-parser/

Birim destekli (px, cm, deg, rad, %) matematik ifade ayrıştırıcı. HCIE'de eklenti geliştirme veya brush boyutu/formül girişi için kullanılabilir.

Zorluk: 2/10 — PEG grammar + tree-walking executor Bağımlılık: pest parser (Cargo.toml'a eklenmeli)


4. Uyarlanarak Taşınabilecek Sistemler (Kategori 2: Adaptasyon Gerekli)

4.1 Node Graph Sistemi — node-graph/ (Stratejik)

Graphite'in en büyük farkı node-graph tabanlı olmasıdır. HCIE'ye node-graph eklemek uzun vadede büyük bir mimari değişikliktir ancak Graphite'in compiler ve executor'ı referans alınabilir:

Bileşen Dosya HCIE'ye Uyarlama
NodeNetwork graph-craft/src/document.rs Document modeline node graph eklenebilir
Compiler graph-craft/src/graphene_compiler.rs Flat → optimized graph dönüşümü
ProtoNetwork graph-craft/src/proto.rs Executable IR
DynamicExecutor interpreted-executor/src/dynamic_executor.rs Runtime execution
NodeRegistry interpreted-executor/src/node_registry.rs Node constructor registry

Ancak: Graphite'in node-graph sistemi oldukça karmaşıktır (~20K satır). HCIE'ye tam node-graph eklemek büyük bir projedir. Daha gerçekçi bir yaklaşım:

  • Filter chain pipeline: hcie-filter'de filter'ların birleştirilebildiği basit bir DAG sistemi
  • Adjustment layer: Node-graph'in en hafifi — sadece filter zinciri

Zorluk: 7/10 (tam port), 4/10 (basitleştirilmiş version)

4.2 Brush Engine — node-graph/nodes/brush/

Dosya İçerik
brush.rs BrushDaub (stamp generation), BrushStyle definition
brush_stroke.rs Stroke rendering, dab placement
brush_cache.rs Cached brush textures

HCIE'nin mevcut brush engine'i daha basit. Graphite'in brush'ı:

  • Stamp-based (fırça ucunu tekrar tekrar basar)
  • Spacing, rotation, scatter
  • Stroke interpolation

Uyarlama: hcie-brush-engine'e BrushStyle ve BrushDaub yapıları eklenebilir.

Zorluk: 5/10

4.3 Vector Path Boolean — node-graph/nodes/path-bool/

Union, Subtract, Intersection, Difference işlemleri. linesweeper kütüphanesi kullanır.

HCIE'nin hcie-vector crate'i şu an path boolean desteklemiyor. Graphite'in implementasyonu referans alınabilir.

Zorluk: 6/10

4.4 Tool Sistemi — editor/src/messages/tool/

Graphite'in tool sistemi message-passing üzerine kurulu. HCIE'nin mevcut tool sistemi (ToolState + match + CanvasWidget) daha basit.

Ödünç alınabilecek konseptler:

  • Tool input preprocessing (input_preprocessor/)
  • Tool message routing (tool_messages/)
  • Common functionality (common_functionality/) — snapping, guides, bounds

Zorluk: 5/10

4.5 Repeat/Grid — node-graph/nodes/repeat/

Count-based repeat + grid layout + radial repeat. HCIE'de pattern oluşturma için kullanılabilir.

Zorluk: 3/10


5. Mimari Fark Nedeniyle Portu Zor (Kategori 3: Referans Alınabilir)

Sistem Graphite Yaklaşımı HCIE Yaklaşımı Port Zorluğu
GUI WebAssembly + Svelte + WebGL egui/eframe (native) 9/10 — toolkit tamamen farklı
Message Bus Dispatcher + MessageHandler trait'leri EventBus<AppEvent> push/pop 7/10 — pattern farkı
Render WebGL compute shaders (WGSL) egui painter 9/10 — GPU pipeline farkı
Undo Node graph memoization + history KisHistory closure-based 6/10 — farklı yaklaşım
Layout Auto-layout widget tree (Svelte) egui immediate mode 8/10 — paradigma farkı
Font Loading Font loading + text-to-path fontdue 5/10 — mevcut sistem yeterli

6. Bağımsız Crate Olarak Alınabilecek Kütüphaneler

6.1 rawkit — Camera Raw Decoder

Dosya: libraries/rawkit/

Sony ARW formatları için ham fotoğraf decoder'ı. TIFF/IFD parsing, demosaicing, white balance, gamma correction.

Durum: Tamamen bağımsız crate, hiçbir Graphite bağımlılığı yok. HCIE'ye hcie-raw olarak eklenebilir.

Zorluk: 1/10 — sadece Cargo.toml'a ekle + FFI yok

6.2 dyn-any — Dynamic Type Erasure

Dosya: libraries/dyn-any/

DynAny trait + derive macro — 'static olmayan tiplerle çalışan type erasure kütüphanesi.

Durum: HCIE'nin mevcut dyn Any kullanımı için alternatif. Plugin sisteminde kullanılabilir.

Zorluk: 2/10 — mevcut projeye entegre edilebilir

6.3 math-parser — Matematik İfade Ayrıştırıcı

Dosya: libraries/math-parser/

Birim destekli matematik parser: 2cm + 3px, sin(45deg) * 100%

Durum: Brush boyutu, filtre parametreleri, transform girdileri için kullanılabilir.

Zorluk: 1/10 — pest bağımlılığı eklenmeli


7. Öncelikli Yol Haritası

Aşama 1: Quick Wins (1-2 hafta)

[ ] brightness_contrast, levels, hue_saturation → hcie-filter (11 yeni filter)
[ ] Gaussian blur (gamma-aware, two-pass) → hcie-filter
[ ] math-parser → hcie-gui-egui (opsiyonel bağımlılık)

Aşama 2: Orta Vadeli (2-4 hafta)

[ ] Gradient map → hcie-filter
[ ] Dehaze → hcie-filter
[ ] Procedural noise patterns → hcie-filter
[ ] Brush stroke rendering (brush_stroke.rs) → hcie-brush-engine

Aşama 3: Stratejik (1-3 ay)

[ ] Node graph compiler (basitleştirilmiş DAG filter chain)
[ ] rawkit → hcie-raw (bağımsız crate)
[ ] Vector path boolean → hcie-vector

Aşama 4: Uzun Vade (3+ ay)

[ ] Full node graph executor
[ ] Tool system redesign (message-passing)
[ ] Animation timeline

8. Graphite vs Krita: Hangisi Daha Faydalı?

Kriter Graphite (Rust) Krita (C++)
Dil uyumu Aynı dil (Rust) C++ → Rust çeviri
Algoritma kalitesi Orta — daha yeni, daha az test Yüksek — 20+ yıl olgunlaşma
Filter çeşitliliği Orta (~15 filter) Yüksek (30+ filter)
Brush engine Basit Çok gelişmiş
Renk yönetimi Temel ICC + CMS
Node graph Full implementation Yok
PSD uyumu Yok Kapsamlı
Camera Raw rawkit Yok
Port maliyeti Düşük (doğrudan kod) Yüksek (çeviri gerek)

Sonuç: Kısa vadede en hızlı kazanç Graphite'den gelir çünkü Rust kodunu doğrudan kopyalayıp HCIE'ye entegre edebilirsiniz. Krita ise uzun vadede daha olgun algoritmalar ve daha fazla çeşitlilik sunar. İdeal yaklaşım: önce Graphite'den hızlı kazanımlar, sonra Krita'dan seçilmiş portlar.


9. Graphite Source Tree Reference (Önemli Yollar)

Klasör İçerik HCIE Karşılığı
node-graph/nodes/raster/src/ Renk ayarları, blur, dehaze, gradient map, procedural patterns hcie-filter (doğrudan port)
node-graph/nodes/brush/ Brush stamp, stroke, cache hcie-brush-engine
node-graph/nodes/vector/ Path modifications, fill/stroke hcie-vector
node-graph/nodes/path-bool/ Boolean path ops hcie-vector (yeni modül)
node-graph/nodes/blending/ Opacity, blend mode manipulation hcie-blend (referans)
node-graph/nodes/text/ Font cache, text-to-path hcie-text (referans)
node-graph/nodes/math/ Math expression nodes math-parser + hcie-gui
node-graph/graph-craft/src/ Document node network, compiler Yok (yeni mimari)
node-graph/interpreted-executor/src/ Runtime executor Yok (yeni mimari)
libraries/dyn-any/ Type erasure Plugin sistemi
libraries/math-parser/ Expression parser GUI widget'ları
libraries/rawkit/ Camera raw decoder hcie-raw (yeni crate)
editor/src/ App layer: dispatcher, tools, messages hcie-gui-egui (farklı toolkit)