#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. |
edemaine
left a comment
There was a problem hiding this comment.
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.
| '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.
I think it would be better to draw these in the tool itself, like we do with line width.
| click: (e) -> selectColorOrFill e, color | ||
| click: (e) -> | ||
| selectColorOrFill e, color | ||
| updateColorOpacity() |
There was a problem hiding this comment.
Should't need an explicit update call here; should use reactivity instead.
| Tracker.autorun -> | ||
| dom.classSet document.body, 'dark', dark.get() | ||
| allowTransparency.set false | ||
| currentOpacity.set 1.0 |
There was a problem hiding this comment.
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.
| room.gridSnap.set not room.gridSnap.get() | ||
|
|
||
| defineTool | ||
| name: 'Transparency' |
| , | ||
| dataset: id: id | ||
| if simple | ||
| if simple or allowTransparency.valueCur != true |
There was a problem hiding this comment.
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.
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.
|
|
||
|
|
||
| # 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.
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.
I leave this to your wysdom
| allowTransparency.set not allowTransparency.get() | ||
| updateOpacity 1.0, allowTransparency.curValue | ||
| init: -> | ||
| updateOpacity 1.0, false |
There was a problem hiding this comment.
Calls to updateOpacity should be replaced with just setOpacity.
|
|
||
| buttons = document.querySelectorAll('[data-tool^="Opacity"]') | ||
| for button in buttons | ||
| button.style.display = if display then "block" else "none" No newline at end of file |
There was a problem hiding this comment.
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.
thanks for making that easier for me
| allowTransparency.set display | ||
|
|
||
| if currentOpacity.get() == val | ||
| currentOpacity.set 1.0 |
There was a problem hiding this comment.
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.
bye bye allowTransparency. √
| pts: [xywType] | ||
| color: String | ||
| width: Number | ||
| opacity: Number |
There was a problem hiding this comment.
These should probably be made optional in the same way as fill.
There was a problem hiding this comment.
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.