question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to connect a large number of lines or erase to a specific point?

See original GitHub issue

Hi there. This is not a problem, but a question.

I’m creating an app that uses a map to show a line that shows what people have passed through. Draw multiple people (about 100 people) on one side.

You can set the time by moving the slider and connect the line from 0 seconds to the set time.

The data it holds is an array of {x, y}. It is arranged in tenths of a second increments. (For example, if the data is from “0 seconds to 30 minutes”, there is an array of 18,000 per person in length.)

I tried to connect the lineTo() of new PIXI.Graphics() several times to make this happen.

However, it is also possible to turn back time by moving the slider.

If you connect a line to a Graphics object with lineTo(), you can make more lines, but you can’t make them go back to an arbitrary line.

So I came up with a way to create a number of new PIXI.Graphics(), connect the object to the time, and display the objects up to the time set by the slider.

But this would require creating 18000 objects * 100 people of Graphics objects.

It’s easy to imagine that this will obviously have an impact on performance even before it’s implemented.

I can only think of a way to use Pixi this way. Will you help me?

I don’t know if it exists, but is it possible to give a name to, say, lineTo() and then remove it with that name?

Thank you.

pixi.js version: 5.2.1 Browser & Version: Latest chrome version OS & Version: Windows 10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ivanpopelyshevcommented, Apr 15, 2020

I didnt have time to review it yet. Maybe I wont before next week 😦

1reaction
KagiJPNcommented, Apr 10, 2020

@ivanpopelyshev I did as I was told, debugging and doing my best. What we have found is that the value of “points” has changed.

Create a graphicsData object in “graphics.geometry.graphicsData.push()”

    for (var i = 0; i < 100; i++) {
        let graphics = new PIXI.Graphics();
        graphics.lineStyle(4, getRandomColor());
        viewport.addChild(graphics);

        graphicsArr.push({
            graphics: graphics,
            location: getRondomLocations()
        })

        //graphics.moveTo(graphicsArr[i].location[0].x, graphicsArr[i].location[0].y)
        graphics.geometry.graphicsData.push(new PIXI.GraphicsData(new PIXI.Polygon(),new PIXI.LineStyle(),new PIXI.LineStyle()))
    }

Manipulate the “graphicsData[0].points” and “graphicsData[0].shape” points and call “invalidate()”.

        for (var j = 0; j < 30; j++) {
            if (now > oldNow) {
                for (let i = 0; i < now - oldNow; i++) {
                    //graphicsArr[j].graphics.moveTo(graphicsArr[j].location[now - 1 - i].x, graphicsArr[j].location[now - 1 - i].y)
                    //graphicsArr[j].graphics.lineTo(graphicsArr[j].location[now - i].x, graphicsArr[j].location[now - i].y)
                    graphicsArr[j].graphics.geometry.graphicsData[0].points.push(graphicsArr[j].location[now - i].x)
                    graphicsArr[j].graphics.geometry.graphicsData[0].points.push(graphicsArr[j].location[now - i].y)
                    graphicsArr[j].graphics.geometry.graphicsData[0].shape.points.push(graphicsArr[j].location[now - i].x)
                    graphicsArr[j].graphics.geometry.graphicsData[0].shape.points.push(graphicsArr[j].location[now - i].y)
                }
                graphicsArr[j].graphics.geometry.invalidate();
                console.log(graphicsArr[j].graphics.geometry.graphicsData)
            } else if (now < oldNow) {
                for (let i = 0; i < oldNow - now; i++) {
                    graphicsArr[j].graphics.geometry.graphicsData[0].points.pop()
                    graphicsArr[j].graphics.geometry.graphicsData[0].points.pop()
                    graphicsArr[j].graphics.geometry.graphicsData[0].shape.points.pop()
                    graphicsArr[j].graphics.geometry.graphicsData[0].shape.points.pop()
                }
                graphicsArr[j].graphics.geometry.invalidate();
                console.log(graphicsArr[j].graphics.geometry.graphicsData)
            }
        }

I tried to implement it like this, but it doesn’t work.

Any little bit of help would be greatly appreciated.

https://jsfiddle.net/takeshi1234/yjstLrw8/2/

Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Draw or delete a line or connector - Microsoft Support
To work with multiple lines, select the first line, and then press and hold Ctrl while you select the other lines. On the...
Read more >
Select range of lines in notepad++ - Stack Overflow
Easiest way for big files: Ctrl + G , go to line 1000. Menu > Edit > Begin/End select . Ctrl + G...
Read more >
How do I remove the first 300 million lines from a 700 GB txt ...
Use chunk's filename to store line numbers. After that you will end with completely erased big file and lots of much smaller files...
Read more >
How to Delete a Line in VIM {All, Multiple, Range) - phoenixNAP
1. Firstly use Esc to move to normal mode. 2. Then, remove all the lines that contain a specific word by typing:
Read more >
Python Delete Lines From a File [4 Ways] - PYnative
Learn How to remove lines from a file by line numbers. Remove lines that match the specific text. Delete first and Last lines...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found