问:
Wagtail rendering of referenced objects in an InlinePanel
In my Article pageModel I have an InlinePanel('technologies', label="Technologies"), which loads up an ArticlesPageTechnologies(Orderable) which is using PageChooserPanel('technologies', 'rb_tech_portfolio.TechnologiesPage'),.

This is all working nicely.  But what I want to do is to list links to these referenced pages, but I cannot seem to work out the best way to do this.  The closest I have gotten is with {% for technology in page.technologies.all %} but this simply gives me the object which connects the 2 page models, whereas I want the referenced object.  Is this all there ready to use, or do I need to do an extra query in def_context to do this?

Thanks,
Dan

Technologies Inline panel

```<code>class ArticlesPageTechnologies(Orderable):
    page = ParentalKey(ArticlesPage, on_delete=models.CASCADE, related_name='technologies')

    technologies = models.ForeignKey(
        'wagtailcore.Page',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )

    panels = [
        PageChooserPanel('technologies', 'rb_tech_portfolio.TechnologiesPage'),
    ]
</code>```

Page Model for Articles

```<code>class ArticlesPage(Page):
    body = RichTextField(blank=True)
    thumbnail = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    content_panels = Page.content_panels + [
        FieldPanel('body', classname="full"),
        ImageChooserPanel('thumbnail'),
        InlinePanel('technologies', label="Technologies"),
    ]

    def get_context(self, request, *args, **kwargs):
        """Adding custom stuff to our context."""
        context = super().get_context(request, *args, **kwargs)
        # Get all posts
        posts = ArticlesPage.objects.live().public().order_by('-date')[:5]

        context["posts"] = posts
        return context
</code>```

Articles Page Template

```<code>{% extends "base.html" %}

{% block body_class %}template-article{% endblock %}

{% block content %}
{% comment %}
{% for post in posts %}
{{ post.url }}
{% endfor %}
{% endcomment %}

<div class="row">
  <div class="col-9 col-12-medium">
    <section>
      <header>
        <h1>{{ page.title }}</h1>
      </header>
      {{ page.body|safe }}
    </section>
    </ul>
  </div>
  <div class="col-3 col-12-medium">

    <!-- Sidebar -->
    <section>

      <header>
        <h2>Technologies</h2>
      </header>

      <ul class="link-list">
        {% for technology in page.technologies.all %}
          <li>{{ technology.select_related.title }}</li>
        {% endfor %}
      </ul>

    </section>

  </div>
</div>

{% endblock content %}
</code>```

答:
This should work:

```<code> {% for technology in page.technologies.all %}
     <li>{{ technology.technologies.title }}</li>
 {% endfor %}
</code>```

If this looks a little confusing it's because your ArticlesPageTechnologies model uses technologies in a slightly confusing way. Each ArticlesPageTechnologies object links a single technology to your page, not multiple ones - the multiplicity is achieved by having several such objects in your InlinePanel.

I would suggest you rename the tehnologies foreign key to technology to reflect this fact. If you do that then your template logic (functionally identical to the above, but with hopefully more understandable variables names) would be:

```<code> {% for page_technology in page.technologies.all %}
     <li>{{ page_technology.technology.title }}</li>
 {% endfor %}
</code>```

Body:
In my Article pageModel I have an InlinePanel('technologies', label="Technologies"), which loads up an ArticlesPageTechnologies(Orderable) which is using PageChooserPanel('technologies', 'rb_tech_portfolio.TechnologiesPage'),.

This is all working nicely.  But what I want to do is to list links to these referenced pages, but I cannot seem to work out the best way to do this.  The closest I have gotten is with {% for technology in page.technologies.all %} but this simply gives me the object which connects the 2 page models, whereas I want the referenced object.  Is this all there ready to use, or do I need to do an extra query in def_context to do this?

Thanks,
Dan

Technologies Inline panel

class ArticlesPageTechnologies(Orderable):
    page = ParentalKey(ArticlesPage, on_delete=models.CASCADE, related_name='technologies')

    technologies = models.ForeignKey(
        'wagtailcore.Page',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )

    panels = [
        PageChooserPanel('technologies', 'rb_tech_portfolio.TechnologiesPage'),
    ]

Page Model for Articles

class ArticlesPage(Page):
    body = RichTextField(blank=True)
    thumbnail = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    content_panels = Page.content_panels + [
        FieldPanel('body', classname="full"),
        ImageChooserPanel('thumbnail'),
        InlinePanel('technologies', label="Technologies"),
    ]

    def get_context(self, request, *args, **kwargs):
        """Adding custom stuff to our context."""
        context = super().get_context(request, *args, **kwargs)
        # Get all posts
        posts = ArticlesPage.objects.live().public().order_by('-date')[:5]

        context["posts"] = posts
        return context

Articles Page Template

{% extends "base.html" %}

{% block body_class %}template-article{% endblock %}

{% block content %}
{% comment %}
{% for post in posts %}
{{ post.url }}
{% endfor %}
{% endcomment %}

{{ page.title }}

      {{ page.body|safe }}

Technologies

        {% for technology in page.technologies.all %}

{{ technology.select_related.title }}

        {% endfor %}

{% endblock content %}

Body:
This should work:

 {% for technology in page.technologies.all %}
     <li>{{ technology.technologies.title }}</li>
 {% endfor %}

If this looks a little confusing it's because your ArticlesPageTechnologies model uses technologies in a slightly confusing way. Each ArticlesPageTechnologies object links a single technology to your page, not multiple ones - the multiplicity is achieved by having several such objects in your InlinePanel.

I would suggest you rename the tehnologies foreign key to technology to reflect this fact. If you do that then your template logic (functionally identical to the above, but with hopefully more understandable variables names) would be:

 {% for page_technology in page.technologies.all %}
     <li>{{ page_technology.technology.title }}</li>
 {% endfor %}


来源: stackexchange

问:
Fieldset HTML Styling using CSS
I have 5 fieldsets which I want to layout in a particular design.
All have the same width, but may have different heights.

```<code>┌-[Fieldset 1]----┐
|                 |
|                 |
└-----------------┘
┌-[Fieldset 2]----┐  ┌-[Fieldset 3]----┐
|                 |  |                 |
|                 |  |                 |
|                 |  |                 |
└-----------------┘  └-----------------┘
┌-[Fieldset 4]----┐  ┌-[Fieldset 5]----┐
|                 |  |                 |
|                 |  |                 |
|                 |  |                 |
|                 |  |                 |
└-----------------┘  └-----------------┘
</code>```

in my HTML source, I want to make the source "clean", which removes any unnecessary formatting tags which include "br" and "p". The container of the fieldsets is set to the full width of the window.

The only way where I can style in it this structure currently, is by placing "br" elements after the fieldsets I want to move to the next line:

```<code><fieldset style='width:200px;'><legend>Fieldset1</legend></fieldset><br/>
<fieldset style='width:200px;'><legend>Fieldset2</legend></fieldset>
<fieldset style='width:200px;'><legend>Fieldset3</legend></fieldset><br/>
<fieldset style='width:200px;'><legend>Fieldset4</legend></fieldset>
<fieldset style='width:200px;'><legend>Fieldset5</legend></fieldset>
</code>```

The container which holds the fieldsets is actually the full length of the screen, (ie:100%). If I take out the "br"s the fieldsets line-up next to each other in a haphazard way.

I have tried various ways to align and adjust the fieldsets in the order that I want them using CSS including using float, clear, padding-left but to no avail.

Is there a proper methodology using CSS that can be applied to get the desired effect wanted as shown above?

thankyou.

答:
use

```<code>.fld{float:left;}
.fld1{float:left;}
</code>```

class .fld for 2 and 3rd fieldset.
class .fld1 for 4 and 5 fieldset.

Here is the working example:http://jsfiddle.net/anish/xaZDC/

ContentLicense: CC BY-SA 3.0

Title: Fieldset HTML Styling using CSS

Body:
I have 5 fieldsets which I want to layout in a particular design.
All have the same width, but may have different heights.

┌-[Fieldset 1]----┐
|                 |
|                 |
└-----------------┘
┌-[Fieldset 2]----┐  ┌-[Fieldset 3]----┐
|                 |  |                 |
|                 |  |                 |
|                 |  |                 |
└-----------------┘  └-----------------┘
┌-[Fieldset 4]----┐  ┌-[Fieldset 5]----┐
|                 |  |                 |
|                 |  |                 |
|                 |  |                 |
|                 |  |                 |
└-----------------┘  └-----------------┘

in my HTML source, I want to make the source "clean", which removes any unnecessary formatting tags which include "br" and "p". The container of the fieldsets is set to the full width of the window.

The only way where I can style in it this structure currently, is by placing "br" elements after the fieldsets I want to move to the next line:

<fieldset style='width:200px;'><legend>Fieldset1</legend></fieldset>

<fieldset style='width:200px;'><legend>Fieldset2</legend></fieldset>
<fieldset style='width:200px;'><legend>Fieldset3</legend></fieldset>

<fieldset style='width:200px;'><legend>Fieldset4</legend></fieldset>
<fieldset style='width:200px;'><legend>Fieldset5</legend></fieldset>

The container which holds the fieldsets is actually the full length of the screen, (ie:100%). If I take out the "br"s the fieldsets line-up next to each other in a haphazard way.

I have tried various ways to align and adjust the fieldsets in the order that I want them using CSS including using float, clear, padding-left but to no avail.

Is there a proper methodology using CSS that can be applied to get the desired effect wanted as shown above?

thankyou.

Body:
use

.fld{float:left;}
.fld1{float:left;}

class .fld for 2 and 3rd fieldset.
class .fld1 for 4 and 5 fieldset.

Here is the working example:http://jsfiddle.net/anish/xaZDC/


问:
Mirth, transform a simple tag value of inbound xml file
I would like to use mirth in the following scenario:
1. Receive a xml file
2. Change value of a tag if this tag has a specific value
3. Outbound the resulting xml

So i've in mirth a filereader inbound connector and a filewriter outbound connector.
How can i transform this xml:

```<code><?xml version="1.0" encoding="ISO-8859-1" ?>
<R>
  <NDOSM />
  <NADM>20060552</NADM>
  <DATECONS>20200205</DATECONS>
  <PRODNR />
  <PRODUCTID>1602235</PRODUCTID>
  <PRODUCTDESC>relaxine compr. pellic. 500 mg</PRODUCTDESC>
  <QTY>1.0</QTY>
  <PARSTOCKID>ethilog</PARSTOCKID>
  <PRIX />
  <STUPNR />
  <MEDNR>16822372</MEDNR>
  <CODEIDENTIFICATION />
  <SERIALNO />
  <NOMARGE />
  <PATIENTNAME>CLINT</PATIENTNAME>
  <PATIENTLASTNAME>EASTWOOD</PATIENTLASTNAME>
  <DATEOFBIRTH>19420910</DATEOFBIRTH>
  <LOTNR />
  <SERVICE />
  <SERVICEDIST>160</SERVICEDIST>
  <KEYFROMPM>20200205163309_05604132</KEYFROMPM>
  <TYPEMOUVEMENT>PREDISPOSITION</TYPEMOUVEMENT>
  <ANNULATION>N</ANNULATION>
  <PARSTOCKID-DOTATION />
  <COMMENTAIREMVT />
</R>
</code>```

in this one

```<code><?xml version="1.0" encoding="ISO-8859-1" ?>
<R>
  <NDOSM />
  <NADM>20060552</NADM>
  <DATECONS>20200205</DATECONS>
  <PRODNR />
  <PRODUCTID>1602235</PRODUCTID>
  <PRODUCTDESC>relaxine compr. pellic. 500 mg</PRODUCTDESC>
  <QTY>1.0</QTY>
  <PARSTOCKID>51</PARSTOCKID>
  <PRIX />
  <STUPNR />
  <MEDNR>16822372</MEDNR>
  <CODEIDENTIFICATION />
  <SERIALNO />
  <NOMARGE />
  <PATIENTNAME>CLINT</PATIENTNAME>
  <PATIENTLASTNAME>EASTWOOD</PATIENTLASTNAME>
  <DATEOFBIRTH>19420910</DATEOFBIRTH>
  <LOTNR />
  <SERVICE />
  <SERVICEDIST>160</SERVICEDIST>
  <KEYFROMPM>20200205163309_05604132</KEYFROMPM>
  <TYPEMOUVEMENT>PREDISPOSITION</TYPEMOUVEMENT>
  <ANNULATION>N</ANNULATION>
  <PARSTOCKID-DOTATION />
  <COMMENTAIREMVT />
</R>
</code>```

I must change inbound xml only if value of tag PARSTOCKID is ethilog. In this case, i've to replace ethilog by 51.
I've tried a couple of thing without success :(

Thanks

答:
This is pretty straightforward to do with a javascript step in mirth.</p>

```<code>if (msg.PARSTOCKID.toString() == 'ethilog') {
    msg.PARSTOCKID = '51';
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I would like to use mirth in the following scenario:
1. Receive a xml file
2. Change value of a tag if this tag has a specific value
3. Outbound the resulting xml

So i've in mirth a filereader inbound connector and a filewriter outbound connector.
How can i transform this xml:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<R>
  <NDOSM />
  <NADM>20060552</NADM>
  <DATECONS>20200205</DATECONS>
  <PRODNR />
  <PRODUCTID>1602235</PRODUCTID>
  <PRODUCTDESC>relaxine compr. pellic. 500 mg</PRODUCTDESC>
  <QTY>1.0</QTY>
  <PARSTOCKID>ethilog</PARSTOCKID>
  <PRIX />
  <STUPNR />
  <MEDNR>16822372</MEDNR>
  <CODEIDENTIFICATION />
  <SERIALNO />
  <NOMARGE />
  <PATIENTNAME>CLINT</PATIENTNAME>
  <PATIENTLASTNAME>EASTWOOD</PATIENTLASTNAME>
  <DATEOFBIRTH>19420910</DATEOFBIRTH>
  <LOTNR />
  <SERVICE />
  <SERVICEDIST>160</SERVICEDIST>
  <KEYFROMPM>20200205163309_05604132</KEYFROMPM>
  <TYPEMOUVEMENT>PREDISPOSITION</TYPEMOUVEMENT>
  <ANNULATION>N</ANNULATION>
  <PARSTOCKID-DOTATION />
  <COMMENTAIREMVT />
</R>

in this one

<?xml version="1.0" encoding="ISO-8859-1" ?>
<R>
  <NDOSM />
  <NADM>20060552</NADM>
  <DATECONS>20200205</DATECONS>
  <PRODNR />
  <PRODUCTID>1602235</PRODUCTID>
  <PRODUCTDESC>relaxine compr. pellic. 500 mg</PRODUCTDESC>
  <QTY>1.0</QTY>
  <PARSTOCKID>51</PARSTOCKID>
  <PRIX />
  <STUPNR />
  <MEDNR>16822372</MEDNR>
  <CODEIDENTIFICATION />
  <SERIALNO />
  <NOMARGE />
  <PATIENTNAME>CLINT</PATIENTNAME>
  <PATIENTLASTNAME>EASTWOOD</PATIENTLASTNAME>
  <DATEOFBIRTH>19420910</DATEOFBIRTH>
  <LOTNR />
  <SERVICE />
  <SERVICEDIST>160</SERVICEDIST>
  <KEYFROMPM>20200205163309_05604132</KEYFROMPM>
  <TYPEMOUVEMENT>PREDISPOSITION</TYPEMOUVEMENT>
  <ANNULATION>N</ANNULATION>
  <PARSTOCKID-DOTATION />
  <COMMENTAIREMVT />
</R>

I must change inbound xml only if value of tag PARSTOCKID is ethilog. In this case, i've to replace ethilog by 51.
I've tried a couple of thing without success :(

Thanks

Body:
This is pretty straightforward to do with a javascript step in mirth.

if (msg.PARSTOCKID.toString() == 'ethilog') {
    msg.PARSTOCKID = '51';
}


问:
React: "Module not found: Can't resolve" Path error
I have this code in my src/components:

```<code>import PropTypes from 'prop-types';
import React from 'react';
import Typography from 'Typography';
</code>```

I have one file named Typography.js in the same directory.

I have two Ubuntu systems.  In one system, this code is working fine, and in the other, it gives this error on line 3:

Module not found: Can't resolve 'Typography'

If I use import Typography from './Typography'; then it won't give me the error, but why does the same code work on one system but not the other?

Should I have used import Typography from './Typography'; everywhere?

here is my
webpack-config

```<code>resolve: {
    modules: ['node_modules', paths.appNodeModules].concat(
      process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
    ),
    extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
    alias: {
      'babel-runtime': path.dirname(
        require.resolve('babel-runtime/package.json')
      ),
      'react-native': 'react-native-web',
    },
    plugins: [
      new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
    ],
  }
</code>```

答:
I have the same problem when trying to use a front end template, in which they always use

```<code>import Typography from 'Typography';
</code>```

instead of the relative path:

```<code>import Typography from './Typography'
</code>```

And the template actually works in one laptop, and not the other.

And it seems to have something to do with the environment variable NODE_PATH, some how it is different between laptops, I am not sure why.

So, my quick fix here is to create a file named .env in the same folder as package.json, with this one line NODE_PATH=./src, this will helps setting NODE_PATH to ./src value.

Err, hope you still need the answer!

Body:
I have this code in my src/components:

import PropTypes from 'prop-types';
import React from 'react';
import Typography from 'Typography';

I have one file named Typography.js in the same directory.

I have two Ubuntu systems.  In one system, this code is working fine, and in the other, it gives this error on line 3:

Module not found: Can't resolve 'Typography'

If I use import Typography from './Typography'; then it won't give me the error, but why does the same code work on one system but not the other?

Should I have used import Typography from './Typography'; everywhere?

here is my
webpack-config

resolve: {
    modules: ['node_modules', paths.appNodeModules].concat(
      process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
    ),
    extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
    alias: {
      'babel-runtime': path.dirname(
        require.resolve('babel-runtime/package.json')
      ),
      'react-native': 'react-native-web',
    },
    plugins: [
      new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
    ],
  }

Body:
I have the same problem when trying to use a front end template, in which they always use

import Typography from 'Typography';

instead of the relative path:

import Typography from './Typography'

And the template actually works in one laptop, and not the other.

And it seems to have something to do with the environment variable NODE_PATH, some how it is different between laptops, I am not sure why.

So, my quick fix here is to create a file named .env in the same folder as package.json, with this one line NODE_PATH=./src, this will helps setting NODE_PATH to ./src value.

Err, hope you still need the answer!


问:
Losing content when i convert html to pdf with jsPDF
In my React App (client-side) i have a button to create a pdf using the current html content with jsPDF. I'm using .html() instead of .fromHTML() because i need to keep the html styles in the pdf conversion. The Real Problem is when i use html() i lost a lot of content for the row/col structure of the page. So, i need to scale my html content into the pdf, but i don't know how to do it.

My code:

```<code>let doc = new jsPDF('p', 'pt', 'a4')
    let source = document.getElementById('pdfContent')

    doc.html( source, {
        callback: function (doc) {
            doc.save();
        }
     });
</code>```

答:
By "lost a lot of content" if you meant your content cannot fit into an a4 page then you can either make your page larger, say using a3 instead of a4, or you may shrink the content by using scale in html2canvas. The scale can be calculated based on your page format and element size.

```<code>let doc = new jsPDF('p', 'pt', 'a4')

doc.html(document.getElementById('pdfContent'), {
    html2canvas: {
        scale: [yourScaleHere],
    },
    x: [margin],
    y: [margin],
    callback: function (doc) {
        window.open(doc.output('bloburl'));
    }
});
</code>```

If you don't need a standard page size, you may just set the page according to your content. e.g. let pdf = new jsPDF('p', 'pt', [612, 1200]);

Body:
In my React App (client-side) i have a button to create a pdf using the current html content with jsPDF. I'm using .html() instead of .fromHTML() because i need to keep the html styles in the pdf conversion. The Real Problem is when i use html() i lost a lot of content for the row/col structure of the page. So, i need to scale my html content into the pdf, but i don't know how to do it.

My code:

let doc = new jsPDF('p', 'pt', 'a4')
    let source = document.getElementById('pdfContent')

    doc.html( source, {
        callback: function (doc) {
            doc.save();
        }
     });

Body:
By "lost a lot of content" if you meant your content cannot fit into an a4 page then you can either make your page larger, say using a3 instead of a4, or you may shrink the content by using scale in html2canvas. The scale can be calculated based on your page format and element size.

let doc = new jsPDF('p', 'pt', 'a4')

doc.html(document.getElementById('pdfContent'), {
    html2canvas: {
        scale: [yourScaleHere],
    },
    x: [margin],
    y: [margin],
    callback: function (doc) {
        window.open(doc.output('bloburl'));
    }
});

If you don't need a standard page size, you may just set the page according to your content. e.g. let pdf = new jsPDF('p', 'pt', [612, 1200]);


问:
How to implement onHover event with Catalyst?
Is it possible for a mouse onHover event with Mac Catalyst using SwiftUI?

onHover(perform:) is only available for macOS now.

答:
```<code>class SomeOfMyView: UIView {
    // 1. Make sure you save default color upon init
    var color: UIColor?
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
            if #available(iOS 13.0, *) {
                // 2. add hover gesture
                let hover = UIHoverGestureRecognizer(target: self, action: #selector(self.hovering(_:)))
                self.addGestureRecognizer(hover)
                // 3. saving default color
                self.color = self.backgroundColor
            }
        }
    }

    @available(iOS 13.0, *)
    @objc func hovering(_ recognizer: UIHoverGestureRecognizer) {
        // 4. upon hover we change color.
        switch recognizer.state {
            case .began, .changed:
                backgroundColor = .lightGray
            case .ended:
                backgroundColor = color
            default:
                backgroundColor = color
        }
    }
</code>```


问:
HTML5 Canvas ctx.fill() fills outside the stroke area
I am working with the virtual sky library, https://github.com/slowe/VirtualSky. The library tries to show a visual representation of the sky. The library is built on html canvas. In the original code, the milky way line is drawn as a line with ctx.stroke() and everything works fine. I tried adding ctx.fill() to fill in the milky way area but for some coordinates/dates canvas fills outside the stroked area. I added the two images that represents the issue. In the filled version, notice that it fills also some other area outside the milky way line. I spent much time on the issue but couldn't figure out why the canvas fills outside the drawn area.

Without ctx.fill()

With ctx.fill()

Here is the code that draws the Milky Way line :

```<code>VirtualSky.prototype.drawGalaxy = function(colour){
    if(!this.galaxy || !this.showgalaxy) return this;
    if(!colour) colour = this.col.galaxy;
    this.ctx.beginPath();
    this.ctx.strokeStyle = colour;
    this.ctx.fillStyle = "rgba(255,255,255,0.4)";
    this.ctx.lineWidth = (this.gal.lineWidth || 0.75);
    this.ctx.lineJoin = "round";
    var p,pa,pb,i,c,maxl,dx,dy;
    maxl = this.maxLine(5);

    for(c = 0; c < this.galaxy.length; c++){

        // We will convert all the galaxy outline coordinates to radians
        if(!this.gal.processed){
            for(i = 1; i < this.galaxy[c].length; i++) this.galaxy[c][i] *= this.d2r;
        }

        // Get a copy of the current shape
        p = this.galaxy[c].slice(0);

        // Get the colour (first element)
        p.shift();
        // Set the initial point to null
        pa = null;

        // Now loop over joining the points
        for(i = 0; i < p.length; i+=2){
            pb = this.radec2xy(p[i], p[i+1]);
            if(i==0) this.ctx.moveTo(pb.x,pb.y);
            else{
                dx = Math.abs(pa.x-pb.x);
                dy = Math.abs(pa.y-pb.y);
                if(!isNaN(dx) && !isNaN(dy)){
                    // Basic error checking: if the line is very long we need to normalize to other side of sky
                    if(dx >= maxl || dy >= maxl) this.ctx.moveTo(pb.x,pb.y);
                    this.ctx.lineTo(pb.x,pb.y);
                }else{
                    this.ctx.moveTo(pb.x,pb.y);
                }
            }
            pa = pb;
        }
    }
    // We've converted the galaxy to radians
    this.gal.processed = true;
    this.ctx.stroke();

    this.ctx.fill();

//  I added this ctx.fill() here which causes the problem.

    return this;
};
</code>```

Json data for the milky way lines

{
  "galaxy": [
    ["#396bad", 254.1778, -21.5124, 253.6146, -22.5310, 253.2638, -27.7008, 251.9368, -29.7742, 249.7919, -29.7867, 247.8000, -28.4406, 246.5570, -26.9571, 244.6278, -25.8787, 242.5067, -26.0070, 241.5945, -25.3687, 240.7208, -23.0525, 239.5973, -22.3533, 238.6863, -23.5322, 238.7180, -25.7313, 239.4131, -28.0723, 238.6475, -30.8747, 239.9512, -34.4963, 240.4545, -37.0030, 238.8220, -39.1709, 235.6101, -41.6744, 234.5926, -42.9833, 235.6221, -44.6917, 235.5743, -46.4283, 232.6913, -48.4186, 228.3087, -49.7552, 225.9823, -50.6267, 221.4249, -52.5289, 216.0338, -54.6596, 209.0229, -55.3209, 202.9102, -56.0362, 196.2626, -56.3616, 191.7337, -57.1169, 184.7426, -59.1857, 180.5514, -58.8402, 175.1997, -58.5802, 170.6339, -57.6749, 168.3549, -56.2380, 163.3607, -54.7001, 159.2106, -51.3301, 154.8495, -47.2975, 150.0574, -45.2411, 146.8211, -44.7221, 145.5418, -45.4794, 145.6709, -46.1571, 149.5391, -48.3145, 150.7915, -49.6707, 150.0747, -51.0247, 147.4159, -49.8497, 144.3472, -47.8592, 142.7713, -47.5886, 142.7304, -48.1825, 141.8590, -48.7921, 143.8702, -51.7563, 146.7533, -53.8733, 146.7337, -54.7900, 145.4937, -55.0315, 136.3994, -53.7185, 133.1890, -53.9932, 132.3952, -55.2722, 133.9782, -56.3603, 137.5581, -56.8447, 142.3823, -56.7640, 147.1253, -56.7384, 149.2668, -57.3424, 151.0831, -57.4354, 153.9265, -58.4216, 157.9421, -58.9774, 159.0422, -59.6771, 157.5067, -60.3507, 155.1830, -59.7783, 151.9601, -59.2083, 149.2887, -59.3163, 148.3379, -59.9243, 149.9157, -61.4340, 154.0475, -62.1249, 155.9994, -62.2575, 159.2582, -63.5263, 165.5091, -63.4204, 167.1619, -62.8290, 170.1596, -61.3662, 172.9661, -61.4156, 176.0518, -62.9133, 179.3437, -64.2607, 181.9387, -65.3282, 184.3779, -69.3924, 188.2568, -70.9570, 194.7347, -71.2607, 199.7570, -70.2394, 204.1730, -68.8427, 209.0938, -67.8511, 216.7510, -68.0095, 221.9748, -67.1396, 227.5494, -66.2461, 234.5158, -64.3854, 240.5233, -61.8468, 244.0983, -60.4173, 251.3801, -59.1124, 253.2926, -57.4685, 254.7774, -56.3244, 261.4819, -54.4899, 265.8676, -50.8482, 268.8085, -48.0793, 269.9543, -46.3469, 270.5405, -43.6313, 270.6492, -42.3809, 271.0668, -41.1083, 273.1271, -38.6387, 274.8287, -36.5477, 276.5511, -33.8477, 275.4040, -33.1596, 275.2727, -30.5290, 276.8968, -28.1703, 277.9533, -25.4297, 278.6386, -22.3113, 279.4081, -19.7351, 280.9230, -17.4472, 281.9964, -15.6719, 282.8788, -13.6664, 283.3409, -11.0282, 284.5659, -8.4787, 285.8740, -5.6156, 287.7313, -3.1057, 289.7038, -1.0941, 290.4044, -0.0164, 290.7342, 1.1813, 291.9363, 0.4122, 292.8626, 0.7917, 295.5690, 0.8033, 297.0695, 1.1497, 297.0874, 2.1407, 295.9694, 2.3815, 294.6764, 2.5679, 294.4415, 3.7745, 295.0541, 5.1814, 296.9021, 5.9879, 297.7330, 6.5454, 297.6053, 8.4351, 298.6240, 10.2040, 298.1628, 13.5562, 299.1257, 15.5289, 302.8713, 15.4981, 305.5156, 16.1286, 308.1366, 16.6469, 308.7496, 18.5262, 307.5513, 19.8431, 307.7080, 20.7394, 309.0176, 21.5802, 308.7945, 23.5149, 309.4605, 24.2478, 310.5891, 24.9863, 310.3480, 26.0982, 308.9284, 26.8788, 309.1600, 27.5971, 311.8741, 29.1431, 313.3279, 32.0552, 313.9435, 35.1102, 314.9513, 36.1769, 319.2157, 38.0107, 320.5720, 39.7440, 321.0403, 40.9232, 321.8310, 41.6873, 323.6238, 44.8754, 325.1386, 46.0919, 328.0798, 46.8738, 332.6317, 47.1238, 338.1292, 47.4766, 344.7038, 47.6502, 346.4796, 47.7702, 351.3753, 46.7280, 355.1420, 46.2097, 359.5920, 46.1929, 4.3035, 46.2481, 8.0516, 45.6862, 10.5201, 45.7218, 12.3781, 45.1055, 16.3043, 45.2972, 19.0389, 44.8213, 23.6309, 45.0223, 30.7979, 43.0638, 32.8210, 42.8635, 40.6571, 43.7653, 43.6189, 43.8484, 46.6891, 42.5931, 45.3773, 41.6641, 41.7099, 41.8080, 39.3969, 41.6311, 36.5579, 40.8644, 36.3328, 39.9578, 39.0080, 38.9254, 43.4828, 39.0665, 47.0254, 39.2746, 50.5370, 39.3676, 53.6788, 39.5428, 55.7670, 38.8688, 57.1481, 37.3216, 57.2361, 35.7482, 56.6404, 33.7143, 57.1765, 32.1478, 58.8043, 30.8405, 59.9439, 30.9968, 61.4966, 33.3066, 61.4994, 36.0547, 61.1808, 38.6650, 61.7684, 40.0026, 63.8402, 40.1004, 71.4989, 34.6769, 75.3343, 31.9184, 79.7168, 29.0407, 81.0519, 25.1195, 82.1320, 22.0941, 83.6308, 17.4698, 85.5679, 15.1690, 86.9568, 12.6324, 87.7444, 8.8192, 91.3008, 6.1831, 92.8266, 2.6539, 94.6923, -2.1965, 97.7264, -6.0265, 102.5525, -9.6439, 104.6125, -11.6416, 105.1552, -14.2536, 108.2256, -18.5894, 109.6456, -25.3483, 111.2200, -27.2135, 111.2669, -32.1720, 114.7741, -37.8718, 116.9787, -42.4014, 117.0836, -45.1959, 116.1853, -48.6868, 118.8947, -50.1703, 123.5005, -49.9484, 125.9819, -48.8761, 122.1675, -44.3179, 122.4135, -42.9137, 124.6591, -42.8292, 129.1849, -46.1315, 132.5020, -47.4562, 134.3955, -47.4750, 135.7144, -46.3461, 131.5066, -42.8910, 132.0107, -42.0135, 137.8183, -45.2697, 139.3131, -45.0639, 139.6524, -44.1094, 136.9034, -40.6399, 136.6626, -38.9913, 139.6753, -40.1504, 144.8151, -42.6899, 150.5786, -42.3526, 153.6316, -43.0367, 155.7573, -42.5342, 156.1233, -41.0904, 152.5690, -38.5605, 148.4971, -37.7767, 141.2865, -38.2886, 135.1421, -35.9600, 129.8501, -32.1764, 126.2320, -28.4253, 122.1594, -21.3427, 118.5304, -12.7577, 116.3335, -8.7013, 112.8556, -6.4334, 109.1321, -2.3025, 108.1548, 0.0096, 107.9889, 5.4587, 106.7266, 8.9737, 103.4908, 11.8896, 101.3959, 15.0964, 99.5314, 17.7842, 97.6915, 19.7759, 96.9057, 21.2016, 90.6296, 24.9510, 88.0744, 27.4918, 86.0675, 31.0217, 85.2336, 32.7789, 81.6446, 36.8533, 79.8386, 39.1558, 78.6539, 44.2051, 77.5234, 45.5296, 73.0840, 46.1406, 69.0884, 46.5652, 66.4784, 48.5322, 65.0187, 50.6773, 63.1096, 51.4737, 60.4311, 51.8441, 60.2604, 52.7052, 63.6488, 52.7609, 65.6099, 53.0495, 68.0178, 52.7517, 68.0826, 53.7533, 63.1671, 54.9872, 57.4967, 55.4868, 58.4393, 56.1385, 60.5618, 56.2369, 62.6651, 56.7553, 62.6924, 57.7129, 59.3107, 59.2013, 50.7444, 59.4785, 45.7503, 59.6435, 43.3097, 60.6511, 38.7256, 61.5348, 35.7107, 62.5099, 30.2614, 62.7058, 27.5803, 63.4145, 23.1877, 65.0421, 18.5579, 65.6747, 13.7778, 67.5849, 11.2150, 68.1610, 7.5359, 67.6326, 5.1034, 66.7569, 2.2150, 66.1991, 0.2476, 66.2511, 355.2714, 64.4260, 350.1006, 62.9385, 344.4302, 62.4847, 339.3002, 60.4931, 333.4702, 58.8851, 331.1327, 59.4605, 330.9382, 61.9623, 340.6152, 65.1092, 343.2879, 66.7647, 343.3581, 70.1643, 341.1773, 70.8790, 336.6449, 73.1299, 333.5813, 75.1391, 324.6186, 76.5981, 322.6315, 75.9427, 319.0891, 73.7015, 314.8850, 71.0639, 315.6348, 68.7048, 315.4588, 66.8973, 313.0831, 64.8622, 312.0635, 62.5880, 314.0142, 60.2312, 313.6305, 59.4861, 311.8591, 59.3915, 309.8048, 58.5233, 310.2041, 57.1819, 306.9144, 55.9804, 304.6804, 54.7702, 305.2319, 53.7273, 307.7332, 52.9357, 308.4628, 52.2243, 308.0011, 51.7205, 306.5029, 51.7495, 304.1552, 50.3598, 302.5798, 48.5193, 302.1408, 47.1988, 300.7148, 46.6004, 299.0278, 47.0595, 297.2437, 46.8711, 295.7553, 46.0584, 294.7485, 44.4314, 292.7755, 41.4764, 288.6933, 39.1997, 287.4471, 37.8510, 287.5118, 36.7221, 289.2538, 36.0606, 290.9985, 36.0011, 292.6594, 35.2362, 292.3950, 34.1260, 291.2070, 33.2023, 288.4240, 33.0160, 287.0090, 32.3231, 286.5059, 31.2666, 287.0896, 29.6223, 286.5820, 27.3683, 285.1771, 25.5062, 283.1010, 23.9449, 281.0469, 22.8010, 279.4373, 21.4068, 279.1821, 19.6473, 279.7551, 18.2109, 280.9496, 17.7421, 282.6220, 17.1833, 283.2966, 16.1546, 283.0965, 15.0372, 281.5283, 14.0053, 280.0909, 12.9151, 278.6961, 11.5975, 277.0707, 10.5385, 275.4225, 9.5688, 273.4622, 8.5487, 270.9916, 7.3738, 269.3157, 5.7621, 268.8705, 4.4507, 269.5389, 3.1987, 271.0927, 2.6855, 273.2811, 2.5608, 275.4739, 3.3006, 278.1912, 5.0780, 281.9090, 8.5271, 284.1697, 11.3576, 286.2251, 14.0132, 286.3233, 15.1915, 286.1158, 15.5100, 285.7599, 16.6912, 286.7631, 18.2914, 287.1951, 19.3787, 286.9849, 20.8446, 289.3257, 22.5391, 291.9464, 25.4127, 292.4286, 28.5332, 293.4593, 30.5996, 297.2230, 32.4772, 299.7133, 35.0595, 303.4745, 35.0807, 304.1266, 34.0245, 303.6819, 30.3270, 300.8895, 28.8322, 296.8912, 28.3993, 294.9144, 27.6937, 294.5657, 26.6140, 296.1041, 25.9037, 297.3739, 25.6845, 297.8246, 24.4710, 295.9400, 22.7956, 293.0649, 21.4866, 291.1229, 20.8588, 290.3240, 19.7277, 290.6364, 18.7692, 292.0849, 18.3219, 293.1902, 17.8198, 293.1968, 16.4933, 292.2117, 15.0311, 290.2679, 13.8513, 288.7569, 12.5900, 288.6076, 10.9218, 288.7328, 9.7665, 287.2839, 8.8429, 285.5820, 8.1189, 284.2910, 7.0396, 283.2366, 5.8411, 282.9327, 3.8283, 282.5522, 3.2275, 280.8435, 2.7268, 279.3674, 2.2532, 278.3224, 1.3453, 278.2314, 0.7429, 279.1609, 1.5654, 279.5029, 0.9574, 279.8970, -0.2562, 281.6814, -0.8823, 283.4665, -1.5073, 284.0658, -2.4642, 282.9599, -3.4894, 281.1068, -3.6991, 279.0490, -4.0172, 278.1079, -5.1256, 278.2582, -6.7990, 279.0976, -9.4057, 278.6578, -11.6460, 277.3170, -14.1578, 276.1600, -16.6976, 275.8960, -19.1108, 275.5302, -21.8370, 274.9452, -24.2398, 272.9984, -26.4299, 270.0613, -28.0668, 268.2229, -29.8114, 268.5228, -30.2623, 267.9381, -32.1320, 267.1568, -33.2373, 265.0719, -33.6050, 262.2933, -32.3327, 261.2061, -30.0066, 261.2532, -27.8653, 261.7517, -26.3868, 262.0161, -24.8538, 263.5809, -22.8788, 265.0658, -21.1691, 265.8074, -19.4150, 266.6842, -18.7916, 268.0278, -18.7995, 268.7521, -17.4910, 268.3084, -15.3906, 266.9707, -13.3787, 264.9872, -12.4603, 262.4372, -12.2113, 260.5499, -13.2122, 258.4769, -14.8956, 256.1174, -16.7507, 254.4650, -18.3043, 253.6343, -20.3552, 254.1778, -21.5124, 254.1778, -21.5124, 254.1778, -21.5124],
    ["#396bad", 257.4284, -35.0782, 258.7567, -34.6776, 259.6113, -33.6806, 259.9750, -32.7946, 260.9776, -32.5946, 263.4189, -33.7211, 265.2841, -35.1551, 267.0684, -37.0106, 266.5317, -38.4758, 264.8234, -39.1661, 263.0403, -38.8168, 260.6629, -38.1140, 258.3247, -38.4735, 255.5110, -38.1878, 254.0470, -37.3602, 253.5295, -36.1222, 253.7763, -35.4603, 254.7476, -35.1875, 256.2938, -35.0264, 257.4284, -35.0782, 257.4284, -35.0782, 257.4284, -35.0782],
    ["#396bad", 254.4847, -39.5230, 255.2762, -39.2671, 257.3657, -39.9243, 258.7042, -41.3823, 258.3749, -43.2682, 257.0644, -43.3665, 254.3218, -40.8215, 254.6242, -40.4285, 254.4847, -39.5230, 254.4847, -39.5230, 254.4847, -39.5230],
    ["#396bad", 247.9505, -43.8132, 247.7714, -42.7233, 248.2105, -41.7101, 249.7280, -40.8373, 248.8720, -37.3180, 247.1054, -36.2799, 245.6020, -36.7984, 243.1195, -35.6949, 242.2253, -36.0340, 241.9943, -38.6050, 241.6221, -40.6326, 239.8163, -43.0489, 238.8334, -44.6762, 238.5119, -46.8016, 237.7857, -49.0401, 236.8718, -50.6695, 237.0713, -52.3828, 238.9693, -53.2821, 241.4236, -52.3398, 244.7950, -51.3601, 248.9798, -51.6343, 253.4436, -51.0624, 257.8767, -50.6966, 260.9423, -50.2581, 261.6140, -49.2459, 260.7624, -46.4869, 260.5888, -45.3986, 259.8614, -44.8904, 257.7870, -44.9484, 256.1962, -45.7995, 256.3613, -48.5425, 253.5419, -49.9573, 249.8040, -49.5087, 248.3220, -49.4156, 245.7227, -48.7635, 244.6261, -48.0299, 245.6396, -46.7119, 247.9407, -46.1849, 251.5170, -45.7312, 252.8143, -45.1508, 251.9638, -44.5626, 249.5206, -44.4962, 247.9505, -43.8132, 247.9505, -43.8132, 247.9505, -43.8132],
    ["#396bad", 231.8281, -52.4833, 233.5614, -52.5365, 234.4273, -52.7145, 236.0044, -53.8647, 236.5304, -55.8352, 237.3389, -57.1286, 230.3741, -58.8315, 226.4955, -59.1351, 221.0867, -60.4628, 220.9820, -59.2769, 221.7242, -59.0271, 223.2728, -57.1869, 226.5641, -55.0286, 228.1040, -54.5097, 229.9674, -52.9922, 231.8281, -52.4833, 231.8281, -52.4833, 231.8281, -52.4833],
    ["#396bad", 191.9931, -60.9308, 195.0383, -60.9157, 197.2513, -61.5730, 197.6589, -63.3081, 193.3910, -65.2609, 190.6198, -65.3102, 189.1651, -65.7997, 187.9019, -65.8296, 187.4866, -64.7787, 188.0292, -64.2788, 187.2718, -63.6037, 188.0759, -62.2722, 190.6559, -61.1093, 191.9931, -60.9308, 191.9931, -60.9308],
    ["#396bad", 132.7337, -37.5805, 133.0861, -38.9333, 132.3284, -39.7468, 129.7569, -39.4258, 127.1207, -38.0660, 124.9328, -36.1447, 124.8899, -34.6079, 124.7196, -32.9119, 125.9376, -32.1253, 127.3543, -32.6954, 128.6915, -33.7875, 129.6263, -35.1366, 131.7847, -36.5415, 132.7337, -37.5805, 132.7337, -37.5805],
    ["#396bad", 121.1825, -39.3994, 119.9070, -39.0295, 119.2840, -37.6001, 119.3245, -36.1550, 117.3621, -34.3430, 116.3134, -31.1424, 115.5167, -28.5014, 115.3112, -26.0891, 115.8367, -24.7060, 117.0334, -24.5218, 117.8897, -25.7087, 118.5145, -28.1509, 119.6664, -31.5362, 121.7083, -34.8713, 122.3366, -37.4519, 122.1419, -39.0037, 121.1825, -39.3994, 121.1825, -39.3994],
    ["#396bad", 305.9982, 40.1858, 309.8895, 39.3472, 311.2759, 37.2754, 311.2100, 35.4356, 310.1900, 34.7837, 308.6971, 34.9849, 307.5461, 36.5500, 305.0697, 37.7876, 304.5142, 39.0978, 305.1288, 40.0209, 305.9982, 40.1858]
  ]
}
```

Body:
I am working with the virtual sky library, https://github.com/slowe/VirtualSky. The library tries to show a visual representation of the sky. The library is built on html canvas. In the original code, the milky way line is drawn as a line with ctx.stroke() and everything works fine. I tried adding ctx.fill() to fill in the milky way area but for some coordinates/dates canvas fills outside the stroked area. I added the two images that represents the issue. In the filled version, notice that it fills also some other area outside the milky way line. I spent much time on the issue but couldn't figure out why the canvas fills outside the drawn area.

Without ctx.fill()

With ctx.fill()

Here is the code that draws the Milky Way line :

VirtualSky.prototype.drawGalaxy = function(colour){
    if(!this.galaxy || !this.showgalaxy) return this;
    if(!colour) colour = this.col.galaxy;
    this.ctx.beginPath();
    this.ctx.strokeStyle = colour;
    this.ctx.fillStyle = "rgba(255,255,255,0.4)";
    this.ctx.lineWidth = (this.gal.lineWidth || 0.75);
    this.ctx.lineJoin = "round";
    var p,pa,pb,i,c,maxl,dx,dy;
    maxl = this.maxLine(5);

    for(c = 0; c < this.galaxy.length; c++){

        // We will convert all the galaxy outline coordinates to radians
        if(!this.gal.processed){
            for(i = 1; i < this.galaxy[c].length; i++) this.galaxy[c][i] *= this.d2r;
        }

        // Get a copy of the current shape
        p = this.galaxy[c].slice(0);

        // Get the colour (first element)
        p.shift();
        // Set the initial point to null
        pa = null;

        // Now loop over joining the points
        for(i = 0; i
= maxl || dy >= maxl) this.ctx.moveTo(pb.x,pb.y);
                    this.ctx.lineTo(pb.x,pb.y);
                }else{
                    this.ctx.moveTo(pb.x,pb.y);
                }
            }
            pa = pb;
        }
    }
    // We've converted the galaxy to radians
    this.gal.processed = true;
    this.ctx.stroke();

    this.ctx.fill();

//  I added this ctx.fill() here which causes the problem.

    return this;
};

Json data for the milky way lines

{
  "galaxy": [
    ["#396bad", 254.1778, -21.5124, 253.6146, -22.5310, 253.2638, -27.7008, 251.9368, -29.7742, 249.7919, -29.7867, 247.8000, -28.4406, 246.5570, -26.9571, 244.6278, -25.8787, 242.5067, -26.0070, 241.5945, -25.3687, 240.7208, -23.0525, 239.5973, -22.3533, 238.6863, -23.5322, 238.7180, -25.7313, 239.4131, -28.0723, 238.6475, -30.8747, 239.9512, -34.4963, 240.4545, -37.0030, 238.8220, -39.1709, 235.6101, -41.6744, 234.5926, -42.9833, 235.6221, -44.6917, 235.5743, -46.4283, 232.6913, -48.4186, 228.3087, -49.7552, 225.9823, -50.6267, 221.4249, -52.5289, 216.0338, -54.6596, 209.0229, -55.3209, 202.9102, -56.0362, 196.2626, -56.3616, 191.7337, -57.1169, 184.7426, -59.1857, 180.5514, -58.8402, 175.1997, -58.5802, 170.6339, -57.6749, 168.3549, -56.2380, 163.3607, -54.7001, 159.2106, -51.3301, 154.8495, -47.2975, 150.0574, -45.2411, 146.8211, -44.7221, 145.5418, -45.4794, 145.6709, -46.1571, 149.5391, -48.3145, 150.7915, -49.6707, 150.0747, -51.0247, 147.4159, -49.8497, 144.3472, -47.8592, 142.7713, -47.5886, 142.7304, -48.1825, 141.8590, -48.7921, 143.8702, -51.7563, 146.7533, -53.8733, 146.7337, -54.7900, 145.4937, -55.0315, 136.3994, -53.7185, 133.1890, -53.9932, 132.3952, -55.2722, 133.9782, -56.3603, 137.5581, -56.8447, 142.3823, -56.7640, 147.1253, -56.7384, 149.2668, -57.3424, 151.0831, -57.4354, 153.9265, -58.4216, 157.9421, -58.9774, 159.0422, -59.6771, 157.5067, -60.3507, 155.1830, -59.7783, 151.9601, -59.2083, 149.2887, -59.3163, 148.3379, -59.9243, 149.9157, -61.4340, 154.0475, -62.1249, 155.9994, -62.2575, 159.2582, -63.5263, 165.5091, -63.4204, 167.1619, -62.8290, 170.1596, -61.3662, 172.9661, -61.4156, 176.0518, -62.9133, 179.3437, -64.2607, 181.9387, -65.3282, 184.3779, -69.3924, 188.2568, -70.9570, 194.7347, -71.2607, 199.7570, -70.2394, 204.1730, -68.8427, 209.0938, -67.8511, 216.7510, -68.0095, 221.9748, -67.1396, 227.5494, -66.2461, 234.5158, -64.3854, 240.5233, -61.8468, 244.0983, -60.4173, 251.3801, -59.1124, 253.2926, -57.4685, 254.7774, -56.3244, 261.4819, -54.4899, 265.8676, -50.8482, 268.8085, -48.0793, 269.9543, -46.3469, 270.5405, -43.6313, 270.6492, -42.3809, 271.0668, -41.1083, 273.1271, -38.6387, 274.8287, -36.5477, 276.5511, -33.8477, 275.4040, -33.1596, 275.2727, -30.5290, 276.8968, -28.1703, 277.9533, -25.4297, 278.6386, -22.3113, 279.4081, -19.7351, 280.9230, -17.4472, 281.9964, -15.6719, 282.8788, -13.6664, 283.3409, -11.0282, 284.5659, -8.4787, 285.8740, -5.6156, 287.7313, -3.1057, 289.7038, -1.0941, 290.4044, -0.0164, 290.7342, 1.1813, 291.9363, 0.4122, 292.8626, 0.7917, 295.5690, 0.8033, 297.0695, 1.1497, 297.0874, 2.1407, 295.9694, 2.3815, 294.6764, 2.5679, 294.4415, 3.7745, 295.0541, 5.1814, 296.9021, 5.9879, 297.7330, 6.5454, 297.6053, 8.4351, 298.6240, 10.2040, 298.1628, 13.5562, 299.1257, 15.5289, 302.8713, 15.4981, 305.5156, 16.1286, 308.1366, 16.6469, 308.7496, 18.5262, 307.5513, 19.8431, 307.7080, 20.7394, 309.0176, 21.5802, 308.7945, 23.5149, 309.4605, 24.2478, 310.5891, 24.9863, 310.3480, 26.0982, 308.9284, 26.8788, 309.1600, 27.5971, 311.8741, 29.1431, 313.3279, 32.0552, 313.9435, 35.1102, 314.9513, 36.1769, 319.2157, 38.0107, 320.5720, 39.7440, 321.0403, 40.9232, 321.8310, 41.6873, 323.6238, 44.8754, 325.1386, 46.0919, 328.0798, 46.8738, 332.6317, 47.1238, 338.1292, 47.4766, 344.7038, 47.6502, 346.4796, 47.7702, 351.3753, 46.7280, 355.1420, 46.2097, 359.5920, 46.1929, 4.3035, 46.2481, 8.0516, 45.6862, 10.5201, 45.7218, 12.3781, 45.1055, 16.3043, 45.2972, 19.0389, 44.8213, 23.6309, 45.0223, 30.7979, 43.0638, 32.8210, 42.8635, 40.6571, 43.7653, 43.6189, 43.8484, 46.6891, 42.5931, 45.3773, 41.6641, 41.7099, 41.8080, 39.3969, 41.6311, 36.5579, 40.8644, 36.3328, 39.9578, 39.0080, 38.9254, 43.4828, 39.0665, 47.0254, 39.2746, 50.5370, 39.3676, 53.6788, 39.5428, 55.7670, 38.8688, 57.1481, 37.3216, 57.2361, 35.7482, 56.6404, 33.7143, 57.1765, 32.1478, 58.8043, 30.8405, 59.9439, 30.9968, 61.4966, 33.3066, 61.4994, 36.0547, 61.1808, 38.6650, 61.7684, 40.0026, 63.8402, 40.1004, 71.4989, 34.6769, 75.3343, 31.9184, 79.7168, 29.0407, 81.0519, 25.1195, 82.1320, 22.0941, 83.6308, 17.4698, 85.5679, 15.1690, 86.9568, 12.6324, 87.7444, 8.8192, 91.3008, 6.1831, 92.8266, 2.6539, 94.6923, -2.1965, 97.7264, -6.0265, 102.5525, -9.6439, 104.6125, -11.6416, 105.1552, -14.2536, 108.2256, -18.5894, 109.6456, -25.3483, 111.2200, -27.2135, 111.2669, -32.1720, 114.7741, -37.8718, 116.9787, -42.4014, 117.0836, -45.1959, 116.1853, -48.6868, 118.8947, -50.1703, 123.5005, -49.9484, 125.9819, -48.8761, 122.1675, -44.3179, 122.4135, -42.9137, 124.6591, -42.8292, 129.1849, -46.1315, 132.5020, -47.4562, 134.3955, -47.4750, 135.7144, -46.3461, 131.5066, -42.8910, 132.0107, -42.0135, 137.8183, -45.2697, 139.3131, -45.0639, 139.6524, -44.1094, 136.9034, -40.6399, 136.6626, -38.9913, 139.6753, -40.1504, 144.8151, -42.6899, 150.5786, -42.3526, 153.6316, -43.0367, 155.7573, -42.5342, 156.1233, -41.0904, 152.5690, -38.5605, 148.4971, -37.7767, 141.2865, -38.2886, 135.1421, -35.9600, 129.8501, -32.1764, 126.2320, -28.4253, 122.1594, -21.3427, 118.5304, -12.7577, 116.3335, -8.7013, 112.8556, -6.4334, 109.1321, -2.3025, 108.1548, 0.0096, 107.9889, 5.4587, 106.7266, 8.9737, 103.4908, 11.8896, 101.3959, 15.0964, 99.5314, 17.7842, 97.6915, 19.7759, 96.9057, 21.2016, 90.6296, 24.9510, 88.0744, 27.4918, 86.0675, 31.0217, 85.2336, 32.7789, 81.6446, 36.8533, 79.8386, 39.1558, 78.6539, 44.2051, 77.5234, 45.5296, 73.0840, 46.1406, 69.0884, 46.5652, 66.4784, 48.5322, 65.0187, 50.6773, 63.1096, 51.4737, 60.4311, 51.8441, 60.2604, 52.7052, 63.6488, 52.7609, 65.6099, 53.0495, 68.0178, 52.7517, 68.0826, 53.7533, 63.1671, 54.9872, 57.4967, 55.4868, 58.4393, 56.1385, 60.5618, 56.2369, 62.6651, 56.7553, 62.6924, 57.7129, 59.3107, 59.2013, 50.7444, 59.4785, 45.7503, 59.6435, 43.3097, 60.6511, 38.7256, 61.5348, 35.7107, 62.5099, 30.2614, 62.7058, 27.5803, 63.4145, 23.1877, 65.0421, 18.5579, 65.6747, 13.7778, 67.5849, 11.2150, 68.1610, 7.5359, 67.6326, 5.1034, 66.7569, 2.2150, 66.1991, 0.2476, 66.2511, 355.2714, 64.4260, 350.1006, 62.9385, 344.4302, 62.4847, 339.3002, 60.4931, 333.4702, 58.8851, 331.1327, 59.4605, 330.9382, 61.9623, 340.6152, 65.1092, 343.2879, 66.7647, 343.3581, 70.1643, 341.1773, 70.8790, 336.6449, 73.1299, 333.5813, 75.1391, 324.6186, 76.5981, 322.6315, 75.9427, 319.0891, 73.7015, 314.8850, 71.0639, 315.6348, 68.7048, 315.4588, 66.8973, 313.0831, 64.8622, 312.0635, 62.5880, 314.0142, 60.2312, 313.6305, 59.4861, 311.8591, 59.3915, 309.8048, 58.5233, 310.2041, 57.1819, 306.9144, 55.9804, 304.6804, 54.7702, 305.2319, 53.7273, 307.7332, 52.9357, 308.4628, 52.2243, 308.0011, 51.7205, 306.5029, 51.7495, 304.1552, 50.3598, 302.5798, 48.5193, 302.1408, 47.1988, 300.7148, 46.6004, 299.0278, 47.0595, 297.2437, 46.8711, 295.7553, 46.0584, 294.7485, 44.4314, 292.7755, 41.4764, 288.6933, 39.1997, 287.4471, 37.8510, 287.5118, 36.7221, 289.2538, 36.0606, 290.9985, 36.0011, 292.6594, 35.2362, 292.3950, 34.1260, 291.2070, 33.2023, 288.4240, 33.0160, 287.0090, 32.3231, 286.5059, 31.2666, 287.0896, 29.6223, 286.5820, 27.3683, 285.1771, 25.5062, 283.1010, 23.9449, 281.0469, 22.8010, 279.4373, 21.4068, 279.1821, 19.6473, 279.7551, 18.2109, 280.9496, 17.7421, 282.6220, 17.1833, 283.2966, 16.1546, 283.0965, 15.0372, 281.5283, 14.0053, 280.0909, 12.9151, 278.6961, 11.5975, 277.0707, 10.5385, 275.4225, 9.5688, 273.4622, 8.5487, 270.9916, 7.3738, 269.3157, 5.7621, 268.8705, 4.4507, 269.5389, 3.1987, 271.0927, 2.6855, 273.2811, 2.5608, 275.4739, 3.3006, 278.1912, 5.0780, 281.9090, 8.5271, 284.1697, 11.3576, 286.2251, 14.0132, 286.3233, 15.1915, 286.1158, 15.5100, 285.7599, 16.6912, 286.7631, 18.2914, 287.1951, 19.3787, 286.9849, 20.8446, 289.3257, 22.5391, 291.9464, 25.4127, 292.4286, 28.5332, 293.4593, 30.5996, 297.2230, 32.4772, 299.7133, 35.0595, 303.4745, 35.0807, 304.1266, 34.0245, 303.6819, 30.3270, 300.8895, 28.8322, 296.8912, 28.3993, 294.9144, 27.6937, 294.5657, 26.6140, 296.1041, 25.9037, 297.3739, 25.6845, 297.8246, 24.4710, 295.9400, 22.7956, 293.0649, 21.4866, 291.1229, 20.8588, 290.3240, 19.7277, 290.6364, 18.7692, 292.0849, 18.3219, 293.1902, 17.8198, 293.1968, 16.4933, 292.2117, 15.0311, 290.2679, 13.8513, 288.7569, 12.5900, 288.6076, 10.9218, 288.7328, 9.7665, 287.2839, 8.8429, 285.5820, 8.1189, 284.2910, 7.0396, 283.2366, 5.8411, 282.9327, 3.8283, 282.5522, 3.2275, 280.8435, 2.7268, 279.3674, 2.2532, 278.3224, 1.3453, 278.2314, 0.7429, 279.1609, 1.5654, 279.5029, 0.9574, 279.8970, -0.2562, 281.6814, -0.8823, 283.4665, -1.5073, 284.0658, -2.4642, 282.9599, -3.4894, 281.1068, -3.6991, 279.0490, -4.0172, 278.1079, -5.1256, 278.2582, -6.7990, 279.0976, -9.4057, 278.6578, -11.6460, 277.3170, -14.1578, 276.1600, -16.6976, 275.8960, -19.1108, 275.5302, -21.8370, 274.9452, -24.2398, 272.9984, -26.4299, 270.0613, -28.0668, 268.2229, -29.8114, 268.5228, -30.2623, 267.9381, -32.1320, 267.1568, -33.2373, 265.0719, -33.6050, 262.2933, -32.3327, 261.2061, -30.0066, 261.2532, -27.8653, 261.7517, -26.3868, 262.0161, -24.8538, 263.5809, -22.8788, 265.0658, -21.1691, 265.8074, -19.4150, 266.6842, -18.7916, 268.0278, -18.7995, 268.7521, -17.4910, 268.3084, -15.3906, 266.9707, -13.3787, 264.9872, -12.4603, 262.4372, -12.2113, 260.5499, -13.2122, 258.4769, -14.8956, 256.1174, -16.7507, 254.4650, -18.3043, 253.6343, -20.3552, 254.1778, -21.5124, 254.1778, -21.5124, 254.1778, -21.5124],
    ["#396bad", 257.4284, -35.0782, 258.7567, -34.6776, 259.6113, -33.6806, 259.9750, -32.7946, 260.9776, -32.5946, 263.4189, -33.7211, 265.2841, -35.1551, 267.0684, -37.0106, 266.5317, -38.4758, 264.8234, -39.1661, 263.0403, -38.8168, 260.6629, -38.1140, 258.3247, -38.4735, 255.5110, -38.1878, 254.0470, -37.3602, 253.5295, -36.1222, 253.7763, -35.4603, 254.7476, -35.1875, 256.2938, -35.0264, 257.4284, -35.0782, 257.4284, -35.0782, 257.4284, -35.0782],
    ["#396bad", 254.4847, -39.5230, 255.2762, -39.2671, 257.3657, -39.9243, 258.7042, -41.3823, 258.3749, -43.2682, 257.0644, -43.3665, 254.3218, -40.8215, 254.6242, -40.4285, 254.4847, -39.5230, 254.4847, -39.5230, 254.4847, -39.5230],
    ["#396bad", 247.9505, -43.8132, 247.7714, -42.7233, 248.2105, -41.7101, 249.7280, -40.8373, 248.8720, -37.3180, 247.1054, -36.2799, 245.6020, -36.7984, 243.1195, -35.6949, 242.2253, -36.0340, 241.9943, -38.6050, 241.6221, -40.6326, 239.8163, -43.0489, 238.8334, -44.6762, 238.5119, -46.8016, 237.7857, -49.0401, 236.8718, -50.6695, 237.0713, -52.3828, 238.9693, -53.2821, 241.4236, -52.3398, 244.7950, -51.3601, 248.9798, -51.6343, 253.4436, -51.0624, 257.8767, -50.6966, 260.9423, -50.2581, 261.6140, -49.2459, 260.7624, -46.4869, 260.5888, -45.3986, 259.8614, -44.8904, 257.7870, -44.9484, 256.1962, -45.7995, 256.3613, -48.5425, 253.5419, -49.9573, 249.8040, -49.5087, 248.3220, -49.4156, 245.7227, -48.7635, 244.6261, -48.0299, 245.6396, -46.7119, 247.9407, -46.1849, 251.5170, -45.7312, 252.8143, -45.1508, 251.9638, -44.5626, 249.5206, -44.4962, 247.9505, -43.8132, 247.9505, -43.8132, 247.9505, -43.8132],
    ["#396bad", 231.8281, -52.4833, 233.5614, -52.5365, 234.4273, -52.7145, 236.0044, -53.8647, 236.5304, -55.8352, 237.3389, -57.1286, 230.3741, -58.8315, 226.4955, -59.1351, 221.0867, -60.4628, 220.9820, -59.2769, 221.7242, -59.0271, 223.2728, -57.1869, 226.5641, -55.0286, 228.1040, -54.5097, 229.9674, -52.9922, 231.8281, -52.4833, 231.8281, -52.4833, 231.8281, -52.4833],
    ["#396bad", 191.9931, -60.9308, 195.0383, -60.9157, 197.2513, -61.5730, 197.6589, -63.3081, 193.3910, -65.2609, 190.6198, -65.3102, 189.1651, -65.7997, 187.9019, -65.8296, 187.4866, -64.7787, 188.0292, -64.2788, 187.2718, -63.6037, 188.0759, -62.2722, 190.6559, -61.1093, 191.9931, -60.9308, 191.9931, -60.9308],
    ["#396bad", 132.7337, -37.5805, 133.0861, -38.9333, 132.3284, -39.7468, 129.7569, -39.4258, 127.1207, -38.0660, 124.9328, -36.1447, 124.8899, -34.6079, 124.7196, -32.9119, 125.9376, -32.1253, 127.3543, -32.6954, 128.6915, -33.7875, 129.6263, -35.1366, 131.7847, -36.5415, 132.7337, -37.5805, 132.7337, -37.5805],
    ["#396bad", 121.1825, -39.3994, 119.9070, -39.0295, 119.2840, -37.6001, 119.3245, -36.1550, 117.3621, -34.3430, 116.3134, -31.1424, 115.5167, -28.5014, 115.3112, -26.0891, 115.8367, -24.7060, 117.0334, -24.5218, 117.8897, -25.7087, 118.5145, -28.1509, 119.6664, -31.5362, 121.7083, -34.8713, 122.3366, -37.4519, 122.1419, -39.0037, 121.1825, -39.3994, 121.1825, -39.3994],
    ["#396bad", 305.9982, 40.1858, 309.8895, 39.3472, 311.2759, 37.2754, 311.2100, 35.4356, 310.1900, 34.7837, 308.6971, 34.9849, 307.5461, 36.5500, 305.0697, 37.7876, 304.5142, 39.0978, 305.1288, 40.0209, 305.9982, 40.1858]
  ]
}

Body:
Wrote a little script to finde any jumps in the coordinates. Output:

Diff found at 342 with newX:   4.3035 and newY: 46.2481 and oldX:359.592 and oldY: 46.1929
Diff found at 624 with newX: 355.2714 and newY: 64.426  and oldX: 0.2476 and oldY: 66.2511

Therefor you need to add 360 to all the x Values inbetween 342 and 624.
You can see a demo of it here: https://jsfiddle.net/MisteriosM/18s0cpmq/43/

Unfortunately I don't know if this really solves your problem since I do not know your draw code. You should update it to be able to use looping coordinates in future.

If you are Lazy and adding it works, here is the first line fixed (with js rounding errors):

["#396bad",254.1778,-21.5124,253.6146,-22.531,253.2638,-27.7008,251.9368,-29.7742,249.7919,-29.7867,247.8,-28.4406,246.557,-26.9571,244.6278,-25.8787,242.5067,-26.007,241.5945,-25.3687,240.7208,-23.0525,239.5973,-22.3533,238.6863,-23.5322,238.718,-25.7313,239.4131,-28.0723,238.6475,-30.8747,239.9512,-34.4963,240.4545,-37.003,238.822,-39.1709,235.6101,-41.6744,234.5926,-42.9833,235.6221,-44.6917,235.5743,-46.4283,232.6913,-48.4186,228.3087,-49.7552,225.9823,-50.6267,221.4249,-52.5289,216.0338,-54.6596,209.0229,-55.3209,202.9102,-56.0362,196.2626,-56.3616,191.7337,-57.1169,184.7426,-59.1857,180.5514,-58.8402,175.1997,-58.5802,170.6339,-57.6749,168.3549,-56.238,163.3607,-54.7001,159.2106,-51.3301,154.8495,-47.2975,150.0574,-45.2411,146.8211,-44.7221,145.5418,-45.4794,145.6709,-46.1571,149.5391,-48.3145,150.7915,-49.6707,150.0747,-51.0247,147.4159,-49.8497,144.3472,-47.8592,142.7713,-47.5886,142.7304,-48.1825,141.859,-48.7921,143.8702,-51.7563,146.7533,-53.8733,146.7337,-54.79,145.4937,-55.0315,136.3994,-53.7185,133.189,-53.9932,132.3952,-55.2722,133.9782,-56.3603,137.5581,-56.8447,142.3823,-56.764,147.1253,-56.7384,149.2668,-57.3424,151.0831,-57.4354,153.9265,-58.4216,157.9421,-58.9774,159.0422,-59.6771,157.5067,-60.3507,155.183,-59.7783,151.9601,-59.2083,149.2887,-59.3163,148.3379,-59.9243,149.9157,-61.434,154.0475,-62.1249,155.9994,-62.2575,159.2582,-63.5263,165.5091,-63.4204,167.1619,-62.829,170.1596,-61.3662,172.9661,-61.4156,176.0518,-62.9133,179.3437,-64.2607,181.9387,-65.3282,184.3779,-69.3924,188.2568,-70.957,194.7347,-71.2607,199.757,-70.2394,204.173,-68.8427,209.0938,-67.8511,216.751,-68.0095,221.9748,-67.1396,227.5494,-66.2461,234.5158,-64.3854,240.5233,-61.8468,244.0983,-60.4173,251.3801,-59.1124,253.2926,-57.4685,254.7774,-56.3244,261.4819,-54.4899,265.8676,-50.8482,268.8085,-48.0793,269.9543,-46.3469,270.5405,-43.6313,270.6492,-42.3809,271.0668,-41.1083,273.1271,-38.6387,274.8287,-36.5477,276.5511,-33.8477,275.404,-33.1596,275.2727,-30.529,276.8968,-28.1703,277.9533,-25.4297,278.6386,-22.3113,279.4081,-19.7351,280.923,-17.4472,281.9964,-15.6719,282.8788,-13.6664,283.3409,-11.0282,284.5659,-8.4787,285.874,-5.6156,287.7313,-3.1057,289.7038,-1.0941,290.4044,-0.0164,290.7342,1.1813,291.9363,0.4122,292.8626,0.7917,295.569,0.8033,297.0695,1.1497,297.0874,2.1407,295.9694,2.3815,294.6764,2.5679,294.4415,3.7745,295.0541,5.1814,296.9021,5.9879,297.733,6.5454,297.6053,8.4351,298.624,10.204,298.1628,13.5562,299.1257,15.5289,302.8713,15.4981,305.5156,16.1286,308.1366,16.6469,308.7496,18.5262,307.5513,19.8431,307.708,20.7394,309.0176,21.5802,308.7945,23.5149,309.4605,24.2478,310.5891,24.9863,310.348,26.0982,308.9284,26.8788,309.16,27.5971,311.8741,29.1431,313.3279,32.0552,313.9435,35.1102,314.9513,36.1769,319.2157,38.0107,320.572,39.744,321.0403,40.9232,321.831,41.6873,323.6238,44.8754,325.1386,46.0919,328.0798,46.8738,332.6317,47.1238,338.1292,47.4766,344.7038,47.6502,346.4796,47.7702,351.3753,46.728,355.142,46.2097,359.592,46.1929,364.3035,46.2481,368.0516,45.6862,370.5201,45.7218,372.3781,45.1055,376.3043,45.2972,379.0389,44.8213,383.6309,45.0223,390.7979,43.0638,392.821,42.8635,400.6571,43.7653,403.6189,43.8484,406.6891,42.5931,405.3773,41.6641,401.7099,41.808,399.3969,41.6311,396.5579,40.8644,396.3328,39.9578,399.008,38.9254,403.4828,39.0665,407.0254,39.2746,410.537,39.3676,413.6788,39.5428,415.767,38.8688,417.1481,37.3216,417.2361,35.7482,416.6404,33.7143,417.1765,32.1478,418.8043,30.8405,419.9439,30.9968,421.4966,33.3066,421.4994,36.0547,421.1808,38.665,421.7684,40.0026,423.8402,40.1004,431.4989,34.6769,435.3343,31.9184,439.71680000000003,29.0407,441.0519,25.1195,442.132,22.0941,443.6308,17.4698,445.5679,15.169,446.9568,12.6324,447.7444,8.8192,451.3008,6.1831,452.8266,2.6539,454.6923,-2.1965,457.7264,-6.0265,462.5525,-9.6439,464.6125,-11.6416,465.1552,-14.2536,468.2256,-18.5894,469.6456,-25.3483,471.22,-27.2135,471.2669,-32.172,474.7741,-37.8718,476.9787,-42.4014,477.0836,-45.1959,476.1853,-48.6868,478.8947,-50.1703,483.5005,-49.9484,485.9819,-48.8761,482.1675,-44.3179,482.4135,-42.9137,484.65909999999997,-42.8292,489.18489999999997,-46.1315,492.502,-47.4562,494.39549999999997,-47.475,495.7144,-46.3461,491.5066,-42.891,492.01070000000004,-42.0135,497.8183,-45.2697,499.31309999999996,-45.0639,499.6524,-44.1094,496.90340000000003,-40.6399,496.6626,-38.9913,499.6753,-40.1504,504.81510000000003,-42.6899,510.5786,-42.3526,513.6315999999999,-43.0367,515.7573,-42.5342,516.1233,-41.0904,512.569,-38.5605,508.4971,-37.7767,501.2865,-38.2886,495.1421,-35.96,489.8501,-32.1764,486.23199999999997,-28.4253,482.1594,-21.3427,478.5304,-12.7577,476.3335,-8.7013,472.8556,-6.4334,469.1321,-2.3025,468.1548,0.0096,467.9889,5.4587,466.7266,8.9737,463.4908,11.8896,461.3959,15.0964,459.5314,17.7842,457.6915,19.7759,456.9057,21.2016,450.6296,24.951,448.07439999999997,27.4918,446.0675,31.0217,445.2336,32.7789,441.64459999999997,36.8533,439.8386,39.1558,438.6539,44.2051,437.5234,45.5296,433.084,46.1406,429.0884,46.5652,426.47839999999997,48.5322,425.01869999999997,50.6773,423.1096,51.4737,420.4311,51.8441,420.2604,52.7052,423.6488,52.7609,425.6099,53.0495,428.01779999999997,52.7517,428.0826,53.7533,423.1671,54.9872,417.4967,55.4868,418.4393,56.1385,420.5618,56.2369,422.6651,56.7553,422.6924,57.7129,419.3107,59.2013,410.7444,59.4785,405.7503,59.6435,403.3097,60.6511,398.7256,61.5348,395.7107,62.5099,390.2614,62.7058,387.5803,63.4145,383.1877,65.0421,378.5579,65.6747,373.7778,67.5849,371.215,68.161,367.5359,67.6326,365.1034,66.7569,362.215,66.1991,360.2476,66.2511,355.2714,64.426,350.1006,62.9385,344.4302,62.4847,339.3002,60.4931,333.4702,58.8851,331.1327,59.4605,330.9382,61.9623,340.6152,65.1092,343.2879,66.7647,343.3581,70.1643,341.1773,70.879,336.6449,73.1299,333.5813,75.1391,324.6186,76.5981,322.6315,75.9427,319.0891,73.7015,314.885,71.0639,315.6348,68.7048,315.4588,66.8973,313.0831,64.8622,312.0635,62.588,314.0142,60.2312,313.6305,59.4861,311.8591,59.3915,309.8048,58.5233,310.2041,57.1819,306.9144,55.9804,304.6804,54.7702,305.2319,53.7273,307.7332,52.9357,308.4628,52.2243,308.0011,51.7205,306.5029,51.7495,304.1552,50.3598,302.5798,48.5193,302.1408,47.1988,300.7148,46.6004,299.0278,47.0595,297.2437,46.8711,295.7553,46.0584,294.7485,44.4314,292.7755,41.4764,288.6933,39.1997,287.4471,37.851,287.5118,36.7221,289.2538,36.0606,290.9985,36.0011,292.6594,35.2362,292.395,34.126,291.207,33.2023,288.424,33.016,287.009,32.3231,286.5059,31.2666,287.0896,29.6223,286.582,27.3683,285.1771,25.5062,283.101,23.9449,281.0469,22.801,279.4373,21.4068,279.1821,19.6473,279.7551,18.2109,280.9496,17.7421,282.622,17.1833,283.2966,16.1546,283.0965,15.0372,281.5283,14.0053,280.0909,12.9151,278.6961,11.5975,277.0707,10.5385,275.4225,9.5688,273.4622,8.5487,270.9916,7.3738,269.3157,5.7621,268.8705,4.4507,269.5389,3.1987,271.0927,2.6855,273.2811,2.5608,275.4739,3.3006,278.1912,5.078,281.909,8.5271,284.1697,11.3576,286.2251,14.0132,286.3233,15.1915,286.1158,15.51,285.7599,16.6912,286.7631,18.2914,287.1951,19.3787,286.9849,20.8446,289.3257,22.5391,291.9464,25.4127,292.4286,28.5332,293.4593,30.5996,297.223,32.4772,299.7133,35.0595,303.4745,35.0807,304.1266,34.0245,303.6819,30.327,300.8895,28.8322,296.8912,28.3993,294.9144,27.6937,294.5657,26.614,296.1041,25.9037,297.3739,25.6845,297.8246,24.471,295.94,22.7956,293.0649,21.4866,291.1229,20.8588,290.324,19.7277,290.6364,18.7692,292.0849,18.3219,293.1902,17.8198,293.1968,16.4933,292.2117,15.0311,290.2679,13.8513,288.7569,12.59,288.6076,10.9218,288.7328,9.7665,287.2839,8.8429,285.582,8.1189,284.291,7.0396,283.2366,5.8411,282.9327,3.8283,282.5522,3.2275,280.8435,2.7268,279.3674,2.2532,278.3224,1.3453,278.2314,0.7429,279.1609,1.5654,279.5029,0.9574,279.897,-0.2562,281.6814,-0.8823,283.4665,-1.5073,284.0658,-2.4642,282.9599,-3.4894,281.1068,-3.6991,279.049,-4.0172,278.1079,-5.1256,278.2582,-6.799,279.0976,-9.4057,278.6578,-11.646,277.317,-14.1578,276.16,-16.6976,275.896,-19.1108,275.5302,-21.837,274.9452,-24.2398,272.9984,-26.4299,270.0613,-28.0668,268.2229,-29.8114,268.5228,-30.2623,267.9381,-32.132,267.1568,-33.2373,265.0719,-33.605,262.2933,-32.3327,261.2061,-30.0066,261.2532,-27.8653,261.7517,-26.3868,262.0161,-24.8538,263.5809,-22.8788,265.0658,-21.1691,265.8074,-19.415,266.6842,-18.7916,268.0278,-18.7995,268.7521,-17.491,268.3084,-15.3906,266.9707,-13.3787,264.9872,-12.4603,262.4372,-12.2113,260.5499,-13.2122,258.4769,-14.8956,256.1174,-16.7507,254.465,-18.3043,253.6343,-20.3552,254.1778,-21.5124,254.1778,-21.5124,254.1778,-21.5124]

const json = '{ "galaxy": [  ["gold", 254.1778, -21.5124, 253.6146, -22.5310, 253.2638, -27.7008, 251.9368, -29.7742, 249.7919, -29.7867, 247.8000, -28.4406, 246.5570, -26.9571, 244.6278, -25.8787, 242.5067, -26.0070, 241.5945, -25.3687, 240.7208, -23.0525, 239.5973, -22.3533, 238.6863, -23.5322, 238.7180, -25.7313, 239.4131, -28.0723, 238.6475, -30.8747, 239.9512, -34.4963, 240.4545, -37.0030, 238.8220, -39.1709, 235.6101, -41.6744, 234.5926, -42.9833, 235.6221, -44.6917, 235.5743, -46.4283, 232.6913, -48.4186, 228.3087, -49.7552, 225.9823, -50.6267, 221.4249, -52.5289, 216.0338, -54.6596, 209.0229, -55.3209, 202.9102, -56.0362, 196.2626, -56.3616, 191.7337, -57.1169, 184.7426, -59.1857, 180.5514, -58.8402, 175.1997, -58.5802, 170.6339, -57.6749, 168.3549, -56.2380, 163.3607, -54.7001, 159.2106, -51.3301, 154.8495, -47.2975, 150.0574, -45.2411, 146.8211, -44.7221, 145.5418, -45.4794, 145.6709, -46.1571, 149.5391, -48.3145, 150.7915, -49.6707, 150.0747, -51.0247, 147.4159, -49.8497, 144.3472, -47.8592, 142.7713, -47.5886, 142.7304, -48.1825, 141.8590, -48.7921, 143.8702, -51.7563, 146.7533, -53.8733, 146.7337, -54.7900, 145.4937, -55.0315, 136.3994, -53.7185, 133.1890, -53.9932, 132.3952, -55.2722, 133.9782, -56.3603, 137.5581, -56.8447, 142.3823, -56.7640, 147.1253, -56.7384, 149.2668, -57.3424, 151.0831, -57.4354, 153.9265, -58.4216, 157.9421, -58.9774, 159.0422, -59.6771, 157.5067, -60.3507, 155.1830, -59.7783, 151.9601, -59.2083, 149.2887, -59.3163, 148.3379, -59.9243, 149.9157, -61.4340, 154.0475, -62.1249, 155.9994, -62.2575, 159.2582, -63.5263, 165.5091, -63.4204, 167.1619, -62.8290, 170.1596, -61.3662, 172.9661, -61.4156, 176.0518, -62.9133, 179.3437, -64.2607, 181.9387, -65.3282, 184.3779, -69.3924, 188.2568, -70.9570, 194.7347, -71.2607, 199.7570, -70.2394, 204.1730, -68.8427, 209.0938, -67.8511, 216.7510, -68.0095, 221.9748, -67.1396, 227.5494, -66.2461, 234.5158, -64.3854, 240.5233, -61.8468, 244.0983, -60.4173, 251.3801, -59.1124, 253.2926, -57.4685, 254.7774, -56.3244, 261.4819, -54.4899, 265.8676, -50.8482, 268.8085, -48.0793, 269.9543, -46.3469, 270.5405, -43.6313, 270.6492, -42.3809, 271.0668, -41.1083, 273.1271, -38.6387, 274.8287, -36.5477, 276.5511, -33.8477, 275.4040, -33.1596, 275.2727, -30.5290, 276.8968, -28.1703, 277.9533, -25.4297, 278.6386, -22.3113, 279.4081, -19.7351, 280.9230, -17.4472, 281.9964, -15.6719, 282.8788, -13.6664, 283.3409, -11.0282, 284.5659, -8.4787, 285.8740, -5.6156, 287.7313, -3.1057, 289.7038, -1.0941, 290.4044, -0.0164, 290.7342, 1.1813, 291.9363, 0.4122, 292.8626, 0.7917, 295.5690, 0.8033, 297.0695, 1.1497, 297.0874, 2.1407, 295.9694, 2.3815, 294.6764, 2.5679, 294.4415, 3.7745, 295.0541, 5.1814, 296.9021, 5.9879, 297.7330, 6.5454, 297.6053, 8.4351, 298.6240, 10.2040, 298.1628, 13.5562, 299.1257, 15.5289, 302.8713, 15.4981, 305.5156, 16.1286, 308.1366, 16.6469, 308.7496, 18.5262, 307.5513, 19.8431, 307.7080, 20.7394, 309.0176, 21.5802, 308.7945, 23.5149, 309.4605, 24.2478, 310.5891, 24.9863, 310.3480, 26.0982, 308.9284, 26.8788, 309.1600, 27.5971, 311.8741, 29.1431, 313.3279, 32.0552, 313.9435, 35.1102, 314.9513, 36.1769, 319.2157, 38.0107, 320.5720, 39.7440, 321.0403, 40.9232, 321.8310, 41.6873, 323.6238, 44.8754, 325.1386, 46.0919, 328.0798, 46.8738, 332.6317, 47.1238, 338.1292, 47.4766, 344.7038, 47.6502, 346.4796, 47.7702, 351.3753, 46.7280, 355.1420, 46.2097, 359.5920, 46.1929, 4.3035, 46.2481, 8.0516, 45.6862, 10.5201, 45.7218, 12.3781, 45.1055, 16.3043, 45.2972, 19.0389, 44.8213, 23.6309, 45.0223, 30.7979, 43.0638, 32.8210, 42.8635, 40.6571, 43.7653, 43.6189, 43.8484, 46.6891, 42.5931, 45.3773, 41.6641, 41.7099, 41.8080, 39.3969, 41.6311, 36.5579, 40.8644, 36.3328, 39.9578, 39.0080, 38.9254, 43.4828, 39.0665, 47.0254, 39.2746, 50.5370, 39.3676, 53.6788, 39.5428, 55.7670, 38.8688, 57.1481, 37.3216, 57.2361, 35.7482, 56.6404, 33.7143, 57.1765, 32.1478, 58.8043, 30.8405, 59.9439, 30.9968, 61.4966, 33.3066, 61.4994, 36.0547, 61.1808, 38.6650, 61.7684, 40.0026, 63.8402, 40.1004, 71.4989, 34.6769, 75.3343, 31.9184, 79.7168, 29.0407, 81.0519, 25.1195, 82.1320, 22.0941, 83.6308, 17.4698, 85.5679, 15.1690, 86.9568, 12.6324, 87.7444, 8.8192, 91.3008, 6.1831, 92.8266, 2.6539, 94.6923, -2.1965, 97.7264, -6.0265, 102.5525, -9.6439, 104.6125, -11.6416, 105.1552, -14.2536, 108.2256, -18.5894, 109.6456, -25.3483, 111.2200, -27.2135, 111.2669, -32.1720, 114.7741, -37.8718, 116.9787, -42.4014, 117.0836, -45.1959, 116.1853, -48.6868, 118.8947, -50.1703, 123.5005, -49.9484, 125.9819, -48.8761, 122.1675, -44.3179, 122.4135, -42.9137, 124.6591, -42.8292, 129.1849, -46.1315, 132.5020, -47.4562, 134.3955, -47.4750, 135.7144, -46.3461, 131.5066, -42.8910, 132.0107, -42.0135, 137.8183, -45.2697, 139.3131, -45.0639, 139.6524, -44.1094, 136.9034, -40.6399, 136.6626, -38.9913, 139.6753, -40.1504, 144.8151, -42.6899, 150.5786, -42.3526, 153.6316, -43.0367, 155.7573, -42.5342, 156.1233, -41.0904, 152.5690, -38.5605, 148.4971, -37.7767, 141.2865, -38.2886, 135.1421, -35.9600, 129.8501, -32.1764, 126.2320, -28.4253, 122.1594, -21.3427, 118.5304, -12.7577, 116.3335, -8.7013, 112.8556, -6.4334, 109.1321, -2.3025, 108.1548, 0.0096, 107.9889, 5.4587, 106.7266, 8.9737, 103.4908, 11.8896, 101.3959, 15.0964, 99.5314, 17.7842, 97.6915, 19.7759, 96.9057, 21.2016, 90.6296, 24.9510, 88.0744, 27.4918, 86.0675, 31.0217, 85.2336, 32.7789, 81.6446, 36.8533, 79.8386, 39.1558, 78.6539, 44.2051, 77.5234, 45.5296, 73.0840, 46.1406, 69.0884, 46.5652, 66.4784, 48.5322, 65.0187, 50.6773, 63.1096, 51.4737, 60.4311, 51.8441, 60.2604, 52.7052, 63.6488, 52.7609, 65.6099, 53.0495, 68.0178, 52.7517, 68.0826, 53.7533, 63.1671, 54.9872, 57.4967, 55.4868, 58.4393, 56.1385, 60.5618, 56.2369, 62.6651, 56.7553, 62.6924, 57.7129, 59.3107, 59.2013, 50.7444, 59.4785, 45.7503, 59.6435, 43.3097, 60.6511, 38.7256, 61.5348, 35.7107, 62.5099, 30.2614, 62.7058, 27.5803, 63.4145, 23.1877, 65.0421, 18.5579, 65.6747, 13.7778, 67.5849, 11.2150, 68.1610, 7.5359, 67.6326, 5.1034, 66.7569, 2.2150, 66.1991, 0.2476, 66.2511, 355.2714, 64.4260, 350.1006, 62.9385, 344.4302, 62.4847, 339.3002, 60.4931, 333.4702, 58.8851, 331.1327, 59.4605, 330.9382, 61.9623, 340.6152, 65.1092, 343.2879, 66.7647, 343.3581, 70.1643, 341.1773, 70.8790, 336.6449, 73.1299, 333.5813, 75.1391, 324.6186, 76.5981, 322.6315, 75.9427, 319.0891, 73.7015, 314.8850, 71.0639, 315.6348, 68.7048, 315.4588, 66.8973, 313.0831, 64.8622, 312.0635, 62.5880, 314.0142, 60.2312, 313.6305, 59.4861, 311.8591, 59.3915, 309.8048, 58.5233, 310.2041, 57.1819, 306.9144, 55.9804, 304.6804, 54.7702, 305.2319, 53.7273, 307.7332, 52.9357, 308.4628, 52.2243, 308.0011, 51.7205, 306.5029, 51.7495, 304.1552, 50.3598, 302.5798, 48.5193, 302.1408, 47.1988, 300.7148, 46.6004, 299.0278, 47.0595, 297.2437, 46.8711, 295.7553, 46.0584, 294.7485, 44.4314, 292.7755, 41.4764, 288.6933, 39.1997, 287.4471, 37.8510, 287.5118, 36.7221, 289.2538, 36.0606, 290.9985, 36.0011, 292.6594, 35.2362, 292.3950, 34.1260, 291.2070, 33.2023, 288.4240, 33.0160, 287.0090, 32.3231, 286.5059, 31.2666, 287.0896, 29.6223, 286.5820, 27.3683, 285.1771, 25.5062, 283.1010, 23.9449, 281.0469, 22.8010, 279.4373, 21.4068, 279.1821, 19.6473, 279.7551, 18.2109, 280.9496, 17.7421, 282.6220, 17.1833, 283.2966, 16.1546, 283.0965, 15.0372, 281.5283, 14.0053, 280.0909, 12.9151, 278.6961, 11.5975, 277.0707, 10.5385, 275.4225, 9.5688, 273.4622, 8.5487, 270.9916, 7.3738, 269.3157, 5.7621, 268.8705, 4.4507, 269.5389, 3.1987, 271.0927, 2.6855, 273.2811, 2.5608, 275.4739, 3.3006, 278.1912, 5.0780, 281.9090, 8.5271, 284.1697, 11.3576, 286.2251, 14.0132, 286.3233, 15.1915, 286.1158, 15.5100, 285.7599, 16.6912, 286.7631, 18.2914, 287.1951, 19.3787, 286.9849, 20.8446, 289.3257, 22.5391, 291.9464, 25.4127, 292.4286, 28.5332, 293.4593, 30.5996, 297.2230, 32.4772, 299.7133, 35.0595, 303.4745, 35.0807, 304.1266, 34.0245, 303.6819, 30.3270, 300.8895, 28.8322, 296.8912, 28.3993, 294.9144, 27.6937, 294.5657, 26.6140, 296.1041, 25.9037, 297.3739, 25.6845, 297.8246, 24.4710, 295.9400, 22.7956, 293.0649, 21.4866, 291.1229, 20.8588, 290.3240, 19.7277, 290.6364, 18.7692, 292.0849, 18.3219, 293.1902, 17.8198, 293.1968, 16.4933, 292.2117, 15.0311, 290.2679, 13.8513, 288.7569, 12.5900, 288.6076, 10.9218, 288.7328, 9.7665, 287.2839, 8.8429, 285.5820, 8.1189, 284.2910, 7.0396, 283.2366, 5.8411, 282.9327, 3.8283, 282.5522, 3.2275, 280.8435, 2.7268, 279.3674, 2.2532, 278.3224, 1.3453, 278.2314, 0.7429, 279.1609, 1.5654, 279.5029, 0.9574, 279.8970, -0.2562, 281.6814, -0.8823, 283.4665, -1.5073, 284.0658, -2.4642, 282.9599, -3.4894, 281.1068, -3.6991, 279.0490, -4.0172, 278.1079, -5.1256, 278.2582, -6.7990, 279.0976, -9.4057, 278.6578, -11.6460, 277.3170, -14.1578, 276.1600, -16.6976, 275.8960, -19.1108, 275.5302, -21.8370, 274.9452, -24.2398, 272.9984, -26.4299, 270.0613, -28.0668, 268.2229, -29.8114, 268.5228, -30.2623, 267.9381, -32.1320, 267.1568, -33.2373, 265.0719, -33.6050, 262.2933, -32.3327, 261.2061, -30.0066, 261.2532, -27.8653, 261.7517, -26.3868, 262.0161, -24.8538, 263.5809, -22.8788, 265.0658, -21.1691, 265.8074, -19.4150, 266.6842, -18.7916, 268.0278, -18.7995, 268.7521, -17.4910, 268.3084, -15.3906, 266.9707, -13.3787, 264.9872, -12.4603, 262.4372, -12.2113, 260.5499, -13.2122, 258.4769, -14.8956, 256.1174, -16.7507, 254.4650, -18.3043, 253.6343, -20.3552, 254.1778, -21.5124, 254.1778, -21.5124, 254.1778, -21.5124],  ["#purple", 257.4284, -35.0782, 258.7567, -34.6776, 259.6113, -33.6806, 259.9750, -32.7946, 260.9776, -32.5946, 263.4189, -33.7211, 265.2841, -35.1551, 267.0684, -37.0106, 266.5317, -38.4758, 264.8234, -39.1661, 263.0403, -38.8168, 260.6629, -38.1140, 258.3247, -38.4735, 255.5110, -38.1878, 254.0470, -37.3602, 253.5295, -36.1222, 253.7763, -35.4603, 254.7476, -35.1875, 256.2938, -35.0264, 257.4284, -35.0782, 257.4284, -35.0782, 257.4284, -35.0782],  ["yellow", 254.4847, -39.5230, 255.2762, -39.2671, 257.3657, -39.9243, 258.7042, -41.3823, 258.3749, -43.2682, 257.0644, -43.3665, 254.3218, -40.8215, 254.6242, -40.4285, 254.4847, -39.5230, 254.4847, -39.5230, 254.4847, -39.5230],   ["gray", 247.9505, -43.8132, 247.7714, -42.7233, 248.2105, -41.7101, 249.7280, -40.8373, 248.8720, -37.3180, 247.1054, -36.2799, 245.6020, -36.7984, 243.1195, -35.6949, 242.2253, -36.0340, 241.9943, -38.6050, 241.6221, -40.6326, 239.8163, -43.0489, 238.8334, -44.6762, 238.5119, -46.8016, 237.7857, -49.0401, 236.8718, -50.6695, 237.0713, -52.3828, 238.9693, -53.2821, 241.4236, -52.3398, 244.7950, -51.3601, 248.9798, -51.6343, 253.4436, -51.0624, 257.8767, -50.6966, 260.9423, -50.2581, 261.6140, -49.2459, 260.7624, -46.4869, 260.5888, -45.3986, 259.8614, -44.8904, 257.7870, -44.9484, 256.1962, -45.7995, 256.3613, -48.5425, 253.5419, -49.9573, 249.8040, -49.5087, 248.3220, -49.4156, 245.7227, -48.7635, 244.6261, -48.0299, 245.6396, -46.7119, 247.9407, -46.1849, 251.5170, -45.7312, 252.8143, -45.1508, 251.9638, -44.5626, 249.5206, -44.4962, 247.9505, -43.8132, 247.9505, -43.8132, 247.9505, -43.8132],   ["pink", 231.8281, -52.4833, 233.5614, -52.5365, 234.4273, -52.7145, 236.0044, -53.8647, 236.5304, -55.8352, 237.3389, -57.1286, 230.3741, -58.8315, 226.4955, -59.1351, 221.0867, -60.4628, 220.9820, -59.2769, 221.7242, -59.0271, 223.2728, -57.1869, 226.5641, -55.0286, 228.1040, -54.5097, 229.9674, -52.9922, 231.8281, -52.4833, 231.8281, -52.4833, 231.8281, -52.4833], ["green", 191.9931, -60.9308, 195.0383, -60.9157, 197.2513, -61.5730, 197.6589, -63.3081, 193.3910, -65.2609, 190.6198, -65.3102, 189.1651, -65.7997, 187.9019, -65.8296, 187.4866, -64.7787, 188.0292, -64.2788, 187.2718, -63.6037, 188.0759, -62.2722, 190.6559, -61.1093, 191.9931, -60.9308, 191.9931, -60.9308],  ["orange", 132.7337, -37.5805, 133.0861, -38.9333, 132.3284, -39.7468, 129.7569, -39.4258, 127.1207, -38.0660, 124.9328, -36.1447, 124.8899, -34.6079, 124.7196, -32.9119, 125.9376, -32.1253, 127.3543, -32.6954, 128.6915, -33.7875, 129.6263, -35.1366, 131.7847, -36.5415, 132.7337, -37.5805, 132.7337, -37.5805],["red", 121.1825, -39.3994, 119.9070, -39.0295, 119.2840, -37.6001, 119.3245, -36.1550, 117.3621, -34.3430, 116.3134, -31.1424, 115.5167, -28.5014, 115.3112, -26.0891, 115.8367, -24.7060, 117.0334, -24.5218, 117.8897, -25.7087, 118.5145, -28.1509, 119.6664, -31.5362, 121.7083, -34.8713, 122.3366, -37.4519, 122.1419, -39.0037, 121.1825, -39.3994, 121.1825, -39.3994],["#396bad", 305.9982, 40.1858, 309.8895, 39.3472, 311.2759, 37.2754, 311.2100, 35.4356, 310.1900, 34.7837, 308.6971, 34.9849, 307.5461, 36.5500, 305.0697, 37.7876, 304.5142, 39.0978, 305.1288, 40.0209, 305.9982, 40.1858] ]}';
function diff(a, b) {
    return Math.abs(a - b);
}

const obj = JSON.parse(json);
var canvas = document.getElementById("result");
ctx = canvas.getContext("2d");

var counter = 0;
var prevX = 254.1778;
var prevY = -21.5124;
var newX, newY;
for (var i = 0; i < 1 /*obj.galaxy.length*/ ; i++) {
    ctx.beginPath();
    ctx.fillStyle = obj.galaxy[i][0];
    counter = 0;
    while (obj.galaxy[i][1 + counter + 2] <= obj.galaxy[i].length) {
        newX = obj.galaxy[i][1 + counter];
        newY = obj.galaxy[i][2 + counter];
        ctx.lineTo(newX, newY + 100);
        if (diff(newX, prevX) > 10 || diff(newY, prevY) > 10) {
            console.log("Diff found at " + counter + " with newX: " + newX + "and newY: " + newY + " and oldX: " + prevX + "and oldY: " + prevY);
        }
        prevX = newX;
        prevY = newY;
        counter += 2;

    }
    ctx.fill();
}

for (j = 0; j < 1 /*obj.galaxy.length*/ ; j++) {
    ctx.beginPath();
    ctx.fillStyle = "red";
    counter = 0;
    while (obj.galaxy[j][1 + counter + 2] <= obj.galaxy[j].length) {
        newX = obj.galaxy[j][1 + counter];
        newY = obj.galaxy[j][2 + counter];
        if (counter >= 342 && counter < 624) newX += 360;
        ctx.lineTo(newX, newY + 300);
        counter += 2;
    }
    ctx.fill();
}

for (j = 0; j < 1 /*obj.galaxy.length*/ ; j++) {
    counter = 0;
    while (obj.galaxy[j][1 + counter + 2] <= obj.galaxy[j].length) {
        if (counter >= 342 && counter < 624) obj.galaxy[j][1 + counter] += 360;
        counter += 2;
    }
    console.log(JSON.stringify(obj.galaxy[0]));
}

<canvas id="result" width="640" height="450" style="position: absolute;border: 1px solid;"></canvas>


问:
The Next Palindrome number
I am beginner in programming, So can you please tell me what's wrong with my code?

I want to print next palindrome number if the number entered by the user (n) is not palindrome

```<code>n = int(input("Enter any number :- "))

reverse = 0
temp = n

while (n!=0):
    reverse = reverse * 10
    reverse = reverse + n%10
    n=n//10
if(temp==reverse):
    print ("Already palindrome:: ")

if(temp != reverse):
     new_temp = temp
     new_reverse = 0
     for i in range(new_temp,new_temp+10):
        while(temp != 0):
            new_reverse = new_reverse * 10
            new_reverse = new_reverse + temp%10
            temp = temp//10
         if(new_temp==new_reverse):
             print ("Next pallindrome is :- ",new_temp)
             break
         if(new_temp != new_reverse):
             temp = new_temp+1
</code>```

答:
```<code>def next_palin_drome(n):
    while True:
        n+=1
        if str(n) == str(n)[::-1]:
            return n

n=12231
print(next_palin_drome(n))
</code>```

output:12321

Title: The Next Palindrome number

Body:
I am beginner in programming, So can you please tell me what's wrong with my code?

I want to print next palindrome number if the number entered by the user (n) is not palindrome

n = int(input("Enter any number :- "))

reverse = 0
temp = n

while (n!=0):
    reverse = reverse * 10
    reverse = reverse + n%10
    n=n//10
if(temp==reverse):
    print ("Already palindrome:: ")

if(temp != reverse):
     new_temp = temp
     new_reverse = 0
     for i in range(new_temp,new_temp+10):
        while(temp != 0):
            new_reverse = new_reverse * 10
            new_reverse = new_reverse + temp%10
            temp = temp//10
         if(new_temp==new_reverse):
             print ("Next pallindrome is :- ",new_temp)
             break
         if(new_temp != new_reverse):
             temp = new_temp+1

Body:
def next_palin_drome(n):
    while True:
        n+=1
        if str(n) == str(n)[::-1]:
            return n

n=12231
print(next_palin_drome(n))

output:12321


问:
Can IAM permission policy used to allow access to cross account resource?
My understanding is,

Service control policy and resource based policies are mainly used to allow/deny cross account access to resources.

From the policy evaluation procedure explained here, I learned that IAM permission policy(managed or inline) is used to grant/deny permissions to Principal within an AWS account.

```<code>{
 "Version": "2012-10-17",
 "Statement": [

     {
         "Action": "sts:AssumeRole",
         "Resource": "arn:aws:iam::*:role/Somerole",
         "Effect": "Allow"
     }
 ]
}
</code>```

But above is the IAM permission policy, written to grant permissions to Principal in the source account, to have access(sts::AssumeRole) to other account resources(Somerole).

Can IAM permission policy be defined to allow Principal in source AWS account get permissions(sts:AssumeRole) to access resources(Somerole) that are present in other accounts(*:role)? In our case Principal is an IAM role in the source AWS account.

答:
The other account would need to have granted access to the account. The role in the other account would need a trust relationship similar to this (often it has conditions added to it as well):

```<code>{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::<AccountId_A>:root"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
</code>```

This example assumes that  is the account you are granting the IAM permission in.

Body:
My understanding is,

Service control policy and resource based policies are mainly used to allow/deny cross account access to resources.

From the policy evaluation procedure explained here, I learned that IAM permission policy(managed or inline) is used to grant/deny permissions to Principal within an AWS account.

{
 "Version": "2012-10-17",
 "Statement": [

     {
         "Action": "sts:AssumeRole",
         "Resource": "arn:aws:iam::*:role/Somerole",
         "Effect": "Allow"
     }
 ]
}

But above is the IAM permission policy, written to grant permissions to Principal in the source account, to have access(sts::AssumeRole) to other account resources(Somerole).

Can IAM permission policy be defined to allow Principal in source AWS account get permissions(sts:AssumeRole) to access resources(Somerole) that are present in other accounts(*:role)? In our case Principal is an IAM role in the source AWS account.

Body:
The other account would need to have granted access to the account. The role in the other account would need a trust relationship similar to this (often it has conditions added to it as well):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::<AccountId_A>:root"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

This example assumes that  is the account you are granting the IAM permission in.


问:
Error when update AWS Java Lambda Function using Bitbucket Pipelines - java.lang.ClassNotFoundException
I have a basic AWS Lambda Java Function my-function

public class Hello implements RequestHandler<Request, Response> {
    public Response handleRequest(Request request, Context context) {
        String greetingString = String.format("Hello %s", request.name);
        return new Response(greetingString);
    }
}

```

That Lambda function is registered in AWS well, the controller is com.tds.Hello and is related to AWS API Gateway correctly.

The final JAR is built through Maven without a problem. When I upload the JAR directly in AWS the function works well.

The problem is when I use Bitbucket Pipelines in order to do an automatic upload (and update) after committing code, the pipeline runs well with success status following This tutorial (Automating AWS Lambda deployments) but when I test/run the function in AWS I get the following error:

{"errorMessage":"Class not found: com.tds.Hello","errorType":"java.lang.ClassNotFoundException"}

Does anyone has faced this issue?

答:
The error was when ZIP file was created and passed through Bitbucket Artifacts. I avoid to compress (ZIP) file, instead, I used the JAR directly to upload in AWS. I updated bitbucket-pipelines.yml as follow:

Old bitbucket-pipeline.yml

```<code>pipelines:
  default:
    - step:
        name: Build and package
        script:
          - apt-get update && apt-get install -y zip
          - zip my-function.zip target/my-function.jar
          - pipe: atlassian/aws-lambda-deploy:0.3.0
            variables:
              AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
              AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
              AWS_DEFAULT_REGION: $AWS_REGION
              FUNCTION_NAME: 'my-function'
              COMMAND: 'update'
              ZIP_FILE: 'my-function.zip'
</code>```

New bitbucket-pipeline.yml

```<code>pipelines:
  default:
    - step:
        name: Build and package
        script:
          - pipe: atlassian/aws-lambda-deploy:0.5.0
            variables:
              AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
              AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
              AWS_DEFAULT_REGION: $AWS_REGION
              FUNCTION_NAME: 'my-function'
              COMMAND: 'update'
              ZIP_FILE: 'target/my-function.jar'
</code>```

Body:
I have a basic AWS Lambda Java Function my-function

public class Hello implements RequestHandler<Request, Response> {
    public Response handleRequest(Request request, Context context) {
        String greetingString = String.format("Hello %s", request.name);
        return new Response(greetingString);
    }
}

That Lambda function is registered in AWS well, the controller is com.tds.Hello and is related to AWS API Gateway correctly.

The final JAR is built through Maven without a problem. When I upload the JAR directly in AWS the function works well.

The problem is when I use Bitbucket Pipelines in order to do an automatic upload (and update) after committing code, the pipeline runs well with success status following This tutorial (Automating AWS Lambda deployments) but when I test/run the function in AWS I get the following error:

{"errorMessage":"Class not found: com.tds.Hello","errorType":"java.lang.ClassNotFoundException"}

Does anyone has faced this issue?

Body:
The error was when ZIP file was created and passed through Bitbucket Artifacts. I avoid to compress (ZIP) file, instead, I used the JAR directly to upload in AWS. I updated bitbucket-pipelines.yml as follow:

Old bitbucket-pipeline.yml

pipelines:
  default:
    - step:
        name: Build and package
        script:
          - apt-get update && apt-get install -y zip
          - zip my-function.zip target/my-function.jar
          - pipe: atlassian/aws-lambda-deploy:0.3.0
            variables:
              AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
              AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
              AWS_DEFAULT_REGION: $AWS_REGION
              FUNCTION_NAME: 'my-function'
              COMMAND: 'update'
              ZIP_FILE: 'my-function.zip'

New bitbucket-pipeline.yml

pipelines:
  default:
    - step:
        name: Build and package
        script:
          - pipe: atlassian/aws-lambda-deploy:0.5.0
            variables:
              AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
              AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
              AWS_DEFAULT_REGION: $AWS_REGION
              FUNCTION_NAME: 'my-function'
              COMMAND: 'update'
              ZIP_FILE: 'target/my-function.jar'


问:
Are there limits to the number of tables that can be joined in Oracle?
I'm writing a fairly large query, and I have 2 tables, inner joined and 15 tables left-outer joined. when I add the 16, I get ORA-03113: end-of-file on communication channel. If I remove a table to add the new one, the query works fine.

The query runs fine for SQL Server, it's just Oracle that seems to be struggling.

答:
The various limitations for Oracle are available in Appendix A of its database documentation. I can't find any specifically for the number of joins allowed in a query, but since you're allowed up to 255 subqueries in a query, I wouldn't think 16 left joins aren't beyond its abilities. Edit: you're allowed 255 subqueries in the WHERE clause. Apparently it's unlimited in the FROM clause

However, the error message you've listed would tend to suggest it's the actual length of the query overall:

The limit on how long a SQL statement can be depends on many factors, including database configuration, disk space, and memory


问:
Python - Determine if Item is in a List Using a Function
I'm trying to write a function in Python to determine whether or not an item is in a list. I've been trying variations of this code.

No matter how I try it, it always returns a FALSE Boolean value. Even if I put the print commands inside the functions, it only prints with the results for a false value. I'm pretty sure I'm passing the list to the function properly, but I can't figure out why it only determines FALSE values. Any ideas?

```<code>def newFunction(x, y, z):
   z = 0
   if y in x:
      z = True
   else:
      z = False
   return (z)

newList = [2,4,6,8,10]
r = input ('Enter a number: ')
s = 0
newFunction(newList, r, s)
if s == True:
   print ('The no. IS in the list.')
else:
   print ('The no. IS NOT in the list.')
</code>```

答:
You are not setting the s - you run the function but it does not assign to s so change to:

```<code>s = newFunction(newList, r, s)
</code>```

You can also remove the 'z' as an argument and instead return False/True in each If condition.

Body:
I'm trying to write a function in Python to determine whether or not an item is in a list. I've been trying variations of this code.

No matter how I try it, it always returns a FALSE Boolean value. Even if I put the print commands inside the functions, it only prints with the results for a false value. I'm pretty sure I'm passing the list to the function properly, but I can't figure out why it only determines FALSE values. Any ideas?

def newFunction(x, y, z):
   z = 0
   if y in x:
      z = True
   else:
      z = False
   return (z)

newList = [2,4,6,8,10]
r = input ('Enter a number: ')
s = 0
newFunction(newList, r, s)
if s == True:
   print ('The no. IS in the list.')
else:
   print ('The no. IS NOT in the list.')

Body:
You are not setting the s - you run the function but it does not assign to s so change to:

s = newFunction(newList, r, s)

You can also remove the 'z' as an argument and instead return False/True in each If condition.


问:
python: How to interpret indexing of slicing
Here is the code:

```<code>a = [0, 11, 22, 33, 44, 55]
a[1:4][1] = 666
print(a)
</code>```

The output is [0, 11, 22, 33, 44, 55]

So list a is not updated, then what is the effect of that assignment?

[UPDATE]
Thanks @Amadan for explanation, it makes sense. But I am still puzzled, the following slicing directly updates the list:

```<code>a[1:4] = [111, 222, 333]
</code>```

Intuitively I expect a[1:4][1] still operates on the list, but it is not.

Is my intuition wrong?

答:
Just another solution to think off in case you didn't know the position of 22 (and wanted to replace it with 666) or didn't care about removing other items from the list.

```<code>a = [0, 11, 22, 33, 44, 55]

# make use of enumerate to keep track of when the item is 22 and replace that
# with the help of indexing count i.e the position at which 22 is and replace it
# with 666.

for count,item in enumerate(a):
   if item==22:
      a[count]=666
print(a)
</code>```

Output:

```<code>>>>[0, 11, 666, 33, 44, 55]
</code>```

Hope that helps, cheers!

Body:
Here is the code:

a = [0, 11, 22, 33, 44, 55]
a[1:4][1] = 666
print(a)

The output is [0, 11, 22, 33, 44, 55]

So list a is not updated, then what is the effect of that assignment?

[UPDATE]
Thanks @Amadan for explanation, it makes sense. But I am still puzzled, the following slicing directly updates the list:

a[1:4] = [111, 222, 333]

Intuitively I expect a[1:4][1] still operates on the list, but it is not.

Is my intuition wrong?

Body:
Just another solution to think off in case you didn't know the position of 22 (and wanted to replace it with 666) or didn't care about removing other items from the list.

a = [0, 11, 22, 33, 44, 55]

# make use of enumerate to keep track of when the item is 22 and replace that
# with the help of indexing count i.e the position at which 22 is and replace it
# with 666.

for count,item in enumerate(a):
   if item==22:
      a[count]=666
print(a)

Output:

>>>[0, 11, 666, 33, 44, 55]

Hope that helps, cheers!


问:
How to make a Azure SQL Exec or select another table/procedure in another Azure SQL
I've two Azure SQL Servers, each one contains one database, I need to exec Selects or Stored procedures between them.

For example:

Server1.database.windows.net DB: local1
Server2.database.windows.net DB: remote1

in Server1: Select * from Server2.remote1.dbo.Orders and this query return a list of orders.

in Server2: Exec Server1.local1.dbo.ProcedureOrders and this execute a stored procedure in Server1

First of all, is this possible? If yes, how?

答:
Yes, it's possible. Azure sql database doesn't support linked server, but like @Alberto Morillo mentioned that Elastic Query can help you query and execute stored procedure in other SQL Server.

For the remote table query, here are the steps:

Create database scoped master key and credentials:

CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'master_key_password'; CREATE DATABASE SCOPED CREDENTIAL <credential_name>  WITH IDENTITY = '<username>',   SECRET = '<password>' [;]

Create external data sources:

<External_Data_Source> ::= CREATE EXTERNAL DATA SOURCE <data_source_name> WITH  (TYPE = RDBMS, LOCATION = ’<fully_qualified_server_name>’, DATABASE_NAME = ‘<remote_database_name>’,   CREDENTIAL = <credential_name>  ) [;]

External Tables:

CREATE EXTERNAL TABLE [ database_name . [ schema_name ] . | schema_name . ] table_name   ( { <column_definition> } [ ,...n ])      { WITH ( <rdbms_external_table_options> ) }  )[;]

<rdbms_external_table_options> ::=  DATA_SOURCE = <External_Data_Source>,  [ SCHEMA_NAME = N'nonescaped_schema_name',]  [ OBJECT_NAME = N'nonescaped_object_name',]

For execute remote stored procedure:

Elastic query also introduces a stored procedure that provides direct access to the remote database. The stored procedure is called sp_execute _remote and can be used to execute remote stored procedures or T-SQL code on the remote database.

Example:

```<code>EXEC sp_execute_remote
        N'MyExtSrc',
        N'select count(w_id) as foo from warehouse'
</code>```

For more details, please reference:

Reporting across scaled-out cloud databases (preview)

Query across cloud databases with different schemas (preview)

Hope this helps.

Body:
Yes, it's possible. Azure sql database doesn't support linked server, but like @Alberto Morillo mentioned that Elastic Query can help you query and execute stored procedure in other SQL Server.

For the remote table query, here are the steps:

Create database scoped master key and credentials:

CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'master_key_password'; CREATE DATABASE SCOPED CREDENTIAL <credential_name>  WITH IDENTITY = '<username>',   SECRET = '<password>' [;]

Create external data sources:

<External_Data_Source> ::= CREATE EXTERNAL DATA SOURCE <data_source_name> WITH  (TYPE = RDBMS, LOCATION = ’<fully_qualified_server_name>’, DATABASE_NAME = ‘<remote_database_name>’,   CREDENTIAL = <credential_name>  ) [;]

External Tables:

CREATE EXTERNAL TABLE [ database_name . [ schema_name ] . | schema_name . ] table_name   ( { <column_definition> } [ ,...n ])      { WITH ( <rdbms_external_table_options> ) }  )[;]

<rdbms_external_table_options> ::=  DATA_SOURCE = <External_Data_Source>,  [ SCHEMA_NAME = N'nonescaped_schema_name',]  [ OBJECT_NAME = N'nonescaped_object_name',]

For execute remote stored procedure:

Elastic query also introduces a stored procedure that provides direct access to the remote database. The stored procedure is called sp_execute _remote and can be used to execute remote stored procedures or T-SQL code on the remote database.

Example:

EXEC sp_execute_remote
        N'MyExtSrc',
        N'select count(w_id) as foo from warehouse'

For more details, please reference:

Reporting across scaled-out cloud databases (preview)

Query across cloud databases with different schemas (preview)

Hope this helps.