Add the Trianglix Desktop Environment.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-03-16 22:40:02 +01:00
parent 9e67c78271
commit b4a74a93ad
6 changed files with 2139 additions and 0 deletions

View File

@ -20,6 +20,7 @@ mkinitrd \
regress \
sh \
tix \
trianglix \
utils \
kernel

View File

@ -196,6 +196,7 @@ Sortix comes with a number of home-made programs. Here is an overview:
* `sort` - sort lines of text files
* `tail` - display end of file
* `time` - measure program running time
* `trianglix` - triangle system
* `tr` - translate, squeeze and/or delete characters
* `true` - exit with a success status
* `type` - type raw characters directly into the terminal
@ -371,6 +372,10 @@ Graphical User Interface
The `dispd` display server is still under development. Sortix does not feature
any documented graphical user interface at the moment.
Sortix comes with the orthogonal graphical multi-user revolutionary triangle
system Trianglix, an attempt at making the most foreign yet somehow usable user
interface. You just need to run `trianglix` to start it.
Network
-------

1
trianglix/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
trianglix

27
trianglix/Makefile Normal file
View File

@ -0,0 +1,27 @@
SOFTWARE_MEANT_FOR_SORTIX=1
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=-g -O2
CXXFLAGS?=$(OPTLEVEL)
CXXFLAGS:=$(CXXFLAGS) -std=gnu++0x -Wall -Wextra -fno-exceptions -fno-rtti -msse -msse2
BINARY:=trianglix
LIBS:=-ldispd
all: $(BINARY)
.PHONY: all install uninstall clean
install: all
mkdir -p $(DESTDIR)$(BINDIR)
install $(BINARY) $(DESTDIR)$(BINDIR)
%: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(LIBS)
clean:
rm -f $(BINARY) *.o

1973
trianglix/trianglix.cpp Normal file

File diff suppressed because it is too large Load Diff

132
trianglix/vector.h Normal file
View File

@ -0,0 +1,132 @@
#ifndef VECTOR_H
#define VECTOR_H
class Vector
{
public:
float x;
float y;
float z;
public:
Vector(float x = 0.f, float y = 0.f, float z = 0.f) : x(x), y(y), z(z) { }
Vector& operator=(const Vector& rhs)
{
if ( this != &rhs ) { x = rhs.x; y = rhs.y; z = rhs.z; }
return *this;
}
Vector& operator+=(const Vector& rhs)
{
x += rhs.x;
y += rhs.y;
z += rhs.z;
return *this;
}
Vector& operator-=(const Vector& rhs)
{
x -= rhs.x;
y -= rhs.y;
z -= rhs.z;
return *this;
}
Vector& operator*=(float scalar)
{
x *= scalar;
y *= scalar;
z *= scalar;
return *this;
}
Vector& operator/=(float scalar)
{
x /= scalar;
y /= scalar;
z /= scalar;
return *this;
}
const Vector operator+(const Vector& other) const
{
Vector ret(*this); ret += other; return ret;
}
const Vector operator-(const Vector& other) const
{
Vector ret(*this); ret -= other; return ret;
}
const Vector operator*(float scalar) const
{
Vector ret(*this); ret *= scalar; return ret;
}
const Vector operator/(float scalar) const
{
Vector ret(*this); ret /= scalar; return ret;
}
bool operator==(const Vector& other) const
{
return x == other.x && y == other.y && z == other.z;
}
bool operator!=(const Vector& other) const
{
return !(*this == other);
}
float Dot(const Vector& other) const
{
return x * other.x + y * other.y + z * other.z;
}
const Vector Cross(const Vector& other) const
{
Vector ret(y * other.z - z * other.y,
z * other.x - x * other.z,
x * other.y - y * other.x);
return ret;
}
float SquaredSize() const
{
return x*x + y*y + z*z;
}
float Size() const
{
return sqrtf(SquaredSize());
}
float DistanceTo(const Vector& other) const
{
return (other - *this).Size();
}
const Vector Normalize() const
{
float size = Size();
if ( size == 0.0 ) { size = 1.0f; }
return *this / size;
}
const Vector Rotate2D(float radians) const
{
float sinr = sinf(radians);
float cosr = cosf(radians);
float newx = x * cosr - y * sinr;
float newy = x * sinr + y * cosr;
return Vector(newx, newy);
}
const Vector Rotate2DAround(float radians, const Vector& off) const
{
return Vector(*this - off).Rotate2D(radians) + off;
}
};
#endif