Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Massively overhaul Drawable classes #10

Open
9 of 14 tasks
lucasstarsz opened this issue Apr 23, 2021 · 4 comments
Open
9 of 14 tasks

[Feature Request] Massively overhaul Drawable classes #10

lucasstarsz opened this issue Apr 23, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@lucasstarsz
Copy link
Member

lucasstarsz commented Apr 23, 2021

Is your feature request related to a problem? Please describe.

As part of the massive performance, feature, and structural overhaul needed to propel FastJ into 2.0, we need an incredibly strong and flexible foundation. As such, this issue is opened to describe the many things needed in order to consider the engine ready for a more useful UI system, among other things.

What should the solution be like?

This is the list of features currently expected as a bare minimum in order to proceed:

General Model Loading

Text2D

  • Improve Text2D with vector graphics/attribute modifiers
  • Support to read/write Text2D to tsdf/svg

Polygon2D

  • Improve Polygon2D with more paint options/outline options
  • Add extra options for working with complex curves (beziers)
  • Add option to create Polygon2D from Path2D instance

Drawable


If you have any suggestions for other features, please leave a comment down below explaining. Progress of this will be tracked in the drawable branch.

@lucasstarsz lucasstarsz added the enhancement New feature or request label Apr 23, 2021
@lucasstarsz lucasstarsz self-assigned this Apr 23, 2021
@nt314p
Copy link

nt314p commented Apr 25, 2021

Perhaps a function or class to set a certain pixel on screen (hopefully will be more performant than drawing a 1x1 rect).
Ability to draw arcs (psdf support and Polygon2D support).

Also is it feasible to add a Polygon2D constructor that takes a Path2D?

@lucasstarsz
Copy link
Member Author

lucasstarsz commented Apr 26, 2021

Perhaps a function or class to set a certain pixel on screen (hopefully will be more performant than drawing a 1x1 rect).

I can't currently guarantee that this will be very performant, unfortunately, but I think it would be worth a shot.

Ability to draw arcs (psdf support and Polygon2D support).

This is included (but not specified -- my bad!) with the improvements all around for the Polygon2D class and model loading.

Also is it feasible to add a Polygon2D constructor that takes a Path2D?

Totally! I personally might end up making it a static method that reads like so:
Polygon2D polygon = Polygon2D.fromPath(path2d);
Hopefully that ends up working out for you.

lucasstarsz added a commit that referenced this issue May 29, 2021
New Additions:
- PsdfUtil:
    - Derivation from DrawUtil for working with `.psdf` files.
    - Added support for saving `RadialGradient` and `LinearGradient` to a psdf file
- Polygon2D -- Changed `color` variable to `paint` to support all types of `Paint` objects.
- DrawUtil
    - Moved psdf content to PsdfUtil
    - `paintEquals` method for comparing equality between two `Paint` objects.
    - Changed `randomFont` method to draw font names from the original font set.
    - Added methods to generate random linear/radial gradients:
        - `randomLinearGradient`
        - `randomLinearGradientWithAlpha`
        - `randomRadialGradient`
        - `randomRadialGradientWithAlpha`

Files Moved:
- `tech.fastj.graphics.DisplayUtil.java` → `tech.fastj.graphics.util.DisplayUtil.java`
- `tech.fastj.graphics.DrawUtil.java` → `tech.fastj.graphics.util.DrawUtil.java`
- `tech.fastj.graphics.util.GradientBuilder.java` → `tech.fastj.graphics.util.gradients.GradientBuilder.java`
- `tech.fastj.graphics.util.Gradients.java` → `tech.fastj.graphics.util.gradients.Gradients.java`
- `tech.fastj.graphics.util.LinearGradientBuilder.java` → `tech.fastj.graphics.util.gradients.LinearGradientBuilder.java`
- `tech.fastj.graphics.util.RadialGradientBuilder.java` → `tech.fastj.graphics.util.gradients.RadialGradientBuilder.java`
lucasstarsz added a commit that referenced this issue Jun 6, 2021
lucasstarsz added a commit that referenced this issue Jun 6, 2021
…nimum color count/radius.

- Moved random gradient methods to `Gradients.java`
lucasstarsz added a commit that referenced this issue Jun 13, 2021
- Added constructors that don't require translation parameters, and constructors that allow initial scale/rotation.
lucasstarsz added a commit that referenced this issue Jun 24, 2021
- Added constructors that don't require translation parameters, and constructors that allow initial scale/rotation.
lucasstarsz added a commit that referenced this issue Jun 24, 2021
This commit contains multitudes of disgusting code. The next commit or two will take care of this.
lucasstarsz added a commit that referenced this issue Jul 4, 2021
With the addition of outline rendering, the boolean determining fill or outline was no longer satisfactory.
As such, the `RenderStyle` class was created, defining the different options for rendering (Only `Polygon2D` has this so far, but it will be rolled out to other classes as needed.)

Additions
- `Polygon2D#renderStyle` - the replacement to the aforementioned boolean which determines if objects should be filled, outlined, or both. Corresponding default is `Polygon2D#DefaultRenderStyle`.
- `Polygon2D#outlineStroke` - the `java.awt.BasicStroke` representing the style of the outline. Corresponding default is `Polygon2D#DefaultStroke`.
- `Polygon2D#outlineColor` - the `java.awt.Color` representing the color of the outline. Corresponding default is `Polygon2D#DefaultOutlineColor`.

Breaking Changes
- Removed all but one `Polygon2D` constructor and made it package private
    - Included are `create` methods that call on a `Polygon2DBuilder` class which will be added in the next commit. This will replace the excessive amounts of constructors that would have eventually arisen.
- Removed `Polygon2D#DefaultFill` and `Polygon2D#shouldFill`, in accordance with the information at the beginning of the commit message.
- Renamed `Polygon2D#get/setPaint` to `get/setFill`

Removals
- Removed transform information from `Polygon2D#toString`
- Removed `Polygon2D#DefaultShow`
lucasstarsz added a commit that referenced this issue Jul 4, 2021
lucasstarsz added a commit that referenced this issue Jul 4, 2021
New Additions:
- Polygon2D now properly supports outlines (BasicStroke only)
- revamped ModelUtil (PsdfUtil → ModelUtil)
    - Added outline, render style, and transform support
    - Refractored code to allow for later support for more file formats

Breaking Changes:
- Removed public access to all `Polygon2D` constructors. `Polygon2D`s must now be created using `Polygon2D#create`, which corresponds to a `Polygon2DBuilder` instance.
- Renamed `PsdfUtil#loadPsdf` → `ModelUtil#loadModel` & `PsdfUtil#writePsdf` → `ModelUtil#writeModel` to better represent what the methods do.
lucasstarsz added a commit that referenced this issue Jul 4, 2021
Bug Fixes:
- Add `break` statements to `PsdfUtil#writeRenderStyle` switch statement to prevent incorrect render style writing
- Fix issue with trying to parse floats in `PsdfUtil#parseOutlineStroke`
- Remove values stream to prevent stream re-usage in `SupportedFileFormats`
- Fix issue with only setting part of the render style content in `Polygon2DBuilder#build`

New Additions:
- Add method to create a random outline stroke
lucasstarsz added a commit that referenced this issue Jul 4, 2021
Bug Fixes:
- Fixed issue with occasionally generating outline strokes with miter limit values less than 1.0

Other Changes:
- Added `Assertions#assertDoesNotThrow` to all random generation unit tests (resolves sonarcloud code smells)
lucasstarsz added a commit that referenced this issue Jul 4, 2021
With the addition of outline rendering, the boolean determining fill or outline was no longer satisfactory.
As such, the `RenderStyle` class was created, defining the different options for rendering (Only `Polygon2D` has this so far, but it will be rolled out to other classes as needed.)

Additions
- `Polygon2D#renderStyle` - the replacement to the aforementioned boolean which determines if objects should be filled, outlined, or both. Corresponding default is `Polygon2D#DefaultRenderStyle`.
- `Polygon2D#outlineStroke` - the `java.awt.BasicStroke` representing the style of the outline. Corresponding default is `Polygon2D#DefaultStroke`.
- `Polygon2D#outlineColor` - the `java.awt.Color` representing the color of the outline. Corresponding default is `Polygon2D#DefaultOutlineColor`.

Breaking Changes
- Removed all but one `Polygon2D` constructor and made it package private
    - Included are `create` methods that call on a `Polygon2DBuilder` class which will be added in the next commit. This will replace the excessive amounts of constructors that would have eventually arisen.
- Removed `Polygon2D#DefaultFill` and `Polygon2D#shouldFill`, in accordance with the information at the beginning of the commit message.
- Renamed `Polygon2D#get/setPaint` to `get/setFill`

Removals
- Removed transform information from `Polygon2D#toString`
- Removed `Polygon2D#DefaultShow`
lucasstarsz added a commit that referenced this issue Jul 4, 2021
lucasstarsz added a commit that referenced this issue Jul 4, 2021
New Additions:
- Polygon2D now properly supports outlines (BasicStroke only)
- revamped ModelUtil (PsdfUtil → ModelUtil)
    - Added outline, render style, and transform support
    - Refractored code to allow for later support for more file formats

Breaking Changes:
- Removed public access to all `Polygon2D` constructors. `Polygon2D`s must now be created using `Polygon2D#create`, which corresponds to a `Polygon2DBuilder` instance.
- Renamed `PsdfUtil#loadPsdf` → `ModelUtil#loadModel` & `PsdfUtil#writePsdf` → `ModelUtil#writeModel` to better represent what the methods do.
lucasstarsz added a commit that referenced this issue Jul 4, 2021
Bug Fixes:
- Add `break` statements to `PsdfUtil#writeRenderStyle` switch statement to prevent incorrect render style writing
- Fix issue with trying to parse floats in `PsdfUtil#parseOutlineStroke`
- Remove values stream to prevent stream re-usage in `SupportedFileFormats`
- Fix issue with only setting part of the render style content in `Polygon2DBuilder#build`

New Additions:
- Add method to create a random outline stroke
lucasstarsz added a commit that referenced this issue Jul 4, 2021
Bug Fixes:
- Fixed issue with occasionally generating outline strokes with miter limit values less than 1.0

Other Changes:
- Added `Assertions#assertDoesNotThrow` to all random generation unit tests (resolves sonarcloud code smells)
lucasstarsz added a commit that referenced this issue Jul 4, 2021
With the addition of outline rendering, the boolean determining fill or outline was no longer satisfactory.
As such, the `RenderStyle` class was created, defining the different options for rendering (Only `Polygon2D` has this so far, but it will be rolled out to other classes as needed.)

Additions
- `Polygon2D#renderStyle` - the replacement to the aforementioned boolean which determines if objects should be filled, outlined, or both. Corresponding default is `Polygon2D#DefaultRenderStyle`.
- `Polygon2D#outlineStroke` - the `java.awt.BasicStroke` representing the style of the outline. Corresponding default is `Polygon2D#DefaultStroke`.
- `Polygon2D#outlineColor` - the `java.awt.Color` representing the color of the outline. Corresponding default is `Polygon2D#DefaultOutlineColor`.

Breaking Changes
- Removed all but one `Polygon2D` constructor and made it package private
    - Included are `create` methods that call on a `Polygon2DBuilder` class which will be added in the next commit. This will replace the excessive amounts of constructors that would have eventually arisen.
- Removed `Polygon2D#DefaultFill` and `Polygon2D#shouldFill`, in accordance with the information at the beginning of the commit message.
- Renamed `Polygon2D#get/setPaint` to `get/setFill`

Removals
- Removed transform information from `Polygon2D#toString`
- Removed `Polygon2D#DefaultShow`
lucasstarsz added a commit that referenced this issue Jul 4, 2021
Bug Fixes:
- Add `break` statements to `PsdfUtil#writeRenderStyle` switch statement to prevent incorrect render style writing
- Fix issue with trying to parse floats in `PsdfUtil#parseOutlineStroke`
- Remove values stream to prevent stream re-usage in `SupportedFileFormats`
- Fix issue with only setting part of the render style content in `Polygon2DBuilder#build`

New Additions:
- Add method to create a random outline stroke
@lucasstarsz
Copy link
Member Author

Note: the drawable-improvement branch has been replaced with the drawable branch.

lucasstarsz added a commit that referenced this issue Sep 12, 2021
Other Changes:
- The .obj parser handles multiple files where internal file paths are based on the starting file path.
  As a result, the file path is passed to the parsers as well as to the writers.
lucasstarsz added a commit that referenced this issue Sep 12, 2021
Images, Sprites, Animations, and a lot more

Additions
-  (#104) added Linux's X11 to list of supported hardware accelerations
- (#108) Added Sprite2D and simple animation system
    - Manages an array of sprites, as well as an image resource instance
    - has default animations for "continuous", "play to end", and "static" (default is "continuous")
- (#113) Added centralized, extensible resource manager
- (#108, #113) Added image resource manager implementation
- (#108) Added `ImageUtil` to load and manage buffered images (makes use of resource manager where needed)
- (#113) Added default resource management, loaded on `FastJEngine` static initialization (_before_ `FastJEngine.init`!)
- (#10, #110) added `TexturePaint` builder, and support for `TexturePaint` in `.psdf` files
- (#10) Added support for writing/parsing `Model2D` to the `.obj`/`.mtl` file format


Bug Fixes
- (Fixes #106) Fixed translation doubling by removing translation from `setMetrics` method calls
- (Fixes #114) Added missing call to `Scene.reset` for each scene in `SceneManager` during a call to `SceneManager.reset`.
-  (Fixes #115) Added calls to destroy `Drawable`s in `Scene`/`SimpleManager`
- (Fixes #86) Fixed issue where occasional `ConcurrentModificationException`s woulc crop up thanks to slight issues with consistent multithreaded/event-based inputs (keyboard, mouse, window, etc).


Breaking Changes
- Moved `tech.fastj.systems.fio.FileUtil` to `tech.fastj.resources.files.FileUtil`
- Moved `tech.fastj.graphics.util.ModelUtil` to `tech.fastj.resources.models.ModelUtil`
- Moved `tech.fastj.graphics.io.PsdfUtil` to `tech.fastj.resources.models.PsdfUtil`
- Moved `tech.fastj.graphics.io.SupportedModelFormats` to `tech.fastj.resources.models.SupportedModelFormats`
@lucasstarsz lucasstarsz added this to the FastJ Drawable System milestone Oct 26, 2021
lucasstarsz added a commit that referenced this issue May 9, 2022
New Additions:
- Created Pair class to handle returning 2 values at once, for generating point meshes with curves.
lucasstarsz added a commit that referenced this issue May 9, 2022
New Additions:
- Support for converting Path2D objects with curves and multiple subpaths to Pointf[] arrays (with optional `alternateIndexes` stored in paired `Point[]`)
- `DrawUtil#pointsOfPathWithAlt` specifically for getting both the points of the path and indicators of where curves/other path related functions are
- Support for writing/reading polygons with curves with .psdf files

Breaking Changes:
- `DrawUtil#pointsOfPath` and variants no longer throw exceptions on unclosed paths.

Bug Fixes:
- (minor) Fixed issue in `DrawUtil#createPath` where `altIndexes` was not checked for emptiness

Other Changes:
- Optimized usages of `Polygon2D#getPoints` to be less taxing for standard tasks
lucasstarsz added a commit that referenced this issue May 9, 2022
(#10, #109) add support for curves in DrawUtil#lengthOfPath
@lucasstarsz
Copy link
Member Author

Also is it feasible to add a Polygon2D constructor that takes a Path2D?

@nt314p Finally got around to doing this one. Still on the fence about working with arcs, points, and lines, but we've got one completely added (see #205)! Hope this helps 👍🏾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants