Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-updates > by-pkgid > 6e2327ca1c896c6d674ae53117299f21 > files > 1356

qtdeclarative5-doc-5.12.6-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- canvas.qdoc -->
  <title>Qt Quick Examples - Canvas | Qt Quick 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtquick-index.html">Qt Quick</a></td><td >Qt Quick Examples - Canvas</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#running-the-example">Running the Example</a></li>
<li class="level1"><a href="#red-heart">Red Heart</a></li>
<li class="level1"><a href="#talk-bubble">Talk Bubble</a></li>
<li class="level1"><a href="#squircle">Squircle</a></li>
<li class="level1"><a href="#rounded-rectangle">Rounded Rectangle</a></li>
<li class="level1"><a href="#smile-face">Smile Face</a></li>
<li class="level1"><a href="#clip">Clip</a></li>
<li class="level1"><a href="#tiger">Tiger</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Quick Examples - Canvas</h1>
<span class="subtitle"></span>
<!-- $$$canvas-brief -->
<p>This is a collection of QML Canvas examples.</p>
<!-- @@@canvas -->
<!-- $$$canvas-description -->
<div class="descr"> <a name="details"></a>
<p class="centerAlign"><img src="images/qml-canvas-example.png" alt="" /></p><p><i>Canvas</i> is a collection of small QML examples relating to the <a href="qml-qtquick-canvas.html">Canvas</a> type. Each example is a small QML file emphasizing a particular type or feature.</p>
<a name="running-the-example"></a>
<h2 id="running-the-example">Running the Example</h2>
<p>To run the example from Qt Creator, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit Building and Running an Example.</p>
<a name="red-heart"></a>
<h2 id="red-heart">Red Heart</h2>
<p><i>Red heart</i> uses the bezier curve API to stroke and fill a red heart.</p>
<pre class="qml">

  ctx.beginPath();
  ctx.moveTo(75,40);
  ctx.bezierCurveTo(75,37,70,25,50,25);
  ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
  ctx.bezierCurveTo(20,80,40,102,75,120);
  ctx.bezierCurveTo(110,102,130,80,130,62.5);
  ctx.bezierCurveTo(130,62.5,130,25,100,25);
  ctx.bezierCurveTo(85,25,75,37,75,40);
  ctx.closePath();

</pre>
<a name="talk-bubble"></a>
<h2 id="talk-bubble">Talk Bubble</h2>
<p><i>Talk bubble</i> uses the quadraticCurveTo() API to stroke and fill a customized talk bubble:</p>
<pre class="qml">

  ctx.beginPath();
  ctx.moveTo(75,25);
  ctx.quadraticCurveTo(25,25,25,62.5);
  ctx.quadraticCurveTo(25,100,50,100);
  ctx.quadraticCurveTo(50,120,30,125);
  ctx.quadraticCurveTo(60,120,65,100);
  ctx.quadraticCurveTo(125,100,125,62.5);
  ctx.quadraticCurveTo(125,25,75,25);
  ctx.closePath();

</pre>
<p>This example also demonstrates the fillText() API:</p>
<pre class="qml">

  ctx.fillStyle = "white";
  ctx.font = "bold 17px sans-serif";
  ctx.fillText("Qt Quick", 40, 70);

</pre>
<a name="squircle"></a>
<h2 id="squircle">Squircle</h2>
<p><i>Squircle</i> uses a collection of simple moveTo() and lineTo() path APIs to draw a smooth squircle.</p>
<a name="rounded-rectangle"></a>
<h2 id="rounded-rectangle">Rounded Rectangle</h2>
<p><i>Rounded rectangle</i> uses a collection of lineTo() and arcTo() path APIs to draw a rounded rectangle.</p>
<a name="smile-face"></a>
<h2 id="smile-face">Smile Face</h2>
<p><i>Smile face</i> uses several paths to draw and fill a smiling face.</p>
<a name="clip"></a>
<h2 id="clip">Clip</h2>
<p><i>Clip</i> uses the clip API to clip a given image.</p>
<pre class="qml">

  ctx.clip();
  ctx.drawImage(canvas.imagefile, 0, 0);

</pre>
<a name="tiger"></a>
<h2 id="tiger">Tiger</h2>
<p><i>Tiger</i> uses the SVG path API to draw a tiger with a collection of SVG path strings.</p>
<pre class="qml">

  for (var i = 0; i < Tiger.tiger.length; i++) {
      if (Tiger.tiger[i].width != undefined)
          ctx.lineWidth = Tiger.tiger[i].width;

      if (Tiger.tiger[i].path != undefined)
          ctx.path = Tiger.tiger[i].path;

      if (Tiger.tiger[i].fill != undefined) {
          ctx.fillStyle = Tiger.tiger[i].fill;
          ctx.fill();
      }

      if (Tiger.tiger[i].stroke != undefined) {
          ctx.strokeStyle = Tiger.tiger[i].stroke;
          ctx.stroke();
      }
  }

</pre>
<p>Files:</p>
<ul>
<li><a href="qtquick-canvas-beziercurve-beziercurve-qml.html">canvas/bezierCurve/bezierCurve.qml</a></li>
<li><a href="qtquick-canvas-canvas-pro.html">canvas/canvas.pro</a></li>
<li><a href="qtquick-canvas-canvas-qml.html">canvas/canvas.qml</a></li>
<li><a href="qtquick-canvas-canvas-qrc.html">canvas/canvas.qrc</a></li>
<li><a href="qtquick-canvas-clip-clip-qml.html">canvas/clip/clip.qml</a></li>
<li><a href="qtquick-canvas-main-cpp.html">canvas/main.cpp</a></li>
<li><a href="qtquick-canvas-quadraticcurveto-quadraticcurveto-qml.html">canvas/quadraticCurveTo/quadraticCurveTo.qml</a></li>
<li><a href="qtquick-canvas-roundedrect-roundedrect-qml.html">canvas/roundedrect/roundedrect.qml</a></li>
<li><a href="qtquick-canvas-smile-smile-qml.html">canvas/smile/smile.qml</a></li>
<li><a href="qtquick-canvas-squircle-squircle-qml.html">canvas/squircle/squircle.qml</a></li>
<li><a href="qtquick-canvas-tiger-tiger-js.html">canvas/tiger/tiger.js</a></li>
<li><a href="qtquick-canvas-tiger-tiger-qml.html">canvas/tiger/tiger.qml</a></li>
</ul>
<p>Images:</p>
<ul>
<li><a href="images/used-in-examples/canvas/contents/qt-logo.png">canvas/contents/qt-logo.png</a></li>
<li><a href="images/used-in-examples/canvas/squircle/squircle.png">canvas/squircle/squircle.png</a></li>
</ul>
</div>
<!-- @@@canvas -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>