IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

SVG qui ne s'affichent pas correctement


Sujet :

JavaScript

  1. #1
    Nouveau Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Décembre 2020
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2020
    Messages : 1
    Points : 1
    Points
    1
    Par défaut SVG qui ne s'affichent pas correctement
    Bonjour,

    Je suis actuellement en train de coder une animation mais j'ai un problème avec l'affichage de mes svg. En effet, comme on le voit sur la photo, il semble qu'il manque un point à mon O, le A et le O sont ouvert, et il y a des petits fioritures sur certains angles (comme le G ou le cadenas bleu). Je n'arrive pas à comprendre ce problème puisque mes svg sont bien propres quand je les ouvre seul. Quelqu'un pourrait-il m'aider :'( (je mets également le zip de mon code)!!! merci

    Nom : Capture d’écran 2020-12-17 à 12.19.49.png
Affichages : 181
Taille : 107,8 Ko

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    <!DOCTYPE html>
    <html lang="en">
     
    <head>
    	<meta charset="UTF-8">
    	<link rel="stylesheet" href="style.css">
    	<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
    	<script src='https://cdnjs.cloudflare.com/ajax/libs/matter-js/0.10.0/matter.js'></script>
    	<script src='https://codepen.io/garethfoote/pen/jrQqVW.js'></script>
     
    </head>
     
    <body>
    	<svg id="svg" style="position:absolute; width: 0; height: 0; display: none;" version="1.1" xmlns="http://www.w3.org/2000/svg"
    		xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" xml:space="preserve">
    		<g>
    			<path class="cls-2"
    				d="M1178,2347.22c0-137.75,56.42-220,177.31-220,84.32,0,146.32,48.15,151.9,126.78h-58.9c-5.58-48.76-40.3-76.19-98.58-76.19-62,0-106.63,42.06-106.63,101.79v128c0,57.91,46.5,101.8,109.73,101.8,65.1,0,102.3-35.36,102.3-100v-28h-95.48v-51.81H1514v221.26h-56.42l-2.48-43.88c-21.7,31.69-53.94,53-107.26,53-107.25,0-169.87-82.29-169.87-212.74">
    			<path class="cls-2"
    				d="M1767.61,2554.37c-130.66,0-186.11-89-186.11-222.45s55.45-222.46,186.11-222.46,186.1,89,186.1,222.46S1898.26,2554.37,1767.61,2554.37Zm119.18-156.66V2266.12c0-64.54-53.54-104.64-119.18-104.64s-119.19,40.1-119.19,104.64v131.59c0,64.54,53.54,104.65,119.19,104.65S1886.79,2462.25,1886.79,2397.71Z">
    			<path class="cls-2"
    				d="M908.34 451.33 843.66 451.33 998.75 10.1 1068.71 10.1 1224.45 451.33 1158.66 451.33 1121.5 342.32 1035.65 342.32 1035.49 291.71 1105 291.71 1034.06 78.24 961.79 291.71 1032.16 291.71 1032.16 342.32 945.29 342.32 908.34 451.33" />
    			<path class="cls-2"
    				d="M2667.56,2468.58l107.25-320h91.76v414.5h-55.18V2210.14h-2.48l-119.66,352.93h-47.11l-120.28-352.93h-2.48v352.93H2464.2v-414.5h93l107.88,320Z" />
    		</g>
    	</svg>
    	<svg id="svglogo" style="position:absolute; width: 0; height: 0; display: none;" version="1.1" xmlns="http://www.w3.org/2000/svg"
    		xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" xml:space="preserve">
    		<g>
    			<path class="cls-1"
    				d="M1808.24,2764l.49,34.92s-41.66,13.14-41.8,64.78c-.12,39.83,36.2,63.4,70.35,63.4s69.64-27.56,71.1-64.32-25.64-54.46-37-61.13c-8.21-4.84-36-14.22-57.84-4.57l-.49-33.08s31.6-13.33,78.75,10.1c0,0,18.56-93.26-51.52-98.78-62-4.88-57.36,62.95-57.36,62.95h-34.52s1.06-40.61,17.26-62.49,44.43-34,71.92-33.08,62,12.36,80,47.76,10.21,118.56,10.21,118.56,28.31,48.48,5.35,92.81c-23.22,44.83-56.8,57.11-96.39,57.11-36.2,0-107.28-29.54-105.34-100.29s64.65-91.9,76.8-94.65"
    				transform="translate(-1730.9 -2642.19)" />
    		</g>
    	</svg>
     
     
    	<div id="container_canvas" style="	width:100vw; height:100vh; z-index:2;"></div>
     
    <script>
    var url = 'https://raw.githubusercontent.com/progers/pathseg/master/pathseg.js';
     
     
     
    loadGitHubScript(url).then(function () {
     
      // module aliases
      var Engine = Matter.Engine,
        Render = Matter.Render,
        World = Matter.World,
        Bodies = Matter.Bodies,
        Composites = Matter.Composites,
        Common = Matter.Common,
        Svg = Matter.Svg,
        Vertices = Matter.Vertices;
     
      // create an engine
      var engine = Engine.create();
     
      // create a renderer
      var render = Render.create({
        element: document.getElementById("container_canvas"),
        engine: engine,
        options: {
          width: window.innerWidth,
          height: window.innerHeight,
          wireframes: false,
          background: 'white'
        }
      });
     
     
      var vertexSets = [],
        color = Common.choose(['#556270', '#4ECDC4', '#C7F464', '#FF6B6B', '#C44D58']);
     
      $('#svg').find('path').each(function (i, path) {
        // vertexSets.push(Svg.pathToVertices(path, 100));
        var v = Bodies.fromVertices(150 + (i * 174), -2000+i*500, Svg.pathToVertices(path, 7), {
          render: {
            fillStyle: 'greenyellow',
            strokeStyle: 'greenyellow',
     
          }
        }, true);
        vertexSets.push(v);
     
        // World.add(engine.world, v);
      });
     
      $('#svglogo').find('path').each(function (i, path) {
        var v = Bodies.fromVertices(500 + (i * 104), -3000, Svg.pathToVertices(path, 10), {
          render: {
            fillStyle: 'blue',
            strokeStyle: 'blue',
     
          }
        }, true);
     
        vertexSets.push(v);
        
      });
     
      // APPLIQUER UNE ROTATION ALÉATOIRE À TOUS LES ÉLÉMENTS
      for (var i=0; i<vertexSets.length; i++)  {
        Matter.Body.rotate(vertexSets[i], Math.random()*180);
      }
     
      var offset = 10;
      var wallSize = 20;
     
      World.add(engine.world, [vertexSets,
        //bottom
        Bodies.rectangle(0, window.innerHeight+offset, window.innerWidth*2 , wallSize, {
          isStatic: true,
           render: {
            opacity:0
          }
        }),
        //right
        Bodies.rectangle(window.innerWidth+offset, 0, wallSize, window.innerHeight*2, {
          isStatic: true,
           render: {
            opacity:0
          }
     
        }),
     
        // // left
        Bodies.rectangle(-offset, 0, wallSize, window.innerHeight*2, {
          isStatic: true,
           render: {
            opacity:0
          }
        })
      ]);
     
     
      // add all of the bodies to the world
      Matter.World.add(engine.world, vertexSets);
      Engine.run(engine);
      Render.run(render);
     
      $(window).resize(function() {
       window.location.reload();
      });
     
    });
    </script>
    </body>
     
    </html>

  2. #2
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 054
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 054
    Points : 44 568
    Points
    44 568
    Par défaut
    Bonjour et bienvenue sur DVP.
    il semble qu'il manque un point à mon O, le A et le O sont ouvert,
    je pense que ton problème viens de tes SVG tout simplement qui ne sont pas « fermés ».

Discussions similaires

  1. Site et images qui ne s'affichent pas correctement
    Par akara dans le forum Hébergement
    Réponses: 1
    Dernier message: 21/12/2009, 19h30
  2. [Dojo] Des éléments dijit qui ne s'affichent pas correctement sous IE
    Par Tavarez59 dans le forum Bibliothèques & Frameworks
    Réponses: 3
    Dernier message: 02/11/2009, 19h04
  3. Date avec GregorianCalendar qui ne s'affiche pas correctement
    Par glasgow dans le forum Collection et Stream
    Réponses: 7
    Dernier message: 01/07/2009, 11h01
  4. Réponses: 1
    Dernier message: 21/11/2006, 16h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo