-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add sketchy transformation #44
base: master
Are you sure you want to change the base?
Conversation
Okay, no rush. I've been working on it a bit more and just finished adding hachures for fills. PR is getting pretty big - if you'd like I can separate out all the Sketchy logic and then either leave it on a fork, or look into opening a new PR to expose the API I'd need to build this on top of elm-collage but as a separate package. Right now this is all just a fun experiment, but I am kinda hoping to get it to a good enough place that people could use it if they want. |
I'm really sorry for the delay, a week turned into a month. A clear sign I should transfer ownership to a new maintainer :-P It's indeed a quite big PR at the moment. Best would be to split it in a sketchy and in a curves part, but I can imaging this could be quite some work to split it in two separate PRs, and I'm quite happy to merge it this way. It helps that it's just a minor update in the end. I'll review your changes today and come back to you! |
src/Collage/Render.elm
Outdated
neighbors arr index = | ||
Maybe.map4 | ||
(\m1 p1 i p2 -> | ||
((m1, p1), (i, p2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a trick because Elm doesn't support tuples with more than 3 elements isn't it? Maybe use a record like {prv, cur, nxt, sub}
for previous, current, next/sequent, subsequent? Or maybe (prv, cur, (nxt, sub))
when using tuples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was because the control points are calculated based on the slope between m1
and p1
and then i
and p2`. But I think you're right that it would make more sense just to put them all in order here. Using a record would be a bit more readable but I need to use tuples to be able to destructure the x and y values in the case expression below.
fontFamily : String | ||
fontFamily = | ||
"Caveat" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better:
fontFamily : String | |
fontFamily = | |
"Caveat" | |
font : Font | |
font = | |
Font "Caveat" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem is I'm using this string to load the Google font below. Pretty hacky, let me know if I should take that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there is not a real nice way to solve this, isn't it? Maybe use both?
fontFamily : String
fontFamily =
"Caveat"
font : Font
font =
Font fontFamily
render : Flow -> Collage msg | ||
render flow = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's my own fault, that I used a custom formatter, but I take you didn't change much or anything at all in this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, yeah sorry about all the formatting changes, accidentally ran elm-format on this one. I did just change one thing in this function - I made the connecting line stop at the sides of the diamond instead of running behind it where it's visible behind the sketched fill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
The formatting thing is actually my fault, as I used a custom formatter. (I don't like four space indentations and find all the newlines between case branches way to much noise...) As elm-format is the community standard, I could run it on all source files and make a commit on master, you can do the same and rebase on that? Or would that give us a lot of whitespace errors?
BTW, what I forgot to write down yesterday before a colleague walked in, the |
Yeah, that's correct. Maybe rename it to On a related note, if we added a real bezier curve API as discussed in #8, then I could improve the browser performance significantly by rendering the hachure fills as one svg |
Thanks for the review @timjs! I've made the changes you requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added two minor comments.
As written above, the formatting thing is actually my fault, as I used a custom formatter. (I don't like four space indentations and find all the newlines between case branches way to much noise... A simple function in Elm can easily fall off my screen!)
As elm-format is the community standard, I could run it on all source files and make a commit on master, you can do the same and rebase on that? Or would that give us a lot of whitespace errors?
fontFamily : String | ||
fontFamily = | ||
"Caveat" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there is not a real nice way to solve this, isn't it? Maybe use both?
fontFamily : String
fontFamily =
"Caveat"
font : Font
font =
Font fontFamily
Yep, I tried rebasing but it results in too many whitespace errors. An alternative could be to run |
let | ||
text = | ||
fromString label | ||
|> Text.typeface (Text.Font fontFamily) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|> Text.typeface (Text.Font fontFamily) | |
|> Text.typeface font |
Hi @chipjacks, Sorry for the delay, was on a holiday ⛰🥾 Merged your other two pull requests. Next steps will be to rebase this one on current master, and I'll merg it! Thanks for all the great work and the constructive discussions 😄 |
Based on excalidraw, rough.js, and this research paper, this allows transforming a collage into a randomized sketchy, hand-drawn version.
The only change I've made to the core modules is to add an API for drawing a
curve
through a set of points. Admittedly, I don't know much about all the different ways to accomplish this, so I just opted for the simplest implementation I could find.I've added a way to toggle examples between normal and sketchy rendering and I think the flowchart example best captures the look I was shooting for:
This is still pretty rough around the edges (hehe), and I'm not entirely sure it belongs inside this package. Maybe would make more sense as a fork or some kind of extension - open to ideas! @timjs any thoughts?