Files
hcie-rust-v3.05/hcie-draw
phantom 07a9b35208 feat: Add theme and font management for egui GUI
- Introduced `theme.rs` to handle visual themes, font discovery, and application of theme colors.
- Implemented system font registration for Linux, macOS, and Windows.
- Added `apply_theme` function to configure egui visuals based on selected theme presets.

feat: Implement interactive tool state management

- Created `tool_state.rs` to manage runtime tool, selection, and transform states.
- Defined `ToolState` struct to encapsulate active tool, color settings, drawing states, and AI panel states.
- Included functionality for managing brush presets, text editing, and selection transformations.

feat: Add utility functions for image and file handling

- Developed `utils.rs` with stateless helper functions for color formatting, drawing icons, and cropping images.
- Implemented save dialog builders and error handling for file operations.
- Added flood fill functionality for composite RGBA pixels.

test: Add unit test for bitmap brush stamp functionality

- Created `bitmap_brush_stamp.rs` to verify the behavior of bitmap brush stamping in the engine.
- Ensured that the painted area matches expected dimensions and characteristics.
2026-07-10 01:23:47 +03:00
..
2026-07-09 02:59:53 +03:00
2026-07-09 02:59:53 +03:00
2026-07-09 02:59:53 +03:00
2026-07-09 02:59:53 +03:00

hcie-draw Projesi Nedir?

hcie-draw, HCIE (HC Image Editor) Rust port'unun bir parçası olan raster çizim motoru kütüphanesidir.

Projenin Amacı

Bu kütüphane, RGBA piksel buffer'ları üzerine vektörel çizim araçlarını (çizgi, daire, elips, dikdörten, flood fill) ve fırça darbelerini (pressure-aware brush strokes) rasterize eder. Pure Rust ile yazılmış, GUI'den bağımsız bir çekirdek kütüphane.


Mimari Yapı (Katman Bakışı)

┌─────────────────────────────┐
│  hcie-core-app (Tauri GUI)  │ ← Svelte frontend + Rust backend
├─────────────────────────────┤
│  hcie-engine-api            │ ← Public API & command bridge
├─────────────────────────────┤
│  hcie-draw (bu crate)       │ ← Rasterization motoru
│  ├─ Layer                   │   • Pixel buffer yönetimi
│  ├─ draw_line/circle/ellipse│   • Primitif çizim fonksiyonları
│  ├─ draw_brush_stroke        │   • Pressure-aware fırça
│  └─ C FFI exports           │   • Zero-copy native arayüz
├─────────────────────────────┤
│  hcie-blend                │ ← Blend modları (Normal, Multiply, vb.)
│  hcie-brush-engine         │ ← Fırça tipi, spacing, jitter
└─────────────────────────────┘

Ana Bileşenler

Layer struct'ı:

pub struct Layer {
    pub name: String,
    pub pixels: Vec<u8>,     // RGBA format (4 bayt/piksel)
    pub width: u32,
    pub height: u32,
    pub visible: bool,
    pub opacity: f32,
    pub dirty: bool,         // Render invalidation flag
}

Çizim fonksiyonları:

Fonksiyon Açıklama
draw_line() Xiaolin Wu algoritmasıyla AA çizgi
draw_filled_circle() Doldurulmuş daire (kenar geçişli)
draw_filled_rect() Doldurulmuş dikdörtgen
draw_filled_ellipse() Doldurulmuş elips
flood_fill() Bağlamsız renk değiştirme
draw_brush_stamp() Tek fırça dampası
draw_brush_stroke() Tüm noktalar boyunca fırça izi

Çalışma Mantığı

  1. Piksel Erişimi: get_pixel() / set_pixel() ile RGBA okuma-yazma
  2. Blend Entegrasyonu: hcie_blend::blend_pixels() ile renk karıştırma
  3. Brush Entegrasyonu: hcie_brush_engine::draw_dab_capped() ile fırça tipi uygulama
  4. Mask Desteği: Opsiyonel selection mask (0-255) ile çizim sınırlandırma

Pressure-aware brush stroke akışı:

Input: points = [(x, y, pressure), ...]
    ↓
brush_spacing_pixels() → spacing hesapla
    ↓
Her segment için interpolate → pressure değişimi
    ↓
jitter_offset() → pozisyon rastgelelik
    ↓
draw_dab_capped() → fırça dampası render et

C FFI Arayüzü

Kütüphane cdylib olarak derlenir, bu sayede başka dillerden doğrudan çağrılabilir:

// draw_line_c - raw buffer pointer alır, in-place değiştirir
void draw_line_c(
    uint8_t* pixels, uint32_t width, uint32_t height,
    float x0, float y0, float x1, float y1,
    const uint8_t* color_rgba, float line_thickness,
    const uint8_t* mask
);

Diğer FFI fonksiyonları: draw_filled_rect_c, draw_filled_circle_c, flood_fill_c, draw_brush_stroke_c


Kullanım Örkeli

Test runner'ı çalıştırmak:

cargo test --manifest-path tests/draw_pixels.rs

GUI testörünü çalıştırmak:

cargo run --example draw_tester

Bağımlılıklar

[dependencies]
hcie-blend        = { path = "../hcie-blend" }   # blend_pixels
hcie-brush-engine = { path = "../hcie-brush-engine" }  # brush tip & spacing

Özellikler

  • Zero-copy FFI: Buffer kopyası yok, doğrudan pointer manipülasyonu
  • GUI bağımsız: Pure Rust, egui/tauri olmadan da kullanılabilir
  • Multi-threading hazır: rayon entegrasyonu (blend katmanında)
  • 30+ fırça stıl: BrushStyle enum'ı içinde (Round, Pencil, Oil, Watercolor, vb.)