SimonBuxx / LogiJS

Discover and create logic circuits
https://logijs.com
GNU General Public License v3.0
42 stars 6 forks source link

Previews of Basic components before adding to canvas #57

Closed crisbbi closed 5 years ago

crisbbi commented 6 years ago

Added an enhancement so the user knows where the component will be placed. The preview symbol has less alpha, so it's slightly more transparent. Works for now only with basic components. Also reduced the mouse dragging of the grid so the relative position of the mouse to the grid is always the same. In other words if you now hold the right mouse button and the pointer is in the middle of a grid square, after dragging, the pointer will afterwards still be on the same spot in the middle of the same grid square.

SimonBuxx commented 6 years ago

Thank you! I really like this idea but the performance is very poor (try shaking the mouse and look at the fps). Also, preview objects don't disappear when clicking a button under "advanced". But I'll see how I can integrate this. I like the idea with the lower drag speed but the cursor only stays at the same position at 100% zoom. Maybe, we could adapt this to work for all zoom levels.

crisbbi commented 6 years ago

Just checked the issues mentioned about the performance drop. Tested with the given cpu design and in fact the fps go down, which might be because of the redraw() method always calling when the mouse moves, so the preview has to be drawn again too and additional code has to be executed. It might be just on my machine but even when shaking the mouse very fastly the drop isn't noticeable, even if fps go down. Additionally, even if the fps go down, it shouldn't have that big of an impact, as the user is in editing mode and all he could do is just add the component. What I forgot about is the preview which just stops when clicking on an advanced component, as I meant to add them as preview too but wasn't able to implement it yet and, as just said, forgot about that. So either change the preview symbol to null for now, when clicking on an advanced component or somehow change the code in a way to make the previews available.

SimonBuxx commented 5 years ago

Did something similar to this, also this request has various conflicts by now.