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

Initial cut of primitives from piet-scene #1

Merged
merged 5 commits into from
Nov 23, 2022
Merged

Initial cut of primitives from piet-scene #1

merged 5 commits into from
Nov 23, 2022

Conversation

dfrg
Copy link
Contributor

@dfrg dfrg commented Nov 22, 2022

Pulls in the primitives from the piet-scene crate, replacing the geometry and path types with those from kurbo. There are a few alterations to naming and docs and the addition of some convenience "builder" methods to making constructing various types easier.

There are more types to add to this crate-- specifically things related to fonts and text. I though I'd keep the initial PR smallish, covering just enough to serve current piet-scene needs.

I have a working branch with updates to the full piet-gpu repo to support these changes that is ready to go after this lands.

Pulls in the primitives from the piet-scene crate, replacing the geometry and path types with those from kurbo. There are a few alterations to naming a docs and the addition of some convenience "builder" methods to making constructing various types easier.

There are more types to add to this crate-- specifically things related to fonts and text. I though I'd keep the initial PR smallish, covering just enough to serve current piet-scene needs.

I have a working branch with updates to the full piet-gpu repo to support these changes that is ready to go after this lands.
Copy link
Contributor

@raphlinus raphlinus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, thanks! Just some small nits and suggestions.

name = "peniko"
version = "0.1.0"
license = "MIT/Apache-2.0"
edition = "2021"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have this a little more filled out - author, description, readme link, keywords.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely will do.

Cargo.toml Outdated
edition = "2021"

[dependencies]
kurbo = { git = "https://github.com/linebender/kurbo" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point to 0.9 when that's released?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the intention, but I didn't want to block on it.

src/blend.rs Outdated
Saturation = 13,
Color = 14,
Luminosity = 15,
// Clip is the same as normal, but doesn't always push a blend group.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is terse and confusing. May I suggest: "Clip is the same as normal, but the latter always creates an isolated blend group and the former can optimize that out."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it bad form to claim that I simply copied your comment from the original code? :) I'll update it. I also intend to document all the others in this file when I have a moment. I'm trying to make that a priority.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code had it in context of a full rendering pipeline, where the intent was crystal clear. Now it's in a separate crate, so without that context it's extremely confusing.

More seriously, yes, we should work toward documenting all this better. It was hard to motivate while everything was so fluid, but it feels like it's starting to converge a bit now.

Self { r, g, b, a }
}

/// Creates a color from hue, saturation, and lightness values.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a massive fan of hsl color spaces, as they're not colorimetrically sound. But color is one of those incredibly deep things. We should just do the RGB basics for now, though I am interested in doing "proper" color at some point.

I see there is hlc, which I like seeing - it should be compatible with Freiefarbe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not either, but one of the things I'd like to be able to offer in this library is reasonable support for the general set of relevant web style properties (in the same way that kurbo can parse SVG path data). This means being able to represent all of the color spaces (and then some?). If you'd prefer to limit the scope, I can do that.


pub use blend::*;
pub use brush::*;
pub use parse::ParseError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the only thing in there is an error, maybe the module should be named "error"? I'd expect parsing code. Minor nit though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a stub for now. As above for color, my future goal is to support parsing additional things like font-family, font-weight, font-style, etc. I have this mostly written in another project, but didn't want to overload this PR with new stuff.

I suppose there is a general question of whether parsing is out of scope for this crate?

dfrg added 3 commits November 22, 2022 22:36
* add additional metadata to Cargo.toml
* better comment on Mix::Clip and document all of the others
also removes the Color::hsl[a] methods
@dfrg
Copy link
Contributor Author

dfrg commented Nov 23, 2022

Cargo metadata and kurbo version have been updated.

I removed the hsl constructors for color (but kept hlc). Happy to spend some time in the future discussing high quality color support as I think this crate is now a suitable place for it. I kept the (currently) unfortunately named parse module for now because I intend to fill it with some actual parsing machinery in the next PR.

Merging this so we can move forward!

@dfrg dfrg merged commit b838217 into main Nov 23, 2022
@dfrg dfrg deleted the initial branch November 23, 2022 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants