java.lang.Object
com.example.brickpaint.ArtMath
Handles the math required to draw various shapes on the canvas in different directions
- Author:
- matde
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancompare(double value1, double value2, double range) Takes two points on a line and a value, if that value is between the two points the method returns truestatic voidDrawCircle(double x1, double y1, double x2, double y2, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws a Circle in the desired direction based on the cursor locationstatic voidDrawOval(double x1, double y1, double x2, double y2, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws an oval in the desired direction based on the cursor locationstatic voidDrawPoly(double x1, double y1, double x2, double y2, int sides, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws a Polygon in the desired direction based on the cursor locationstatic voidDrawRect(double x1, double y1, double x2, double y2, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws a Rectangle in the desired direction based on the cursor locationstatic voidDrawRoundedRect(double x1, double y1, double x2, double y2, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws a Rectangle in the desired direction based on the cursor locationstatic voidDrawSquare(double x1, double y1, double x2, double y2, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws a Square in the desired direction based on the cursor locationstatic javafx.geometry.Point2DgetTopLeft(double x1, double y1, double x2, double y2) Takes in two points on a rectangle and will return the value of the top left point of the ractangle
-
Constructor Details
-
ArtMath
public ArtMath()
-
-
Method Details
-
DrawRect
public static void DrawRect(double x1, double y1, double x2, double y2, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws a Rectangle in the desired direction based on the cursor location- Parameters:
x1- start x cordy1- start y cordx2- mouse x cordy2- mouse y cordgc- the graphics content to draw the shape onfill- boolean to determine if the shape should be filled in
-
DrawRoundedRect
public static void DrawRoundedRect(double x1, double y1, double x2, double y2, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws a Rectangle in the desired direction based on the cursor location- Parameters:
x1- start x cordy1- start y cordx2- mouse x cordy2- mouse y cordgc- the graphics content to draw the shape onfill- boolean to determine if the shape should be filled in
-
DrawSquare
public static void DrawSquare(double x1, double y1, double x2, double y2, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws a Square in the desired direction based on the cursor location- Parameters:
x1- start x cordy1- start y cordx2- mouse x cordy2- mouse y cordgc- the graphics content to draw the shape onfill- boolean to determine if the shape should be filled in
-
DrawCircle
public static void DrawCircle(double x1, double y1, double x2, double y2, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws a Circle in the desired direction based on the cursor location- Parameters:
x1- start x cordy1- start y cordx2- mouse x cordy2- mouse y cordgc- the graphics content to draw the shape onfill- boolean to determine if the shape should be filled in
-
DrawOval
public static void DrawOval(double x1, double y1, double x2, double y2, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws an oval in the desired direction based on the cursor location- Parameters:
x1- start x cordy1- start y cordx2- mouse x cordy2- mouse y cordgc- the graphics content to draw the shape onfill- boolean to determine if the shape should be filled in
-
DrawPoly
public static void DrawPoly(double x1, double y1, double x2, double y2, int sides, javafx.scene.canvas.GraphicsContext gc, boolean fill) Draws a Polygon in the desired direction based on the cursor location- Parameters:
x1- start x cordy1- start y cordx2- mouse x cordy2- mouse y cordsides- number of sides polygon should havegc- the graphics content to draw the shape onfill- boolean to determine if the shape should be filled in
-
compare
public static boolean compare(double value1, double value2, double range) Takes two points on a line and a value, if that value is between the two points the method returns true- Parameters:
value1- first pointvalue2- second pointrange- value to test- Returns:
- true if value is within range false if not
-
getTopLeft
public static javafx.geometry.Point2D getTopLeft(double x1, double y1, double x2, double y2) Takes in two points on a rectangle and will return the value of the top left point of the ractangle- Parameters:
x1- point 1 xy1- point 1 yx2- point 2 xy2- point 2 y- Returns:
- Point2D corresponding to the top left of the rectangle
-