Commit graph

162 commits

Author SHA1 Message Date
Dennis Kobert
c648e25e8c Hook up request animation frame plumbing to decouple execution 2023-05-11 22:13:51 +02:00
Dennis Kobert
fffbaa6de2 Decouple node graph execution 2023-05-11 20:08:29 +02:00
0HyperCube
4e0c673a35 Add Layer and Artboard node definitions and underlying data structures (#1204)
* Add basic node defenitions

* Code review

* change widget code

* Artboard node changes

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-05-09 21:57:22 +01:00
0HyperCube
ab2de96640 Fix brush layers growing hugely when resizing transforms with Select tool (#1201)
* Fix brush tool resize

* Fix typo

* Fix image transforms

* Remove input from image network

* Fix merge error

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-05-07 12:17:12 +01:00
0HyperCube
d7c5658852 Imaginate fixes (#1200) 2023-05-07 11:23:16 +01:00
Keavon Chambers
c79cf41c28 Show outline for image frames on hover and when selected with frame tools 2023-05-07 01:30:16 -07:00
Keavon Chambers
59adf9a032 Remove dead code from document-legacy 2023-05-06 17:03:40 -07:00
Dennis Kobert
47f9f7621e Fix "Failed to execute" dialog showing up at times (#1196)
[𝘀𝗽𝗿] initial version

Created using spr 1.3.4
2023-05-03 19:39:02 +02:00
Dennis Kobert
36f24b7730 Implement bounds input to constrain the output frame of the brush node
Test Plan:
Hook up a constraint to the brush node in the editor and
verify the result looks correct

Reviewers: 

Pull Request: https://github.com/GraphiteEditor/Graphite/pull/1195
2023-05-03 17:05:04 +02:00
Dennis Kobert
3adcc3031a Implement Infrastructure to reuse previous frames for brush drawing
Implement Infrastructuro to reuse the previous evaluation of the
node graph to blend the new stroke with instead of drawing the
entire trace from scratch.
This does not transition to a blending based approach because that still
caused regressions but allows the brush node to work with input data
natively.

Test Plan:
- Use the brush tool in the editor and check for regressions
- Evaluate the performance

Reviewers: Keavon

Pull Request: https://github.com/GraphiteEditor/Graphite/pull/1190
2023-05-03 13:14:41 +02:00
Chase
1aaf2a521b Add fill and stroke color choices to the Pen tool options bar (#1188)
* Add basic layout - WIP

* Add color input min-width -> 80px

* First pass implementation - WIP

* Allow fill to be None

* Fix null Fill color

* refactor fill and stroke options into struct

* toolbar progress - WIP

* Switch is_working_color bool to PenColorType enum

* Add todo

* Add WorkingColorChanged event

* remove unused import

* Add WorkingColor[Primary/Secondary] icons

* Allow new strokes to have no color

* Set to base color when X is pressed (as per req)

* Improve icons for new UI layout design

* Add radio buttons

* Fix menu bar Edit12px -> Edit

* Add tooltips to radio buttons

* Make the color selector only on custom

* Fix edit icon correctly this time (whoops)

* Fix working colors icons

* Changes to improve the UX

* Remove lines obviated by Default::default()

* Make Eyedropper tool use working_color_changed event

* Fix tests

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-05-03 02:08:35 +08:00
Dennis Kobert
cef1cf7587 Hide edge aliasing of hard brushes with a blur (#1189)
* [𝘀𝗽𝗿] initial version

Created using spr 1.3.4

* Formatting

Created using spr 1.3.4

* Rename aa to blur + add comment

Created using spr 1.3.4
2023-04-29 23:35:30 +02:00
Dennis Kobert
1020eb6835 Implement the Brush without relying on a stamp texture
Test Plan: Test the BrushNode in the editor

Reviewers: Keavon

Reviewed By: Keavon

Pull Request: https://github.com/GraphiteEditor/Graphite/pull/1184
2023-04-29 01:31:14 +02:00
Dennis Kobert
bea7cc8dd0 Add node introspection API
Closes #1110

Test Plan: query the introspectNode Endpoint from js

Reviewers: 

Pull Request: https://github.com/GraphiteEditor/Graphite/pull/1183
2023-04-28 00:20:39 +02:00
Dennis Kobert
a4793fb284 Implement source maps between proto/document nodes
Add the node path to the document node and carry that over to the proto
nodes which are generated from that.
This pr also adds a compiler pass to assign the paths based on the
hierarchical structure of the nodegraph.

Test Plan: - Run units tests which check the path propagation works

Reviewers: Keavon

Reviewed By: Keavon

Pull Request: https://github.com/GraphiteEditor/Graphite/pull/1181
2023-04-27 11:02:04 +02:00
0HyperCube
ef93f8442a Migrate text layers to nodes (#1155)
* Initial work towards text to node

* Add the text generate node

* Implement live edit

* Fix merge error

* Cleanup text tool

* Implement text

* Fix transforms

* Fix broken image frame

* Double click to edit text

* Fix rendering text on load

* Moving whilst editing

* Better text properties

* Prevent changing vector when there is a Text node

* Push node api

* Use node fn macro

* Stable ids

* Image module as a seperate file

* Explain check for "Input Frame" node

* Code review

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-04-27 03:07:43 +01:00
Dennis Kobert
271f9d5158 Add monitor node for graph introspection
Adds a `serialize` function on Node which can be implemented by nodes to
allow introspecting their content. This pr also adds a Monitor Node that
always caches the last value it was evaluated with.

Test Plan: -

Reviewers: 0HyperCube

Reviewed By: 0HyperCube

Pull Request: https://github.com/GraphiteEditor/Graphite/pull/1165
2023-04-26 23:21:50 +02:00
nat-rix
c814abc347 Fix too many locals in wasm binary (#1159)
Split function into smaller non-inlinable ones

this fixes the issue that rust creates too many wasm locals in non-optimized
builds. That lead to a compile error in such builds.

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-04-24 21:44:06 +02:00
Dennis Kobert
497bf3dfc5 Fix ordering of MaskNode Trait Bounds
Test Plan: -

Reviewers: 

Pull Request: https://github.com/GraphiteEditor/Graphite/pull/1157
2023-04-24 20:02:45 +02:00
Dennis Kobert
366906b956 Add Luma struct (#1154)
* Make Luma usable for MaskImageNode
2023-04-23 19:42:34 +02:00
Dennis Kobert
bdc1ef926a Restructure GPU execution to model GPU pipelines in the node graph (#1088)
* Start implementing GpuExecutor for wgpu

* Implement read_output_buffer function

* Implement extraction node in the compiler

* Generate type annotations during shader compilation

* Start adding node wrapprs for graph execution api

* Wrap more of the api in nodes

* Restructure Pipeline to accept arbitrary shader inputs

* Adapt nodes to new trait definitions

* Start implementing gpu-compiler trait

* Adapt shader generation

* Hardstuck on pointer casts

* Pass nodes as references in gpu code to avoid zsts

* Update gcore to compile on the gpu

* Fix color doc tests

* Impl Node for node refs
2023-04-23 10:18:31 +02:00
Keavon Chambers
161bbc62b4 Add the Selective Color adjustment node 2023-04-19 03:02:50 -07:00
Dennis Kobert
76c754d38a Simplify node trait definition (#1146)
* Simplify node trait
2023-04-17 23:42:22 +02:00
Dennis Kobert
1d6c4f13dd Bump version of dyn-any to address missues which could lead to ub (#1145)
* Make StaticType trait unsafe

* Mark StaticTypeSized and StaticTypeClone as unsafe as well

* Update dyn-any dependency

* Update manifest links
2023-04-17 23:35:04 +02:00
Keavon Chambers
9db5ad43bf Add the Channel Mixer node (#1142)
* Add the Channel Mixer node

* Fix NodeIdentifier not found in Registry

* Add radio toggle for red/green/blue

---------

Co-authored-by: Dennis Kobert <dennis@kobert.dev>
2023-04-17 12:47:24 -07:00
Dennis Kobert
a1b63811ba Impl byte size function for Color (#1141) 2023-04-17 09:58:21 +02:00
Christopher Mendoza
4c9ef0fe6c Change selection to only the duplicated layer (not both layers) when using Ctrl+D (#1118)
* Nudging is now based on local pixel dimensions

* Brush tool live preview (#1116)

* Disable vector preview for brush tool

* Fix brush preview

* Fix warping

* Left and right square brackets to change size

* Add linear interpolation

* Modfiy existing selected brush layer

* Resolve warnings

---------

Co-authored-by: Dennis Kobert <dennis@kobert.dev>
Co-authored-by: Keavon Chambers <keavon@keavon.com>

* Duplicating a layer selects only new layer

* Add Ctrl+J duplicate alias hotkey

---------

Co-authored-by: 0HyperCube <78500760+0HyperCube@users.noreply.github.com>
Co-authored-by: Dennis Kobert <dennis@kobert.dev>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-04-16 14:42:12 -07:00
Keavon Chambers
fa23e9d55b Update nodes to work with linear color by default (#1135)
* Update nodes to work with linear color by default

* Make tests work in linear not gamma
2023-04-16 12:20:44 -07:00
Dennis Kobert
f68bc42fc9 Serialize Color as srgb (#1136) 2023-04-16 15:02:22 +02:00
Alexandru Ică
b626d39035 Add the image segmentation node (#1122)
* Add image segmentation node

This is a node which receives as input:
- An image.
- A mask, which consists of colors that define the image segments.

Each unique color in the mask defines an area where a segmen resides.
The node generates a `Vec<ImageFrame>` where the length of the result
is the number of unique colors in the mask.

Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>

* Add the Index node for image segments

Since the output of the image segmentation node is a `Vec<ImageFrame>`,
we want a way to access the segments individually. The Index node receives
a `Vec<ImageFrame>` as input and an index, and returns the image found
at that index in the vec.

Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>

* Integrate the image segmentation and index nodes into the editor

Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>

* Initialize the input of the index node with an empty image frame

Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>

* Don't expose the parameter for the index node

Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>

* Don't crash the editor when the number of segments exceeds the accepted limit

Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>

* Print a warning in the console when the number of segments exceeds the accepted limit

Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>

* Add a few more checks so that the editor doesn't crash on invalid input

Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>

* Replace the tagged value for the index node

Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>

* Fix merge conflicts

---------

Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>
Co-authored-by: Dennis Kobert <dennis@kobert.dev>
2023-04-16 14:51:33 +03:00
Dennis Kobert
ce5b73598c Fix transform logic for mask node (#1134)
Fix transform logic for mask node + other fixes

* Fixes the transform logic for the mask node reverting the breakage
introduced by the color pr

* Actually modifies the pixel values

* Fix storage format for images

* Export images as unassociated alpha
2023-04-16 10:15:58 +02:00
Dennis Kobert
37b892a516 Color system based on traits, and conversion to linear color in the graph (#1123)
* Migrate Nodes to use RasterMut + Samplable

* Add Pixel trait to include serialization

* Implement traits for Color and propagate new generics

* Always convert to linear color when loading images
2023-04-16 02:57:05 +02:00
Dennis Kobert
e21c2fb67b Add SetTransformNode (#1131) 2023-04-15 16:34:17 +02:00
Keavon Chambers
0ba0b2e309 Implement the correct Brightness/Contrast node algorithm (#1130)
Implement correct brightness/contrast algorithm
2023-04-15 05:15:58 -07:00
0HyperCube
0e97f352e9 Serialize images as base64 by rounding channels from floats to u8 (#1120)
Serialise images as base64
2023-04-13 20:03:25 +01:00
Dennis Kobert
79dade24e5 Fix opacity blending on colored brush strokes (#1119)
Make apply opacity function use associated alpha
2023-04-13 10:44:33 +02:00
0HyperCube
ed6140b4a7 Brush tool live preview (#1116)
* Disable vector preview for brush tool

* Fix brush preview

* Fix warping

* Left and right square brackets to change size

* Add linear interpolation

* Modfiy existing selected brush layer

* Resolve warnings

---------

Co-authored-by: Dennis Kobert <dennis@kobert.dev>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-04-12 18:50:42 +01:00
Keavon Chambers
c7d14c2a7b Fix Levels and Exposure adjustment nodes (#1112)
* Step Imaginate resolution by 64

* Fix the Exposure node

* Change comments and variable names
2023-04-11 01:52:44 -07:00
Dennis Kobert
589ff9a2d3 Implement the Brush tool (#1099)
* Implement Brush Node

* Add color Input

* Add VectorPointsNode

* Add Erase Node

* Adapt compilation infrastructure to allow non Image Frame inputs

* Remove debug output from TransformNode

* Fix transform calculation

* Fix Blending by making the brush texture use associated alpha

* Code improvements and UX polish

* Rename Opacity to Flow

* Add erase option to brush node + fix freehand tool

* Fix crash

* Revert erase implementation

* Fix flattening id calculation

* Fix some transformation issues

* Fix changing the pivot location

* Fix vector data modify bounds

* Minor fn name cleanup

* Fix some tests

* Fix tests

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
Co-authored-by: hypercube <0hypercube@gmail.com>
2023-04-11 10:35:21 +02:00
Keavon Chambers
ce76dbee6a Rename the Downscale node to Downres 2023-04-09 15:22:22 -07:00
0HyperCube
a58d51d685 Add cache clearing to stop the memory leak (#1106)
* Add cache clearing

* Add TODO comment

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-04-09 23:30:57 +01:00
isiko
9c4164291c Add the Mask node (#1080)
* Add MaskImageNode

Co-authored-by: Dennis Kobert <dennis@kobert.dev>
2023-04-09 04:56:03 +02:00
Keavon Chambers
ea02a2d53a Fix crash upon setting stroke color to none 2023-04-06 18:11:45 -07:00
Keavon Chambers
c16ee88b5d Fix some fatal failures related to rendered frame memory size limits 2023-04-02 18:31:41 -07:00
Keavon Chambers
0a9427fe6e Polish node graph frames and rename them for clarity (#1104)
* Polish layer panel UI and layer type icons/text

* Assorted UI text and comment cleanup

* Insert Transform node before Imaginate node via tool

* Rename "Node Graph Frame" to Layer type and Frame tool

* Rename "Node Graph Frame" to "Frame" tool

* Update Node Graph Frame -> Frame tool icon

* Fix lint warnings
2023-04-03 01:52:25 -07:00
0HyperCube
d710285029 Fix regressions introduced in the vector nodes migration (#1100)
* Fix double click to enter path tool

* Fix error

* Fix transform bug

* Fix squaring scale on images

* Shift node position and refresh graph

* Downscale node seperate

* Fix mirror

* Remove duplicate transform

* Always show node graph

* Correctly set freehand and spline tool positions

* Run cargo format

* Maybe fix the scale

* Downscaled image is always smaller than origional

* Fix one crash

* Don't show node graph on welcome screen

* Reduce default graph panel height

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-03-31 21:15:49 +01:00
isiko
d0863165a4 Add Range parameter to the Threshold node (#1079)
* Add Range

* Naming, order, and defaults

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-03-28 09:06:24 +02:00
Keavon Chambers
d6ab417bcb Code review previous commit, and improve G/R/S hints 2023-03-26 11:49:25 -07:00
0HyperCube
959e790cdf Migrate vector data and tools to use nodes (#1065)
* Add rendering to vector nodes

* Add line, shape, rectange and freehand tool

* Fix transforms, strokes and fills

* Migrate spline tool

* Remove blank lines

* Fix test

* Fix fill in properties

* Select layers when filling

* Properties panel transform around pivot

* Fix select tool outlines

* Select tool modifies node graph pivot

* Add the pivot assist to the properties

* Improve setting non existant fill UX

* Cleanup hash function

* Path and pen tools

* Bug fixes

* Disable boolean ops

* Fix default handle smoothing on ellipses

* Fix test and warnings

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-03-26 08:03:51 +01:00
Keavon Chambers
089df947ac Remove leftover debug logs 2023-03-21 00:41:39 -07:00