nkh / P5-App-Asciio

Plain ASCII diagram
https://nkh.github.io/P5-App-Asciio/
53 stars 4 forks source link

Complete cross mode #129

Closed nkh closed 10 months ago

nkh commented 10 months ago
qindapao commented 10 months ago

@nkh I completed the cross pattern of all characters and optimized the code to make the logic simpler. But it is still written manually. As for the advanced method you mentioned, I will study it when I have time.

This is the finished branch, there are many use cases and it will take time to test, I wouldn't be able to finish them today without vim.

https://github.com/qindapao/P5-App-Asciio/tree/complete_cross

qindapao commented 10 months ago

@nkh As for the cross mode of the connector, I may not have fully understood what you meant yesterday. Let's discuss it later when we are free. My vacation ends today.

qindapao commented 10 months ago

image

Now bold lines and thin lines can also crossing, creating a lot of scenarios.

nkh commented 10 months ago

@qindapao looking good, when you are done with your test I'll merge it.

nkh commented 10 months ago

connector cross mode is a mode where the cross module returns an overlay only if the position being checked is also a connector.

The "normal" cross mode is good for making graphics.

connector cross mode is good for making connections look good.

The efficient way to compute that is to eliminate all the positions where there is no connectors.

If we use code like the example below we may not need to change a single line in the cross module because the caller of get_overlays can send a Z buffer that will not return a stack for a position without connector. So we don't have to implement anything in the cross module.

sub get_overlays
{
my ($asciio, $Z_buffer, $fillers, $start_x, $end_x, $start_y, $end_y)  = @_ ;
...
qindapao commented 10 months ago

@nkh There are too many cross mode functions. I optimized them and reduced the code by 1,000 lines.

https://github.com/qindapao/P5-App-Asciio/tree/cross_mode_code_optimization

I haven't fixed the BUG of the boundary problem yet. When I have time, I will solve it first by rebuilding the 2D array. As for the advanced method you mentioned, how about we implement it in 2.0? Because I'm busy at work again, I don't have much time.

nkh commented 10 months ago

@qindapao 1000 lines less is great!

nkh commented 10 months ago

@qindapao merged

The code is much more readable!

It will be easier to optimize in the future if necessary, I checked some timing.

I drew 20 boxes and 20 arrays heavily overlapping each other in cross mode.

computation time
array 0.0035 sec.
overlays 0.0010 sec.

I think the 2D array should be handed to the Cross module by Asciio; I'll have a look at that.