Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into atomic_blocks
  • Loading branch information
connorslade committed Sep 17, 2023
2 parents f7e9e18 + 2fd051f commit 0187f4e
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 12 deletions.
53 changes: 50 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
# Project exclude paths
out
build
.doc
.tmp
.gradle
bin

# github java .gitignore
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

# github gradle .gitignore
.gradle
**/build/
!src/**/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Avoid ignore Gradle wrappper properties
!gradle-wrapper.properties

# Cache of project
.gradletasknamecache

# Eclipse Gradle plugin generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ https://user-images.githubusercontent.com/48413902/223738287-396ffca5-8bcd-48a8-

https://user-images.githubusercontent.com/48413902/224180302-c79f398b-5772-42b3-9aa5-6139518b5d22.mp4

[javadoc]: https://aspiringlich.github.io/PaintingCanvas/paintingcanvas/package-summary.html
[javadoc]: https://aspiringlich.github.io/PaintingCanvas
46 changes: 43 additions & 3 deletions src/main/java/paintingcanvas/drawable/Drawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,22 @@ public T setColor(int r, int g, int b) {
return this.setColor(new Color(r, g, b));
}

/**
* Set the color of the element with <a href="https://en.wikipedia.org/wiki/RGBA_color_model">RGBA</a>.
* <pre>{@code
* Circle o = new Circle(100, 100, 20);
* o.setColor(255, 0, 0); // Set color to red
* }</pre>
*
* @param r The red component of the color (0-255)
* @param g The green component of the color (0-255)
* @param b The blue component of the color (0-255)
* @return The original object to allow method chaining
*/
public T setColor(int r, int g, int b, int a) {
return this.setColor(new Color(r, g, b, a));
}

/**
* Get the current color of an element as a {@link Color}
*
Expand All @@ -429,19 +445,43 @@ public T setColor(Color color) {
return getThis();
}

/**
* Set the color of the object with a {@link Hue} object.
* <pre>{@code
* Circle o = new Circle(100, 100, 20);
* o.setColor(Hue.GREEN); // Set color to red
* }</pre>
*
* @param color color.
* @return The original object to allow method chaining
*/
public T setColor(Hue hue) {
synchronized (Canvas.drawableSync) {
this.color = hue.getColor();
}
return getThis();
}

/**
* Set the color of the object with a certain color by name
* Set the color of the object with a certain color by name, or by a <a href="https://en.wikipedia.org/wiki/RGB_color_model">hex code</a>. string.
* (see {@link Hue} for list of all valid names)
* <pre>{@code
* Circle o = new Circle(100, 100, 20);
* o.setColor("red"); // Set color to red
* // #FF0000 is hex for (255, 0, 0), which is red
* o.setColor("#FF0000"); // Set color to red, in a different way
* }</pre>
*
* @param color The name of the color (case-insensitive)
* @return The original object to allow method chaining
*/
public T setColor(String color) {
return setColor(Hue.getColor(color));
public T setColor(String name) {
try {
var color = Color.decode(name);
return setColor(color);
} catch (Exception e) {
return setColor(Hue.getColor(name));
}
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/paintingcanvas/drawable/Triangle.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public class Triangle extends Drawable<Triangle> {
*/
public int height;

private Polygon poly;

/**
* Create a new Triangle element.
* <pre>{@code
Expand Down Expand Up @@ -144,4 +142,4 @@ protected void drawOutline(Graphics2D gc) {
protected Triangle getThis() {
return this;
}
}
}
1 change: 0 additions & 1 deletion src/main/java/paintingcanvas/extensions/InfoDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import paintingcanvas.canvas.RenderLifecycle;

import java.awt.*;
import java.awt.image.BufferedImage;

/**
* Displays some information on the screen, such as
Expand Down
1 change: 0 additions & 1 deletion src/test/java/examples/Tessellation.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ void draw(int x, int y) {
var height = Const.height;

var p1 = new Point(-size / 2, -height);
var p2 = new Point(size / 2, -height);

path = new Path().setPos(x, y);
outline = new Path().setPos(x, y);
Expand Down

0 comments on commit 0187f4e

Please sign in to comment.