-
-
Notifications
You must be signed in to change notification settings - Fork 0
Math
Daynlight edited this page Dec 13, 2025
·
1 revision
Graphite includes a built-in math library for 2D/3D visualization and scripting. It provides essential types and functions for geometry, plotting, and mathematical operations.
Point class is used inside script for drawing single point. It is than added to plot.
namespace Graphite::Math {
class Point {
Point(std::array<float, 2> pos, std::array<float, 3> color);
std::array<float, 2> getPos();
void setPos(std::array<float, 2> pos);
std::array<float, 3> getColor();
void setColor(std::array<float, 3> color);
};
};- 2D/3D point representation.
- Color management for points.
Plot is our 2D canvas where we draw elements. We add others Math classes to cells.
namespace Graphite::Math{
class Plot2D{
public:
std::unordered_map<std::string, Graphite::Math::Point> point_cell;
private:
void drawPoint(Graphite::Math::Point point);
public:
Plot2D();
~Plot2D();
void draw();
};
};- Creating plot and adding points.
// 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 <stdio.h>
#include <math.h>
class Script : ScriptInterface{
Graphite::Math::Plot2D plot;
void Init(){
plot["1"] = Graphite::Math::Point({0.2f, 0.1f});
};
void Update(){
};
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;
};You can add your own math types and functions by creating packages (in future) or extending the library in your scripts. Also you can add any header files to scripts.
Graphite Wiki ยฉ 2025 Daynlight & Contributors
Licensed under the Apache License 2.0
- ๐ Home
- ๐ ๏ธ Installation
- ๐งโ๐ป Usage
- ๐ Tutorials
- ๐งโ๐ฌ Examples
- ๐ WritingScripts
- ๐ฆ PackageManager
- ๐งฎ Math
- ๐๏ธ APIReference
- ๐ผ๏ธ RenderingEngine
- ๐๏ธ Architecture
- ๐ Roadmap
- ๐ Versions
- ๐ ChangeLog
- ๐ค Community
- ๐ Credits
- ๐ Troubleshooting
- โ FAQ