Commit Graph

49 Commits

Author SHA1 Message Date
0HyperCube ceb2f4c13f
Add more details to Graphene concept documentation (#1437)
* Start improving node system docs

* Add note on debugging

* Explain testing protonodes

* Code review comments

* Review pass

* Further improve explanation of manual_compostion

* Fix explanation of ComposeNode graph rewriting

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-10-27 19:21:15 -07:00
0HyperCube 9b034a5194
Fix deleting layers (#1441)
* Fix deleting layers

* Code review comments
2023-10-25 15:20:55 -07:00
Yuri Astrakhan 3d4e3a74e5
A few minor lints and docs (#1436)
* A few minor lints and docs

* Added required packages to compile on Debian-style linux
* Inlined some format args, and removed some `&` in args (they cause about 6% slowdown that compiler cannot inline)
* a few spelling mistakes

* fix fmt
2023-10-18 23:33:10 -07:00
0HyperCube 5827e989dc Migrate the Select tool to the document graph (#1433)
* function for accessing document metadata

* Better select tool

* Fix render

* Fix transforms

* Fix loading saved documents

* Populate graph UI when loading autosave

* Multiple transform nodes

* Fix deep select

* Graph tooltips

* Fix flip axis icon

* Show disabled widgets

* Stop select tool from selecting artboards

* Disable (not hide) the pivot widget; remove Deep/Shallow select for now

* Code review changes

* Fix pivot position with select tool

* Fix incorrectly selected layers when shift clicking

---------

Co-authored-by: Dennis Kobert <dennis@kobert.dev>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-10-17 11:09:32 -07:00
Dennis Kobert d82f133514 Lay groundwork for adaptive resolution system (#1395)
* Make transform node accept footprint as input and pass it along to its input

use f32 instead of f64 and add default to document node definition

* Add cull node

* Fix types for Transform and Cull Nodes

* Add render config struct

* Add Render Node skeleton

* Add Render Node to node_registry

* Make types macro use macro hygiene

* Place Render Node as output

* Start making DownresNode footprint aware

* Correctly calculate footprint in Transform Node

* Add cropping and resizing to downres node

* Fix Output node declaration

* Fix image transform

* Fix Vector Data rendering

* Add concept of ImageRenderMode

* Take base image size into account when calculating the final image size

* Supply viewport transform to the node graph

* Start adapting document graph to resolution agnosticism

* Make document node short circuting not shift the input index

* Apply clippy lints
2023-10-17 11:02:07 -07:00
0hypercube b52f831b21 Fix artboard tool and remove old artboard code 2023-10-17 11:02:06 -07:00
0hypercube 9a39c4a0cc Fix gradient tool 2023-10-17 11:02:06 -07:00
0hypercube 4cd72edb64 Initial work migrating vector layers to document graph
* Fix pen tool (except overlays)
* Thumbnail of only the layer and not the composite
* Fix occasional transform breakages
* Constrain size of thumbnail
* Insert new layers at the top
* Broken layer tree
* Fix crash when drawing
* Reduce calls to send graph
* Reduce calls to updating properties
* Store cached transforms upon the document
* Fix missing node UI updates
* Fix fill tool and clean up imports and indentation
* Error on overide existing layer
* Fix pen tool (partially)
* Fix some lints
2023-10-17 11:02:06 -07:00
Keavon Chambers 2b05e1c270 Rename Shape tool to Polygon tool 2023-08-01 01:28:14 -07:00
Dennis Kobert a49d96ed37 Embed git commit hash in the document file (#1325)
* Embed git commit hash in the document file

* Bump version in test document file

* Fixes

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-07-28 22:52:26 +02:00
0HyperCube 80cc5bee73 Fix clippy lints (#1327)
* Fix clippy lints

* Update formatting

* Remove unsafe send impls

* New type for Rc<NodeContainer>
2023-07-19 16:38:23 +01:00
nat-rix f76b850b9c Fix Imaginate by porting its JS roundtrip code to graph-based async execution in Rust (#1250)
* Create asynchronous rust imaginate node

* Make a first imaginate request via rust

* Implement parsing of imaginate API result image

* Stop refresh timer from affecting imaginate progress requests

* Add cargo-about clarification for rustls-webpki

* Delete imaginate.ts and all uses of its functions

* Add imaginate img2img feature

* Fix imaginate random seed button

* Fix imaginate ui inferring non-custom resolutions

* Fix the imaginate progress indicator

* Remove ImaginatePreferences from being compiled into node graph

* Regenerate imaginate only when hitting button

* Add ability to terminate imaginate requests

* Add imaginate server check feature

* Do not compile wasm_bindgen bindings in graphite_editor for tests

* Address some review suggestions

- move wasm futures dependency in editor to the future-executor crate
- guard wasm-bindgen in editor behind a `wasm` feature flag
- dont make seed number input a slider
- remove poll_server_check from process_message function beginning
- guard wasm related code behind `cfg(target_arch = "wasm32")` instead
  of `cfg(test)`
- Call the imaginate idle states "Ready" and "Done" instead of "Nothing
  to do"
- Call the imaginate uploading state "Uploading Image" instead of
  "Uploading Input Image"
- Remove the EvalSyncNode

* Fix imaginate host name being restored between graphite instances

also change the progress status texts a bit.

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-06-09 09:03:15 +02:00
Orson Peters 5558deba5e Brush blend modes and erase/restore (#1261)
* Made blit node numerically stable.

* Added blend mode parameter to brush strokes.

* Fixed difference blend mode.

* Added erase/restore blend modes.

* Added blend mode and draw mode widgets.

* Added comment explaining the ImageFrame.transform.

* Initial blit/blend version.

* Working version of erase/restore.

* Improved inlining for blend functions.

* Dsiable the blend mode selector in erase/draw mode.

* Fixed incorrect bounds calculation.

* Use factor instead of percentage for opacity

* Rearrange options bar widgets

* Tidy up blend modes

* Code review

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-06-02 21:59:55 +02:00
Dennis Kobert 4e1bfddcd8 Remove unsafe code and clean up the code base in general (#1263)
* Remove unsafe code

* Make node graph test syncronous

* Add miri step to ci

* Remove unsafe from node graph evaluation

* Replace operation pseudo_hash with hash based on discriminant

* Fix test

* Move memo module to core and make it safe

* Fix formatting

* Remove unused stuff from gstd

* Use safe casting for creating key variants

* Fix memo node types

* Fix ref node

* "fix" ub

* Use correct input types for ExtractImageFrame

* Fix types for async nodes

* Fix missing implementation

* Manually override output type for async nodes

* Fix types for EditorApi

* Fix output type for WasmSurfaceHandle

* Remove unused miri.yml

* Fix incorrect type for cache node
2023-06-02 11:05:32 +02:00
Dennis Kobert 259dcdc628 Use canvas as target for raster rendering (#1256)
* Implement ApplicationIo

* Simplify output duplication logic

* Fix let node initialization for ExtractImageFrame

* Async macros

* Use manual node registry impl

* Fix canvas insertion into the dom
2023-05-30 20:12:59 +02:00
0HyperCube 15eb4df8d4 Add the document graph (#1217)
* Thumbnails for the layer node

* Raster node graph frames

* Downscale to a random resolution

* Cleanup and bug fixes

* Generate paths before duplicating outputs

* Fix stable id test

* Add a document node graph

* Fix merge conflict

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-05-26 17:22:58 +01:00
Christopher Mendoza bb1e7c44cf Make duplicating folders also duplicate its children (#1178)
* Latest changes

* Add layer attempt

* layer tree is now correct after duplicating layers

* Latest changes

* Latest Changes

* Recursive idea

* Moving Layers to Dup Folder - not done

* latest changes

* latest progress

* Latest Changes

* Latest Changes

* Latest Changes

* Latest

* Latest

* Latest

* Duplicating Folders works

* Initial Refactoring

* Ready for QA

* Doesn't select all the children after duplicate anymore

* First pass code review with major cleanup

* Removed unused next_asssignment_id function and updated FolderLayer struct

* Removed unused logic

* First iteration of cleaning up the code

* Added Ollie's suggestions

* Code review cleanup

---------

Co-authored-by: Ollie Dolan <olliedolan10@gmail.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-05-19 00:41:16 -07:00
0HyperCube 6400953af5 Thumbnails for the layer node (#1210)
* Thumbnails for the layer node

* Raster node graph frames

* Downscale to a random resolution

* Cleanup and bug fixes

* Generate paths before duplicating outputs

* Fix stable id test

* Code review changes

* Code review pass with minor changes

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-05-18 05:12:50 +01:00
Keavon Chambers 59adf9a032 Remove dead code from document-legacy 2023-05-06 17:03:40 -07:00
Keavon Chambers ebf67eaa82 Implement download/copy ImageFrame layer output (#1194)
* Implement download/copy ImageFrame layer output

* Add note about black transparency when copying

* Introspect node graph output type to conditionally disable the download button

---------

Co-authored-by: Dennis Kobert <dennis@kobert.dev>
2023-05-03 02:09:07 -07:00
Keavon Chambers dcabd6c0b4 Refactor naming to deprecate "node graph frame" terminology (#1187) 2023-04-28 01:30:47 -07: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
OllieDolan 974a37f127 Path tool points manipulation: nudging, drag axis snapping, and G/R/S (#1068)
* issue820: implemented nudging points

* nudge points triggered only when the mouse is moved after selecting one point

* issue 820 // bullet 1 done

* grab working / rotate not

* rotate works (sensitive)

* G/R/S and Shift/Drag working

* Cargo formatted // implemented Hypercubes comments

* Refactored G/R/S - need to fix fast transform

* Finished refactored G/R/S

* Typed Angle needs further touch up

* Cargo formatted

* Dealt with dangerous unwraps

* Cargo fmt (again) - unwraps fixed

* Cleaned up

* cargo fmt

* Ready for Review

* Ready for Review- cargo fmt

* Code review fixes

* Remove duplicate constant for nudging

* Fix consts.rs spacing

* Apply suggestions from code review

Added suggestions

Co-authored-by: Keavon Chambers <keavon@keavon.com>

* Added typo/grammar suggestions

* Nits

---------

Co-authored-by: Shiro <shiro@damedane.local>
Co-authored-by: hypercube <0hypercube@gmail.com>
Co-authored-by: 0HyperCube <78500760+0HyperCube@users.noreply.github.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-04-16 15:56:52 -07:00
Christopher Mendoza b83f2c24f1 Change layer duplication so the duplicate is placed above the original (#1124)
Previously, the duplicated layer would be placed at the top of the stack. It is now inserted one layer above the original.

---------

Co-authored-by: Ollie Dolan <olliedolan10@gmail.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-04-16 15:34:02 -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
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
Sahra Zhou dbcb854cd2 Fix crash when scaling something with 0 width or height (#1078)
* resolve NaN value when trying to change scale value from zero to other numbers

* resolve NaN value when trying to change scale value from zero to other numbers

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-03-26 15:20:00 -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
0HyperCube a2046a51b1 Add basic vector nodes (#1059)
* Add some derives

* Allow node_fn with mutable inputs

* Add basic vector nodes

* Revert elipse tool changes

* Fix the elipse tool again

* Change spacer width

* Bubble serde feature in graph craft

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-03-02 21:54:23 +00:00
0HyperCube 4495488546 Refactor vector data type from document-legacy into node graph (#1057)
Add vector data type
2023-02-25 16:55:05 +00:00
Christopher Mendoza b7f2163998 Selecting an individual anchor point deselects each of the other points (#963)
* Selecting an individual anchor point deselects each of the other points

* git gra

* Selecting intersecting shapes,selects top shape

* Merge commit

* cargo fmt

* fixed: can't drag multiple selected shapes.

* Merge commit

* Merge commit

* Code review tweaks

* Merge commit

* Fixed topmost layer and previous_mouse_position

* Fixed issues when clicking on anchors

* Works

* Function name change

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
Co-authored-by: Dennis Kobert <dennis@kobert.dev>
2023-02-19 23:26:02 -08:00
Keavon Chambers 202b0ee6ed Remove Color struct from document-legacy (#1012) 2023-02-07 17:31:50 -08:00
Dennis Kobert 620540d7cd Incremental compilation and stable node IDs (#977)
* Generate stable node ids

* checkpoint

* Implement borrow tree

* Add eval function on borrow tree

* Refactor Node trait to fix lifetime issues

* Compiler infinite loop

* Impl compose pair

* Transition to double lifetime on trait

* Change node trait to use a generic arg for the input

* Start adapting node_macro

* Migrate more nodes to new macro

* Fix raster tests

* Port vector nodes

* Make Node trait object safe

* Fix FlatMapResultNode

* Translate most of gstd

* Fix DowncastBothNode

* Refactor node trait once again to allow for HRTB for type erased nodes

* Start working on type erased nodes

* Try getting DowncastBothNode to work

* Introduce Upcasting node + work on BorrowTree

* Make enough 'static to get the code to compile

* Transition DynamicExecutor to use borrow tree

* Make Compose Node use HRTB's

* Fix MapResultNode

* Disable blur test

* Add workaround for Composing type erased nodes

* Convert more nodes in the node_registry

* Convert more of the node_registry

* Add update tree fn and hook up to frontend

* Fix blur node

* Implement CacheNode

* Make frontend use graph compiler

* Fix document_node_types type declaration for most nodes

* Remove unused imports

* Move comment down

* Reuse nodes via borrow tree

* Deprecate trait based value in favor of TaggedValue

* Remove unsafe code in buffer creation

* Fix blur node

* Fix stable node id generation

* Fix types for Image adjustment document nodes

* Fix Imaginate Node

* Remove unused imports

* Remove log

* Fix off by one error

* Remove macro generated imaginate node entry

* Create parameterized add node

* Fix test case

* Remove link from layer_panel.rs

* Fix formatting
2023-02-07 20:06:24 +01:00
Keavon Chambers beab0f01c6 Refactor font_cache into render_data; delete image layer type 2023-01-29 20:31:14 -08:00
Keavon Chambers d990110f63 Apply lints and cleanup to Rust code 2023-01-29 03:01:57 -08:00
Brendan Allan 5388b59e97 Groundwork for integrating Specta (#949)
* add derive(specta::Type)

* use specta from git

* introduce Uuid type

* remove unnecessary specta::Type

* document export_types test

* upgrade Specta
The previous Specta branch had some hacks that were just for this project. They have all been converted into proper features so they can be merged into main.

* remove some unnecessary specta::Type uses

* add MessageDiscriminantDef explanation

* manually export types with specta

* rename 'specta.rs' to 'export_types.rs'

* rename 'export_types' to 'generate_ts_types'

---------

Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
2023-01-28 22:29:38 -08:00
kadir e0146d57f7 Update UI when deleting last point of shape with Path tool (#979)
* Added new DocumentResponse variant

* Update Operation::DeleteSelectedManipulatorPoints to update Layer Tree by delegating deletion to Operation::DeleteLayer. Also emits Operation::DeletedSelectedManipulatorPoints to let editor clear Properties panel

* Update process_message() to deal with new DocumentResponse::DeletedSelectedManipulatorPoints match case. When this DocumentResponse is emitted, it clears the Properties panel.

* Added Display trait implementation for DocumentResponse::DeletedSelectedManipulatorPoints. Updated imports in document_message_handler.rs to get the correct types for messages emitted from DocumentResponse::DeletedSelectedManipulatorPoints match case in process_message().

* Removed useless import. Capitalized comments for style consistency.

* Updated messages emitted to clear Properties panel by emitting LayoutMessage::SendLayout's instead, which update the backend widget state

* Revert inclusion of unused imports

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-01-28 18:32:31 -05:00
0HyperCube 64e62699fc Replace the image layer type with an Image node (#948)
* Use builder pattern for widgets

* Arguments to new function

* Add node graph when dragging in image

* Fix duplicate import

* Skip processing under node graph frame if unused

* Reduce node graph rerenders

* DUPLICATE ALL frontend changes into other frontend

* DUPLICATE more changes to another frontend

* Code review

* Allow importing SVG files as bitmaps

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-01-27 10:01:09 +00:00
Keavon Chambers 66e8325362 Update project readme and MSRV 2023-01-24 01:33:30 -08:00
Oliver Davies 0019340096 Remove additional boolean for mirroring distance (#965)
Removed the additional boolean for mirroring distance
2023-01-13 15:00:20 -08:00
0HyperCube 2a27471363 Fix boolean crash with self intersecting shape (#952) 2023-01-09 02:25:06 +00:00
locriacyber 1a6ee7c542 Remove direct dependency on ttf_parser (#947)
Because ttf_parser updated, rustybuzz was using an older version.
2023-01-07 16:40:59 +00:00
0hypercube 8e9d097fcc Fix accidental 'not' when checking for redraw 2023-01-03 18:24:02 +00:00
0HyperCube cd8a897b96 Don't show the blue outline when bloburl is set (#937) 2023-01-03 10:05:46 +00:00
0HyperCube 7cc1a192cb Fix viewport culling with nested layers (#939)
* Fix viewport culling with nested layers

* Clean up naming
2023-01-02 15:27:11 +00:00
0HyperCube 6e142627a3 Fix a derivative causing NaNs in boolean ops (#934)
* Fix a derivative causing NaNs

* Better error messages around boolean ops

* Tweak error dialog wording

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-01-01 08:54:10 +00:00
0HyperCube 0d703e857b Gradient tool improvements (#927)
* Reuse existing gradient

* Double click to insert gradient stop

* Add history states to the gradient tool

* Do trig in viewport space so it is actually perpendicular

* Sync tool options with active gradient

* Deleting points with delete key

* More tolerance on inserting points
2022-12-29 20:00:58 +00:00
0HyperCube 750ef06cba Add a 'Preserve Aspect Ratio' checkbox to Properties panel (#923)
* Add the link button

* Transform around pivot

* Remove log

* Fix tests

* Add a hacky two-line layout for the checkbox

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2022-12-28 23:21:03 +00:00
Keavon Chambers 49b9b8cfec Rename the legacy Graphene crate to document-legacy (#899)
* Rename /graphene to /document-legacy

* Update names in code
2022-12-22 02:12:05 -08:00