Skip to content

Commit fb9f1b9

Browse files
committed
1.20
1 parent 6066b43 commit fb9f1b9

File tree

6 files changed

+150
-27
lines changed

6 files changed

+150
-27
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66

77
group 'dev.felnull'
88
archivesBaseName = "felnull-java-library"
9-
version '1.19'
9+
version '1.20'
1010

1111
repositories {
1212
mavenCentral()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.felnull.fnjl;
22

33
public class BuildIn {
4-
protected static final String VERSION = "1.19";
4+
protected static final String VERSION = "1.20";
55

66
protected static final int NATIVE_LIB_VERSION = 2;
77
}

src/main/java/dev/felnull/fnjl/math/FNVec2d.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dev.felnull.fnjl.math;
22

3+
import java.util.Objects;
4+
35
public class FNVec2d {
46
private double x;
57
private double y;
@@ -24,4 +26,41 @@ public void setX(double x) {
2426
public void setY(double y) {
2527
this.y = y;
2628
}
29+
30+
public double distance(FNVec2i vec) {
31+
return Math.sqrt(Math.pow(x - vec.getX(), 2) + Math.pow(y - vec.getY(), 2));
32+
}
33+
34+
public FNVec2d add(FNVec2d vec) {
35+
this.x += vec.getX();
36+
this.y += vec.getY();
37+
return this;
38+
}
39+
40+
public FNVec2d sub(FNVec2d vec) {
41+
this.x -= vec.getX();
42+
this.y -= vec.getY();
43+
return this;
44+
}
45+
46+
@Override
47+
public boolean equals(Object o) {
48+
if (this == o) return true;
49+
if (o == null || getClass() != o.getClass()) return false;
50+
FNVec2d fnVec2d = (FNVec2d) o;
51+
return Double.compare(fnVec2d.x, x) == 0 && Double.compare(fnVec2d.y, y) == 0;
52+
}
53+
54+
@Override
55+
public int hashCode() {
56+
return Objects.hash(x, y);
57+
}
58+
59+
@Override
60+
public String toString() {
61+
return "FNVec2d{" +
62+
"x=" + x +
63+
", y=" + y +
64+
'}';
65+
}
2766
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package dev.felnull.fnjl.math;
2+
3+
import java.util.Objects;
4+
5+
public class FNVec2f {
6+
private float x;
7+
private float y;
8+
9+
public FNVec2f(float x, float y) {
10+
this.x = x;
11+
this.y = y;
12+
}
13+
14+
public float getX() {
15+
return x;
16+
}
17+
18+
public float getY() {
19+
return y;
20+
}
21+
22+
public void setY(float y) {
23+
this.y = y;
24+
}
25+
26+
public void setX(float x) {
27+
this.x = x;
28+
}
29+
30+
public double distance(FNVec2i vec) {
31+
return Math.sqrt(Math.pow(x - vec.getX(), 2) + Math.pow(y - vec.getY(), 2));
32+
}
33+
34+
public FNVec2f add(FNVec2f vec) {
35+
this.x += vec.getX();
36+
this.y += vec.getY();
37+
return this;
38+
}
39+
40+
public FNVec2f sub(FNVec2f vec) {
41+
this.x -= vec.getX();
42+
this.y -= vec.getY();
43+
return this;
44+
}
45+
46+
@Override
47+
public String toString() {
48+
return "FNVec2f{" +
49+
"x=" + x +
50+
", y=" + y +
51+
'}';
52+
}
53+
54+
@Override
55+
public boolean equals(Object o) {
56+
if (this == o) return true;
57+
if (o == null || getClass() != o.getClass()) return false;
58+
FNVec2f fnVec2f = (FNVec2f) o;
59+
return Float.compare(fnVec2f.x, x) == 0 && Float.compare(fnVec2f.y, y) == 0;
60+
}
61+
62+
@Override
63+
public int hashCode() {
64+
return Objects.hash(x, y);
65+
}
66+
}

src/main/java/dev/felnull/fnjl/math/FNVec2i.java

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dev.felnull.fnjl.math;
22

3+
import java.util.Objects;
4+
35
public class FNVec2i {
46
private int x;
57
private int y;
@@ -17,11 +19,48 @@ public int getY() {
1719
return y;
1820
}
1921

22+
public void setX(int x) {
23+
this.x = x;
24+
}
25+
2026
public void setY(int y) {
2127
this.y = y;
2228
}
2329

24-
public void setX(int x) {
25-
this.x = x;
30+
public double distance(FNVec2i vec) {
31+
return Math.sqrt(Math.pow(x - vec.getX(), 2) + Math.pow(y - vec.getY(), 2));
32+
}
33+
34+
public FNVec2i add(FNVec2i vec) {
35+
this.x += vec.getX();
36+
this.y += vec.getY();
37+
return this;
38+
}
39+
40+
public FNVec2i sub(FNVec2i vec) {
41+
this.x -= vec.getX();
42+
this.y -= vec.getY();
43+
return this;
44+
}
45+
46+
@Override
47+
public boolean equals(Object o) {
48+
if (this == o) return true;
49+
if (o == null || getClass() != o.getClass()) return false;
50+
FNVec2i fnVec2i = (FNVec2i) o;
51+
return x == fnVec2i.x && y == fnVec2i.y;
52+
}
53+
54+
@Override
55+
public int hashCode() {
56+
return Objects.hash(x, y);
57+
}
58+
59+
@Override
60+
public String toString() {
61+
return "FNVec2i{" +
62+
"x=" + x +
63+
", y=" + y +
64+
'}';
2665
}
2766
}
Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
11
package dev.felnull;
22

3-
import dev.felnull.fnjl.util.FNMath;
4-
5-
import javax.imageio.ImageIO;
6-
import java.awt.*;
7-
import java.awt.image.BufferedImage;
8-
import java.nio.file.Paths;
3+
import dev.felnull.fnjl.math.FNVec2i;
94

105
public class TestMain {
116
public static void main(String[] args) throws Exception {
12-
ImageIO.write(generateMandelbrotCL(500, 500, 0, 0, 1), "png", Paths.get("test\\test.png").toFile());
13-
}
14-
15-
public static BufferedImage generateMandelbrot(int width, int height, double posX, double posY, double zoom) {
16-
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
17-
FNMath.generateMandelbrotSet(width, height, posX, posY, zoom, 20, n -> {
18-
image.setRGB(n.getX(), n.getY(), 0xFFFFFF);
19-
});
20-
return image;
21-
}
22-
23-
public static BufferedImage generateMandelbrotCL(int width, int height, double posX, double posY, double zoom) {
24-
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
25-
FNMath.generateColorMandelbrot(width, height, posX, posY, zoom, 10, n -> {
26-
image.setRGB(n.getPos().getX(), n.getPos().getY(), Color.HSBtoRGB((float) n.getColor() / 10, 1, 1));
27-
});
28-
return image;
7+
System.out.println(new FNVec2i(0, 0).distance(new FNVec2i(1, 1)));
298
}
309
}

0 commit comments

Comments
 (0)