Skip to content

Latest commit

 

History

History
235 lines (156 loc) · 4.96 KB

File metadata and controls

235 lines (156 loc) · 4.96 KB

⚪️ Graphite ⚪️

Simple, fast 2D/3D math visual app (like GeoGebra) using C++ scripting and hot-reloadable DLLs.

wakatime

About

Graphite is a lightweight 2D/3D math visualization app similar to GeoGebra or matplotlib, but built with C++ scripting and hot-reloadable DLLs for fast interactive development. It uses the author's rendering library CWindow.

Why it exists:

  • I dislike Python 🐍
  • GeoGebra can be slow 🐢
  • I enjoy building my own tools 💻
  • Learning & experimentation 🎓

Who it's for:

  • People who want a faster graphical math app ⚡
  • People who hate Python ❤️

Screenshots

Bezier Sin
Plots Lines

Table of Contents

Installation

git clone --recursive https://github.com/daynlight/Graphite.git
cd Graphite

mkdir -p build
cd build
cmake ..
cmake --build . --config Release
cd ..

cd bin/
sudo ./GraphiteInstaller

cd ../..

Usage

Run

  1. Start Graphite:
Graphite <flags> <path>
  1. Example script (Graphite.cpp)
// Graphite
// Copyright 2025 Daynlight
// Licensed under the Apache License, Version 2.0.
// See LICENSE file for details.


#define  BUILDING_SCRIPT_DLL
#include <Graphite/ScriptInterface.h>

#include <math.h>


class Script : ScriptInterface{

  Graphite::Math::Plot2D plot;


  void Init(){
    plot.point_cell["1"] = Graphite::Math::Point({-2.0f, 2.0f}, 0.2f);
    plot.point_cell["2"] = Graphite::Math::Point({1.0f, -5.0f}, 0.2f);
    plot.point_cell["3"] = Graphite::Math::Point({5.0f, 2.0f}, 0.2f);

    for(auto el : plot.point_cell)
      plot.line_cell[el.first] = Graphite::Math::Line({0, 0}, plot.point_cell[el.first].getPos(), 0.1f);
  };

  void Update(){
    plot.plotEvents();
  };

  void Draw(){
    plot.draw();
  };

  void Destroy(){

  };
};



extern "C" ScriptInterface* SCRIPT_API GetScript() {
  Script* script = new Script();
  return (ScriptInterface*)script;
};

extern "C" void SCRIPT_API DeleteScript(ScriptInterface* script) {
  Script* temp_script = (Script*)script;
  delete temp_script;
};

Flags

  • -h, --help — show program help
  • -i, --init — initialize default files
  • -s, --sandbox — enable sandbox mode (recommended for editing)
  • -v, -d, --verbose, --debug — verbose / debug output

Path

The final path is the last argument. If a filename is specified it will create a directory instead.

Important Note ⚠️

  • Use sandbox mode for development and live-editing to avoid crashes: Graphite -s <path> or Graphite -s -v <path>.
  • Sandbox runs the script in a fork for safer testing; if the script crashes, it won't take down the host process.
  • Always end all threads and free allocations in Destroy() to avoid leaks and undefined behavior.
  • When your script is stable, run in normal mode for better performance.
  • Sandbox performs an initial test run in the fork before the main execution to catch runtime issues early.

Prerequisites

  • CMake (for building)
  • C++17 (compiler)
  • Git (for cloning repo and submodules)

Versions and features

v2.0.0
  • Installer
  • Plots
  • Math Interface for Plots
  • Better Point Class
  • Line Class
  • Polynomial Class
  • Ui
  • Templates
v1.0.1
  • ScriptController edge-case handling
  • Sandbox mode now tests before execution
  • Edge-case fixes for Graphite, Flags, AppRenderer, ScriptLoader
v1.0.0
  • Sandbox mode
  • Script sandbox last-write detection
  • Separate CWindow renderer via AppRenderer
  • Safer script destroy
Prototype
  • Hot script loading
  • Help flag
  • Init flag
  • Verbose flag
  • Points rendering
  • Multiple point prints
  • Installation guide
  • Docs
  • Auto create path

Other Docs

Cat 🐱

cat