[API] Add arithmetic ops to ImVec2 and ImVec4

- plus
- minus
- times
This commit is contained in:
SpaiR committed 2022-12-19 11:30:51 +02:00
1 parent a2bacb292e
commit 47baed3b42
4 files changed
+308 -32

No files matched your search

+43 -14
View File
@@ -3,7 +3,7 @@ package imgui;
import java.util.Objects;
/**
* 2D vector (often used to store positions or sizes)
* 2D vector (often used to store positions or sizes).
*/
public final class ImVec2 implements Cloneable {
public float x;
@@ -12,24 +12,52 @@ public final class ImVec2 implements Cloneable {
public ImVec2() {
}
public ImVec2(final ImVec2 imVec2) {
this.x = imVec2.x;
this.y = imVec2.y;
}
public ImVec2(final float x, final float y) {
this.x = x;
this.y = y;
set(x, y);
}
public void set(final float x, final float y) {
this.x = x;
this.y = y;
public ImVec2(final ImVec2 value) {
this(value.x, value.y);
}
public void set(final ImVec2 value) {
this.x = value.x;
this.y = value.y;
public ImVec2 set(final float x, final float y) {
this.x = x;
this.y = y;
return this;
}
public ImVec2 set(final ImVec2 value) {
return set(value.x, value.y);
}
public ImVec2 plus(final float x, final float y) {
this.x += x;
this.y += y;
return this;
}
public ImVec2 plus(final ImVec2 value) {
return plus(value.x, value.y);
}
public ImVec2 minus(final float x, final float y) {
this.x -= x;
this.y -= y;
return this;
}
public ImVec2 minus(final ImVec2 value) {
return minus(value.x, value.y);
}
public ImVec2 times(final float x, final float y) {
this.x *= x;
this.y *= y;
return this;
}
public ImVec2 times(final ImVec2 value) {
return times(value.x, value.y);
}
@Override
@@ -58,6 +86,7 @@ public final class ImVec2 implements Cloneable {
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImVec2 clone() {
return new ImVec2(this);
}
+47 -18
View File
@@ -3,7 +3,7 @@ package imgui;
import java.util.Objects;
/**
* 4D vector (often used to store floating-point colors)
* 4D vector (often used to store floating-point colors).
*/
public final class ImVec4 implements Cloneable {
public float x;
@@ -14,32 +14,60 @@ public final class ImVec4 implements Cloneable {
public ImVec4() {
}
public ImVec4(final ImVec4 imVec4) {
this.x = imVec4.x;
this.y = imVec4.y;
this.z = imVec4.z;
this.w = imVec4.w;
}
public ImVec4(final float x, final float y, final float z, final float w) {
set(x, y, z, w);
}
public ImVec4(final ImVec4 value) {
this(value.x, value.y, value.z, value.w);
}
public ImVec4 set(final float x, final float y, final float z, final float w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
return this;
}
public void set(final float x, final float y, final float z, final float w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
public ImVec4 set(final ImVec4 value) {
return set(value.x, value.y, value.z, value.w);
}
public void set(final ImVec4 value) {
this.x = value.x;
this.y = value.y;
this.z = value.z;
this.w = value.w;
public ImVec4 plus(final float x, final float y, final float z, final float w) {
this.x += x;
this.y += y;
this.z += z;
this.w += w;
return this;
}
public ImVec4 plus(final ImVec4 value) {
return plus(value.x, value.y, value.z, value.w);
}
public ImVec4 minus(final float x, final float y, final float z, final float w) {
this.x -= x;
this.y -= y;
this.z -= z;
this.w -= w;
return this;
}
public ImVec4 minus(final ImVec4 value) {
return minus(value.x, value.y, value.z, value.w);
}
public ImVec4 times(final float x, final float y, final float z, final float w) {
this.x *= x;
this.y *= y;
this.z *= z;
this.w *= w;
return this;
}
public ImVec4 times(final ImVec4 value) {
return times(value.x, value.y, value.z, value.w);
}
@Override
@@ -70,6 +98,7 @@ public final class ImVec4 implements Cloneable {
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImVec4 clone() {
return new ImVec4(this);
}