-
Notifications
You must be signed in to change notification settings - Fork 657
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
Support custom line thickness #31
Comments
It is generated code, but I edit it directly to add imperative stuff as necessary. I am happy to make the I have reservations about your suggestions though. I do not like the idea that The second suggestion seems to hinge on functions like Here's my long term plan for forms, shapes, and lines. I'd like to have functions like:
And once there are typeclasses, I'd like to make To get the default behavior you are describing, maybe there could be functions like:
Where SB is "solid black". Or maybe |
Thanks, you make very good points. I'd still like to see a styling system that can be extended without breakage. Another idea might be:
Thus, |
I like this approach more. It is similar to how I ended up changing the HTTP library (old, new). Also, I really really like the name There are still some ambiguities that can be avoided though. For example:
I'll try an API now, keeping an eye on these docs so that it is as general as possible. This first part is about filling shapes and lines:
This next part is about lines:
I believe that none of this should cause any breaking changes. As a side note, this seems like a fun function:
Which would return the position that is some percentage along the given path. This might make it easier to move forms around in a nice way. |
Maybe Also, this is much more complicated than I anticipated! |
I am also really tempted to totally rename type |
Also, maybe rename |
My two cents: don't worry about it! You have the same situation in imperative code:
in JavaScript object notation:
and even in Haskell's Data.Map:
In all of these cases, "blue" overrides "black" because it is listed last. So for:
Just make |
Sorry for the delay, I have been without internet for a bit. I see the convenience of it, but I think the larger issue is "how do you do optional arguments in a functional language with type inference?" and as far as I know, there is not a nice way to do it. I think maps and dictionaries are not comparable because that is a problem where types cannot rule out ambiguities and conflicts. An association list can have duplicate keys and (short of dependent types) that's just the way it is. So That said, your proposal appears to be simple and nice. I am not sure if it would end up being simpler once it is fully fleshed out, but I suspect it might. My biggest hesitation is that I have never seen an API like this in a functional language in a comparable situation (i.e. when types could be used to resolve ambiguities). Do you know of any libraries or languages that expose APIs like the one you suggest? If not, why should Elm be the first language to do so? |
This got added! It's definitely in 0.8 and 0.9 :) |
Elm currently does not let you set the thickness of a line. Actually, you can make thick lines using
scale
, but you have to tweak your coordinates.I suppose the API could be this:
This would set the thickness of lines, both for polygon edges (coming from Shape) and line paths (coming from Line).
While we're at it, it would be nice if
line
andsegment
returned aForm
instead of aLine
. It's annoying to have to specify the style and color of a line just to get it on the page:I'd rather just say:
and have it default to a solid black line.
I would tackle this, but Element.js looks like it came from a code generator. Do you have the original Elm source, or do you just tweak the generated code now?
The text was updated successfully, but these errors were encountered: