Skip to content

Commit 0e61968

Browse files
committed
refactor Color to PolyColor
we have a typealias for Color now
1 parent a0ce7b4 commit 0e61968

File tree

11 files changed

+38
-35
lines changed

11 files changed

+38
-35
lines changed

nanovg-impl/src/main/kotlin/org/polyfrost/polyui/renderer/impl/NVGRenderer.kt

+2-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import org.lwjgl.stb.STBImage
3232
import org.lwjgl.stb.STBImageResize
3333
import org.lwjgl.system.MemoryUtil
3434
import org.polyfrost.polyui.PolyUI
35-
import org.polyfrost.polyui.color.Color
35+
import org.polyfrost.polyui.color.PolyColor as Color
3636
import org.polyfrost.polyui.property.Settings
3737
import org.polyfrost.polyui.renderer.Renderer
3838
import org.polyfrost.polyui.renderer.data.Font
@@ -522,11 +522,7 @@ class NVGRenderer(width: Float, height: Float) : Renderer(width, height) {
522522
}
523523

524524
PolyImage.Type.Vector -> {
525-
val d = InputStreamReader(stream).use {
526-
val t = it.readText()
527-
it.close()
528-
t
529-
} as CharSequence
525+
val d = InputStreamReader(stream).readText()
530526
val svg = NanoSVG.nsvgParse(d, "px", 96f) ?: throw Exception("Failed to open SVG: $image (invalid data?)")
531527
val raster = NanoSVG.nsvgCreateRasterizer()
532528
val scale = if (image.width != -1f || image.height != -1f) {

nanovg-impl/src/test/java/org/polyfrost/polyui/JavaTest.java

+24-19
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111

1212
import java.util.ArrayList;
1313

14+
import org.polyfrost.polyui.color.PolyColor;
1415
import org.polyfrost.polyui.component.Drawable;
1516
import org.polyfrost.polyui.component.impl.Block;
1617
import org.polyfrost.polyui.component.impl.Image;
18+
import org.polyfrost.polyui.component.impl.Text;
1719
import org.polyfrost.polyui.event.MouseClicked;
20+
import org.polyfrost.polyui.input.Translator;
1821
import org.polyfrost.polyui.layout.Layout;
1922
import org.polyfrost.polyui.layout.impl.FlexLayout;
23+
import org.polyfrost.polyui.property.impl.BlockProperties;
24+
import org.polyfrost.polyui.property.impl.TextProperties;
2025
import org.polyfrost.polyui.renderer.data.PolyImage;
2126
import org.polyfrost.polyui.renderer.impl.GLWindow;
2227
import org.polyfrost.polyui.renderer.impl.NVGRenderer;
@@ -25,24 +30,24 @@
2530

2631
public class JavaTest {
2732
public static void main(String[] args) {
28-
// GLWindow window = new GLWindow("Java Window", 800, 800);
29-
// ArrayList<Drawable> things = new ArrayList<>(50);
30-
// for (int i = 0; i < 51; i++) { // creates 50 rectangles with random sizes
31-
// int finalI = i;
32-
// things.add(new Block(Units.flex(), new Vec2<>(Units.pixels(Math.random() * 40 + 40), Units.pixels(Math.random() * 40 + 40)), new MouseClicked(0).to(component -> {
33-
// System.out.println("Mouse clicked! " + finalI);
34-
// }), new MouseClicked(0, 2).to(component -> {
35-
// System.out.println("Mouse double-clicked! " + finalI);
36-
// }), new MouseClicked(1).to(component -> {
37-
// System.out.println("Mouse right clicked! " + finalI);
38-
// })));
39-
// }
40-
// PolyUI polyUI = new PolyUI("", new NVGRenderer(window.getWidth(), window.getHeight()), Layout.drawables(
41-
//new Text(PolyTranslator.localised("Java... rainbow! and image"), Units.pixels(32), Units.times(Units.pixels(20), Units.pixels(570))),
42-
// new Block(new BlockProperties(new Color.Gradient(new Color(1f, 0f, 0f), new Color(0f, 1f, 1f))), Units.times(Units.pixels(20), Units.pixels(600)), Units.times(Units.pixels(120), Units.pixels(120))),
43-
// new Block(new BlockProperties(new Color.Chroma(Units.seconds(5))), Units.times(Units.pixels(200), Units.pixels(600)), Units.times(Units.pixels(120), Units.pixels(120))),
44-
// new Image(new PolyImage("/s.png", 120, 120), Units.times(Units.pixels(380), Units.pixels(600))),
45-
// new FlexLayout(Units.times(Units.pixels(20), Units.pixels(30)), Units.percent(80), things.toArray(new Drawable[50]))));
46-
// window.open(polyUI);
33+
//GLWindow window = new GLWindow("Java Window", 800, 800);
34+
//ArrayList<Drawable> things = new ArrayList<>(50);
35+
//for (int i = 0; i < 51; i++) { // creates 50 rectangles with random sizes
36+
// int finalI = i;
37+
// things.add(new Block(Units.flex(), new Vec2<>(Units.pixels(Math.random() * 40 + 40), Units.pixels(Math.random() * 40 + 40)), new MouseClicked(0).to(component -> {
38+
// System.out.println("Mouse clicked! " + finalI);
39+
// }), new MouseClicked(0, 2).to(component -> {
40+
// System.out.println("Mouse double-clicked! " + finalI);
41+
// }), new MouseClicked(1).to(component -> {
42+
// System.out.println("Mouse right clicked! " + finalI);
43+
// })));
44+
//}
45+
//PolyUI polyUI = new PolyUI("", new NVGRenderer(window.getWidth(), window.getHeight()), Layout.drawables(
46+
// new Text(new TextProperties(), Translator.localised("Java... rainbow! and image"), Units.pixels(32), Units.times(Units.pixels(20), Units.pixels(570))),
47+
// new Block(new BlockProperties(), Units.times(Units.pixels(20), Units.pixels(600)), Units.times(Units.pixels(120), Units.pixels(120))),
48+
// new Block(new BlockProperties(), Units.times(Units.pixels(200), Units.pixels(600)), Units.times(Units.pixels(120), Units.pixels(120))),
49+
// new Image(new PolyImage("/s.png", 120, 120), Units.times(Units.pixels(380), Units.pixels(600))),
50+
// new FlexLayout(Units.times(Units.pixels(20), Units.pixels(30)), Units.percent(80), things.toArray(new Drawable[50]))));
51+
//window.open(polyUI);
4752
}
4853
}

nanovg-impl/src/test/kotlin/org/polyfrost/polyui/Test.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ package org.polyfrost.polyui
2323

2424
import org.polyfrost.polyui.animate.Animations
2525
import org.polyfrost.polyui.animate.keyframed
26-
import org.polyfrost.polyui.color.Color
26+
import org.polyfrost.polyui.color.PolyColor as Color
2727
import org.polyfrost.polyui.color.DarkTheme
2828
import org.polyfrost.polyui.color.LightTheme
2929
import org.polyfrost.polyui.component.Drawable
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
polyui.test=Kotlin... {}! and image
22
polyui.button=I am a button.
3-
polyui.text.default=Write something here...
3+
polyui.textinput.placeholder=Write something here...
44
polyfrost.copyright=© Polyfrost 2023. All rights reserved.
55
button.randomize=Randomize order
66
text.light=Flashbang mode
77
text.dark=Boring mode
8-
button.text=A {0} button
8+
button.text=A {0} button

skija-impl/src/main/kotlin/org/polyfrost/polyui/renderer/impl/SkijaRenderer.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
package org.polyfrost.polyui.renderer.impl
2323

2424
import org.jetbrains.skija.*
25-
import org.polyfrost.polyui.color.Color
25+
import org.polyfrost.polyui.color.PolyColor as Color
2626
import org.polyfrost.polyui.renderer.Renderer
2727
import org.polyfrost.polyui.renderer.data.Font
2828
import org.polyfrost.polyui.renderer.data.Framebuffer

src/main/kotlin/org/polyfrost/polyui/color/Color.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import org.polyfrost.polyui.utils.rgba
3737
* @see [Color.Gradient]
3838
* @see [Color.Chroma]
3939
*/
40-
open class Color @JvmOverloads constructor(hue: Float, saturation: Float, brightness: Float, alpha: Float = 1f) : Cloneable {
40+
open class PolyColor @JvmOverloads constructor(hue: Float, saturation: Float, brightness: Float, alpha: Float = 1f) : Cloneable {
4141

4242
var hue = hue
4343
set(value) {
@@ -493,3 +493,5 @@ open class Color @JvmOverloads constructor(hue: Float, saturation: Float, bright
493493
override val alwaysUpdates get() = true
494494
}
495495
}
496+
497+
typealias Color = PolyColor

src/main/kotlin/org/polyfrost/polyui/component/Component.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import org.polyfrost.polyui.PolyUI.Companion.INIT_SETUP
3030
import org.polyfrost.polyui.animate.Animation
3131
import org.polyfrost.polyui.animate.Animations
3232
import org.polyfrost.polyui.animate.KeyFrames
33-
import org.polyfrost.polyui.color.Color
33+
import org.polyfrost.polyui.color.PolyColor as Color
3434
import org.polyfrost.polyui.color.Colors
3535
import org.polyfrost.polyui.event.*
3636
import org.polyfrost.polyui.layout.Layout

src/main/kotlin/org/polyfrost/polyui/component/impl/Block.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
package org.polyfrost.polyui.component.impl
2323

2424
import org.polyfrost.polyui.PolyUI
25-
import org.polyfrost.polyui.color.Color
25+
import org.polyfrost.polyui.color.PolyColor as Color
2626
import org.polyfrost.polyui.color.Colors
2727
import org.polyfrost.polyui.component.Component
2828
import org.polyfrost.polyui.event.EventDSL

src/main/kotlin/org/polyfrost/polyui/component/impl/Dropdown.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ package org.polyfrost.polyui.component.impl
2424
import org.polyfrost.polyui.PolyUI
2525
import org.polyfrost.polyui.PolyUI.Companion.INIT_NOT_STARTED
2626
import org.polyfrost.polyui.animate.Animation
27-
import org.polyfrost.polyui.color.Color
27+
import org.polyfrost.polyui.color.PolyColor as Color
2828
import org.polyfrost.polyui.component.ContainingComponent
2929
import org.polyfrost.polyui.component.DrawableOp
3030
import org.polyfrost.polyui.component.Focusable

src/main/kotlin/org/polyfrost/polyui/component/impl/Slider.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ package org.polyfrost.polyui.component.impl
2323

2424
import org.polyfrost.polyui.PolyUI
2525
import org.polyfrost.polyui.PolyUI.Companion.INIT_COMPLETE
26-
import org.polyfrost.polyui.color.Color
26+
import org.polyfrost.polyui.color.PolyColor as Color
2727
import org.polyfrost.polyui.color.Colors
2828
import org.polyfrost.polyui.component.Component
2929
import org.polyfrost.polyui.event.Event

src/main/kotlin/org/polyfrost/polyui/component/impl/Switch.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ package org.polyfrost.polyui.component.impl
2323

2424
import org.polyfrost.polyui.PolyUI
2525
import org.polyfrost.polyui.animate.Animation
26-
import org.polyfrost.polyui.color.Color
26+
import org.polyfrost.polyui.color.PolyColor as Color
2727
import org.polyfrost.polyui.color.Colors
2828
import org.polyfrost.polyui.event.EventDSL
2929
import org.polyfrost.polyui.input.PolyText

0 commit comments

Comments
 (0)