-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
#25-Transparency #193
#25-Transparency #193
Conversation
Bug flipped if boolean to avoid dots appearing in highlights
Remove errant import
Generate opacity icons in a loop Cleanup the proof of concept into a cleaner working code
Cleanup more superflous code. Its amazing how you can see the excess on the third or fourth commit.
It just dawned on me that these variable are really not useful anymore allow25Percent allow50Percent allow75Percent
@edemaine -- also, I've kept changing the PR all day, but I think I have it where I'm now ready for you to tear it apart. |
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.
Thanks for the PR, and sorry for the delay in reviewing! This is definitely on the right track, and is probably pretty close to being done. But I have a bunch of comments to do things in more Cocreate ways. If you'd rather do [some of] them, e.g. it's unclear what I mean, let me know.
client/lib/icons.coffee
Outdated
'opacity50': | ||
'<circle cx="250" cy="250" r="200" fill-opacity="0.50"/>' | ||
'opacity75': | ||
'<circle cx="250" cy="250" r="200" fill-opacity="0.75"/>' |
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 think it would be better to draw these in the tool itself, like we do with line width.
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. √
client/tools/color.coffee
Outdated
click: (e) -> selectColorOrFill e, color | ||
click: (e) -> | ||
selectColorOrFill e, color | ||
updateColorOpacity() |
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.
Should't need an explicit update call here; should use reactivity instead.
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.
√
client/tools/settings.coffee
Outdated
@@ -15,6 +17,8 @@ export dark = new storage.Variable 'dark', false | |||
|
|||
Tracker.autorun -> | |||
dom.classSet document.body, 'dark', dark.get() | |||
allowTransparency.set false | |||
currentOpacity.set 1.0 |
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 almost certainly the wrong place for this code. Tracker.autorun
reruns this code whenever the dependencies (here, dark.get()
) change. I don't think you want to reset these things whenever dark mode changes.
client/tools/settings.coffee
Outdated
@@ -81,3 +85,44 @@ defineTool | |||
click: -> | |||
return unless (room = currentRoom.get())? | |||
room.gridSnap.set not room.gridSnap.get() | |||
|
|||
defineTool | |||
name: 'Transparency' |
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.
Lower case for consistency
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.
√
client/RenderObjects.coffee
Outdated
@@ -53,14 +55,15 @@ export class RenderObjects | |||
class: 'pen' | |||
, | |||
dataset: id: id | |||
if simple | |||
if simple or allowTransparency.valueCur != true |
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 (and test above) seems wrong: you're using simple rendering whenever the transparency tool is currently active. To see this fail, do some transparent drawing, and then reload the board: everything will be opaque. You should instead be looking at whether the object itself has transparency.
Also, should document that pressure sensitivity doesn't work with transparency mode. I think that's probably better than the messy dots along the way (until we can support actual transparency with varying line thickness, via <path>
rendering).
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.
yep ... I didn't quite understand what was going on in my first pass but I knew that the darn dots were ruining my beautiful transparent stroke.
client/tools/settings.coffee
Outdated
|
||
|
||
# These values are chosen for no particular reason. I saw that | ||
# 12.5 was a number you liked for highlighting Perhaps .25 should be 12.5 |
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.
Where did you see 12.5? Ah, 0x20 in #139. That's not me, but may be useful guideline. I'll need to experiment.
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.
√
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 leave this to your wysdom
client/tools/settings.coffee
Outdated
allowTransparency.set not allowTransparency.get() | ||
updateOpacity 1.0, allowTransparency.curValue | ||
init: -> | ||
updateOpacity 1.0, false |
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.
Calls to updateOpacity
should be replaced with just setOpacity
.
client/tools/settings.coffee
Outdated
|
||
buttons = document.querySelectorAll('[data-tool^="Opacity"]') | ||
for button in buttons | ||
button.style.display = if display then "block" else "none" |
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.
Since the move to React, we don't want to manipulate widget DOM directly like this. Instead, add to DrawApp something like:
transparency = useTracker -> allowTransparency.get()
...
{if transparency
<div id="opacities" className="subpalette">
<ToolCategory category="opacity" placemen="top"/>
</div>
}
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.
thanks for making that easier for me
client/tools/settings.coffee
Outdated
allowTransparency.set display | ||
|
||
if currentOpacity.get() == val | ||
currentOpacity.set 1.0 |
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 don't like resetting currentOpacity
to 1 when toggling the mode off. I'd rather keep the same opacity when I leave and re-enter transparent mode. Similar to how fill mode works, we should have a Boolean currentOpacityOn
, which should replace the current allowTransparency
.
Similarly, I don't like that clicking on the transparent mode for the first time doesn't immediately turn on transparency. It (and thus currentOpacity
) should start at a global default (maybe 50%?), so one of the specific buttons starts down as well.
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.
bye bye allowTransparency. √
lib/objects.coffee
Outdated
@@ -44,11 +44,13 @@ Meteor.methods | |||
pts: [xywType] | |||
color: String | |||
width: Number | |||
opacity: Number |
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.
These should probably be made optional in the same way as 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.
I think I did it right but I basically aped some other code
@edemaine I think I hit most or all of your changes. Thanks - it should be much more cocreate-y |
@flooie Please push your changes... |
@edemaine lol - thats embarrassing. |
… 25-add-transparency
Thanks @flooie for working on this! I'm excited to play around with it (and we'll see whether 25, 50, 75 are the right options in practice). It'll be deployed within the next ~30 minutes. |
PR Adds support for transparent pen, rect and ellipses.
I think this is more of a Draft than an actual PR, but I think it could be helpful to get some quick pointers.
It enables support for transparency, and while rather straightforward I do see some potential improvements, in both tool icon generation - tool color and toggling.