Bezier | 绘制任意阶数的贝塞尔曲线

 by   7heaven Java Updated: 3 years ago - Current License: No License

Download this library from

Build Applications

kandi X-RAY | Bezier REVIEW AND RATINGS

绘制任意阶数的贝塞尔曲线

kandi-support
Support

  • Bezier has a low active ecosystem.
  • It has 19 star(s) with 4 fork(s).
  • It had no major release in the last 12 months.
  • It has a neutral sentiment in the developer community.

quality kandi
Quality

  • Bezier has 0 bugs and 0 code smells.

security
Security

  • Bezier has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • Bezier code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.

license
License

  • Bezier does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.

build
Reuse

  • Bezier releases are not available. You will need to build from source code and install.
  • Bezier has no build file. You will be need to create the build yourself to build the component from source.
  • Bezier saves you 84 person hours of effort in developing the same functionality from scratch.
  • It has 216 lines of code, 9 functions and 15 files with 0 % test coverage
  • It has low code complexity. Code complexity directly impacts maintainability of the code.
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

Bezier Key Features

绘制任意阶数的贝塞尔曲线

Bezier examples and code snippets

  • Vue add class before insert, leave it
  • Find point on cubic bezier given x-pos
  • Do not close the mode in the mouse up event
  • React inlined SVG paths are not responding to css animations
  • Is there a convenient way to draw arc only using two points and curve radius in Android?
  • animate Kivy Bezier curve with custom width ? (a bit silly question)
  • How to draw another layer of hexagon UIBezier Path and animate accordingly
  • How to put an element (a grid) under an image?
  • Merging two SVG Paths: Open Bezier and Line
  • How to make Canvas vertex instructions relative to a widget in Kivy

Vue add class before insert, leave it

<div id="app">
  <div>
    <button type="button" @click="toggle">Toggle</button>
  </div>
  <transition name="label" v-on:enter="enter" v-on:before-leave="leave">
    <div v-if="isOpen">Hi</div>
  </transition>
</div>
.label-enter-active, .label-leave-active {
  transition: opacity 1s;
}
.label-enter, .label-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}

.staying-visible {
  background-color: red;
  color: white;
}
const vm = new Vue({
  el: '#app',
  data: {
    isOpen: false
  },
  methods: {
    enter(el){
      el.classList.add("staying-visible")
    },
    leave(el){
      el.classList.remove("staying-visible")
    },
    toggle(){
      this.isOpen = !this.isOpen
    }
  }
})
-----------------------
<div id="app">
  <div>
    <button type="button" @click="toggle">Toggle</button>
  </div>
  <transition name="label" v-on:enter="enter" v-on:before-leave="leave">
    <div v-if="isOpen">Hi</div>
  </transition>
</div>
.label-enter-active, .label-leave-active {
  transition: opacity 1s;
}
.label-enter, .label-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}

.staying-visible {
  background-color: red;
  color: white;
}
const vm = new Vue({
  el: '#app',
  data: {
    isOpen: false
  },
  methods: {
    enter(el){
      el.classList.add("staying-visible")
    },
    leave(el){
      el.classList.remove("staying-visible")
    },
    toggle(){
      this.isOpen = !this.isOpen
    }
  }
})
-----------------------
<div id="app">
  <div>
    <button type="button" @click="toggle">Toggle</button>
  </div>
  <transition name="label" v-on:enter="enter" v-on:before-leave="leave">
    <div v-if="isOpen">Hi</div>
  </transition>
</div>
.label-enter-active, .label-leave-active {
  transition: opacity 1s;
}
.label-enter, .label-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}

.staying-visible {
  background-color: red;
  color: white;
}
const vm = new Vue({
  el: '#app',
  data: {
    isOpen: false
  },
  methods: {
    enter(el){
      el.classList.add("staying-visible")
    },
    leave(el){
      el.classList.remove("staying-visible")
    },
    toggle(){
      this.isOpen = !this.isOpen
    }
  }
})

Find point on cubic bezier given x-pos

function getCubicBezierY(a, b, p, q, x) {
    // By the Cubic Bézier curve formula, we know that
    // 3(1-t)²ta + 3(1-t)t²p + t³ - x = 0
    // After formatting it to the cubic equation form, we have
    // (3a-3p+1)t³ + (3p-6a)t² + 3at - x = 0
    // Solve the equation
    const t = solveCubic(3*a-3*p+1, 3*p-6*a, 3*a, -x)[0]; // There should be only 1 root
    const r = 1 - t;
    // Find y by using the Cubic Bezier curve formula
    return 3*r*r*t*b + 3*r*t*t*q + t*t*t;
}

// Functions for solving cubic equation
function cuberoot(x) {
    var y = Math.pow(Math.abs(x), 1/3);
    return x < 0 ? -y : y;
}

function solveCubic(a, b, c, d) {
    if (Math.abs(a) < Number.EPSILON) { // Quadratic case, ax^2+bx+c=0
        a = b; b = c; c = d;
        if (Math.abs(a) < Number.EPSILON) { // Linear case, ax+b=0
            a = b; b = c;
            if (Math.abs(a) < Number.EPSILON) // Degenerate case
                return [];
            return [-b/a];
        }

        var D = b*b - 4*a*c;
        if (Math.abs(D) < Number.EPSILON)
            return [-b/(2*a)];
        else if (D > 0)
            return [(-b+Math.sqrt(D))/(2*a), (-b-Math.sqrt(D))/(2*a)];
        return [];
    }

    // Convert to depressed cubic t^3+pt+q = 0 (subst x = t - b/3a)
    var p = (3*a*c - b*b)/(3*a*a);
    var q = (2*b*b*b - 9*a*b*c + 27*a*a*d)/(27*a*a*a);
    var roots;

    if (Math.abs(p) < Number.EPSILON) { // p = 0 -> t^3 = -q -> t = -q^1/3
        roots = [cuberoot(-q)];
    } else if (Math.abs(q) < Number.EPSILON) { // q = 0 -> t^3 + pt = 0 -> t(t^2+p)=0
        roots = [0].concat(p < 0 ? [Math.sqrt(-p), -Math.sqrt(-p)] : []);
    } else {
        var D = q*q/4 + p*p*p/27;
        if (Math.abs(D) < Number.EPSILON) {       // D = 0 -> two roots
            roots = [-1.5*q/p, 3*q/p];
        } else if (D > 0) {             // Only one real root
            var u = cuberoot(-q/2 - Math.sqrt(D));
            roots = [u - p/(3*u)];
        } else {                        // D < 0, three roots, but needs to use complex numbers/trigonometric solution
            var u = 2*Math.sqrt(-p/3);
            var t = Math.acos(3*q/p/u)/3;  // D < 0 implies p < 0 and acos argument in [-1..1]
            var k = 2*Math.PI/3;
            roots = [u*Math.cos(t), u*Math.cos(t-k), u*Math.cos(t-2*k)];
        }
    }

    // Convert back from depressed cubic
    for (var i = 0; i < roots.length; i++)
        roots[i] -= b/(3*a);

    return roots;
}

Do not close the mode in the mouse up event

<div class="modal__overlay" tabindex="-1">
-----------------------
let openButton = document.getElementById('open-modal');

openButton.addEventListener('click', function() {
    MicroModal.show('modal-1');
});

const overlays = document.querySelectorAll(".modal__overlay");
for(let i = 0; i < overlays.length; i++)
{
  const overlay = overlays[i];
  let overlayMouseDown;

  /* detect if clicked on overlay itself */
  overlay.addEventListener("mousedown", e => overlayMouseDown = e.target === overlay);
  /* prevent from closing when clicked on overlay and dragged into modal */
  overlay.addEventListener("mouseout", e => overlayMouseDown = false);
  overlay.addEventListener("click", e =>
  {
    if (e.target === overlay && !overlayMouseDown)
    {
      e.preventDefault();
      e.stopPropagation();
    }
  });
}
/**************************\
  Basic Modal Styles
\**************************/

.modal {
    font-family: -apple-system,BlinkMacSystemFont,avenir next,avenir,helvetica neue,helvetica,ubuntu,roboto,noto,segoe ui,arial,sans-serif;
}

.modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal__container {
    background-color: #fff;
    padding: 30px;
    max-width: 500px;
    max-height: 100vh;
    border-radius: 4px;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal__title {
    margin-top: 0;
    margin-bottom: 0;
    font-weight: 600;
    font-size: 1.25rem;
    line-height: 1.25;
    color: #00449e;
    box-sizing: border-box;
}

.modal__close {
    background: transparent;
    border: 0;
}

.modal__header .modal__close:before { content: "\2715"; }

.modal__content {
    margin-top: 2rem;
    margin-bottom: 2rem;
    line-height: 1.5;
    color: rgba(0,0,0,.8);
}

.modal__btn {
    font-size: .875rem;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: .5rem;
    padding-bottom: .5rem;
    background-color: #e6e6e6;
    color: rgba(0,0,0,.8);
    border-radius: .25rem;
    border-style: none;
    border-width: 0;
    cursor: pointer;
    -webkit-appearance: button;
    text-transform: none;
    overflow: visible;
    line-height: 1.15;
    margin: 0;
    will-change: transform;
    -moz-osx-font-smoothing: grayscale;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    transition: -webkit-transform .25s ease-out;
    transition: transform .25s ease-out;
    transition: transform .25s ease-out,-webkit-transform .25s ease-out;
}

.modal__btn:focus, .modal__btn:hover {
    -webkit-transform: scale(1.05);
    transform: scale(1.05);
}

.modal__btn-primary {
    background-color: #00449e;
    color: #fff;
}



/**************************\
  Demo Animation Style
\**************************/
@keyframes mmfadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes mmfadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes mmslideIn {
    from { transform: translateY(15%); }
    to { transform: translateY(0); }
}

@keyframes mmslideOut {
    from { transform: translateY(0); }
    to { transform: translateY(-10%); }
}

.micromodal-slide {
    display: none;
}

.micromodal-slide.is-open {
    display: block;
}

.micromodal-slide[aria-hidden="false"] .modal__overlay {
    animation: mmfadeIn .3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.micromodal-slide[aria-hidden="false"] .modal__container {
    animation: mmslideIn .3s cubic-bezier(0, 0, .2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__overlay {
    animation: mmfadeOut .3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__container {
    animation: mmslideOut .3s cubic-bezier(0, 0, .2, 1);
}

.micromodal-slide .modal__container,
.micromodal-slide .modal__overlay {
    will-change: transform;
}
<html>
<head>
    <Title>MicroModal Toggle Pen</Title>
    <script defer  src="https://unpkg.com/micromodal/dist/micromodal.min.js"></script>
    <script  defer  src="script.js"></script>
    <link rel="stylesheet" href="style.css">
</head>
<body>

<button type="button" id="open-modal">Open new modal</button>

<!-- New event modal -->
<div class="modal micromodal-slide" id="modal-1" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    New event
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                <input type="text" placeholder="name">
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>

<!-- Event 1 -->
<div class="modal micromodal-slide" id="event-modal-1" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    Event 1
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                Blah
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>

<!-- Event Modal 2 -->
<div class="modal micromodal-slide" id="event-modal-2" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    Event 2
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                blah
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>
</body>
</html>
-----------------------
let openButton = document.getElementById('open-modal');

openButton.addEventListener('click', function() {
    MicroModal.show('modal-1');
});

const overlays = document.querySelectorAll(".modal__overlay");
for(let i = 0; i < overlays.length; i++)
{
  const overlay = overlays[i];
  let overlayMouseDown;

  /* detect if clicked on overlay itself */
  overlay.addEventListener("mousedown", e => overlayMouseDown = e.target === overlay);
  /* prevent from closing when clicked on overlay and dragged into modal */
  overlay.addEventListener("mouseout", e => overlayMouseDown = false);
  overlay.addEventListener("click", e =>
  {
    if (e.target === overlay && !overlayMouseDown)
    {
      e.preventDefault();
      e.stopPropagation();
    }
  });
}
/**************************\
  Basic Modal Styles
\**************************/

.modal {
    font-family: -apple-system,BlinkMacSystemFont,avenir next,avenir,helvetica neue,helvetica,ubuntu,roboto,noto,segoe ui,arial,sans-serif;
}

.modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal__container {
    background-color: #fff;
    padding: 30px;
    max-width: 500px;
    max-height: 100vh;
    border-radius: 4px;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal__title {
    margin-top: 0;
    margin-bottom: 0;
    font-weight: 600;
    font-size: 1.25rem;
    line-height: 1.25;
    color: #00449e;
    box-sizing: border-box;
}

.modal__close {
    background: transparent;
    border: 0;
}

.modal__header .modal__close:before { content: "\2715"; }

.modal__content {
    margin-top: 2rem;
    margin-bottom: 2rem;
    line-height: 1.5;
    color: rgba(0,0,0,.8);
}

.modal__btn {
    font-size: .875rem;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: .5rem;
    padding-bottom: .5rem;
    background-color: #e6e6e6;
    color: rgba(0,0,0,.8);
    border-radius: .25rem;
    border-style: none;
    border-width: 0;
    cursor: pointer;
    -webkit-appearance: button;
    text-transform: none;
    overflow: visible;
    line-height: 1.15;
    margin: 0;
    will-change: transform;
    -moz-osx-font-smoothing: grayscale;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    transition: -webkit-transform .25s ease-out;
    transition: transform .25s ease-out;
    transition: transform .25s ease-out,-webkit-transform .25s ease-out;
}

.modal__btn:focus, .modal__btn:hover {
    -webkit-transform: scale(1.05);
    transform: scale(1.05);
}

.modal__btn-primary {
    background-color: #00449e;
    color: #fff;
}



/**************************\
  Demo Animation Style
\**************************/
@keyframes mmfadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes mmfadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes mmslideIn {
    from { transform: translateY(15%); }
    to { transform: translateY(0); }
}

@keyframes mmslideOut {
    from { transform: translateY(0); }
    to { transform: translateY(-10%); }
}

.micromodal-slide {
    display: none;
}

.micromodal-slide.is-open {
    display: block;
}

.micromodal-slide[aria-hidden="false"] .modal__overlay {
    animation: mmfadeIn .3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.micromodal-slide[aria-hidden="false"] .modal__container {
    animation: mmslideIn .3s cubic-bezier(0, 0, .2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__overlay {
    animation: mmfadeOut .3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__container {
    animation: mmslideOut .3s cubic-bezier(0, 0, .2, 1);
}

.micromodal-slide .modal__container,
.micromodal-slide .modal__overlay {
    will-change: transform;
}
<html>
<head>
    <Title>MicroModal Toggle Pen</Title>
    <script defer  src="https://unpkg.com/micromodal/dist/micromodal.min.js"></script>
    <script  defer  src="script.js"></script>
    <link rel="stylesheet" href="style.css">
</head>
<body>

<button type="button" id="open-modal">Open new modal</button>

<!-- New event modal -->
<div class="modal micromodal-slide" id="modal-1" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    New event
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                <input type="text" placeholder="name">
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>

<!-- Event 1 -->
<div class="modal micromodal-slide" id="event-modal-1" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    Event 1
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                Blah
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>

<!-- Event Modal 2 -->
<div class="modal micromodal-slide" id="event-modal-2" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    Event 2
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                blah
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>
</body>
</html>
-----------------------
let openButton = document.getElementById('open-modal');

openButton.addEventListener('click', function() {
    MicroModal.show('modal-1');
});

const overlays = document.querySelectorAll(".modal__overlay");
for(let i = 0; i < overlays.length; i++)
{
  const overlay = overlays[i];
  let overlayMouseDown;

  /* detect if clicked on overlay itself */
  overlay.addEventListener("mousedown", e => overlayMouseDown = e.target === overlay);
  /* prevent from closing when clicked on overlay and dragged into modal */
  overlay.addEventListener("mouseout", e => overlayMouseDown = false);
  overlay.addEventListener("click", e =>
  {
    if (e.target === overlay && !overlayMouseDown)
    {
      e.preventDefault();
      e.stopPropagation();
    }
  });
}
/**************************\
  Basic Modal Styles
\**************************/

.modal {
    font-family: -apple-system,BlinkMacSystemFont,avenir next,avenir,helvetica neue,helvetica,ubuntu,roboto,noto,segoe ui,arial,sans-serif;
}

.modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal__container {
    background-color: #fff;
    padding: 30px;
    max-width: 500px;
    max-height: 100vh;
    border-radius: 4px;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal__title {
    margin-top: 0;
    margin-bottom: 0;
    font-weight: 600;
    font-size: 1.25rem;
    line-height: 1.25;
    color: #00449e;
    box-sizing: border-box;
}

.modal__close {
    background: transparent;
    border: 0;
}

.modal__header .modal__close:before { content: "\2715"; }

.modal__content {
    margin-top: 2rem;
    margin-bottom: 2rem;
    line-height: 1.5;
    color: rgba(0,0,0,.8);
}

.modal__btn {
    font-size: .875rem;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: .5rem;
    padding-bottom: .5rem;
    background-color: #e6e6e6;
    color: rgba(0,0,0,.8);
    border-radius: .25rem;
    border-style: none;
    border-width: 0;
    cursor: pointer;
    -webkit-appearance: button;
    text-transform: none;
    overflow: visible;
    line-height: 1.15;
    margin: 0;
    will-change: transform;
    -moz-osx-font-smoothing: grayscale;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    transition: -webkit-transform .25s ease-out;
    transition: transform .25s ease-out;
    transition: transform .25s ease-out,-webkit-transform .25s ease-out;
}

.modal__btn:focus, .modal__btn:hover {
    -webkit-transform: scale(1.05);
    transform: scale(1.05);
}

.modal__btn-primary {
    background-color: #00449e;
    color: #fff;
}



/**************************\
  Demo Animation Style
\**************************/
@keyframes mmfadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes mmfadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes mmslideIn {
    from { transform: translateY(15%); }
    to { transform: translateY(0); }
}

@keyframes mmslideOut {
    from { transform: translateY(0); }
    to { transform: translateY(-10%); }
}

.micromodal-slide {
    display: none;
}

.micromodal-slide.is-open {
    display: block;
}

.micromodal-slide[aria-hidden="false"] .modal__overlay {
    animation: mmfadeIn .3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.micromodal-slide[aria-hidden="false"] .modal__container {
    animation: mmslideIn .3s cubic-bezier(0, 0, .2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__overlay {
    animation: mmfadeOut .3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__container {
    animation: mmslideOut .3s cubic-bezier(0, 0, .2, 1);
}

.micromodal-slide .modal__container,
.micromodal-slide .modal__overlay {
    will-change: transform;
}
<html>
<head>
    <Title>MicroModal Toggle Pen</Title>
    <script defer  src="https://unpkg.com/micromodal/dist/micromodal.min.js"></script>
    <script  defer  src="script.js"></script>
    <link rel="stylesheet" href="style.css">
</head>
<body>

<button type="button" id="open-modal">Open new modal</button>

<!-- New event modal -->
<div class="modal micromodal-slide" id="modal-1" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    New event
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                <input type="text" placeholder="name">
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>

<!-- Event 1 -->
<div class="modal micromodal-slide" id="event-modal-1" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    Event 1
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                Blah
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>

<!-- Event Modal 2 -->
<div class="modal micromodal-slide" id="event-modal-2" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    Event 2
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                blah
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>
</body>
</html>
-----------------------
let openButton = document.getElementById('open-modal');
const modalOverlay = document.querySelector('.modal__overlay');
openButton.addEventListener('click', function () {
    MicroModal.show('modal-1');
});

modalOverlay.addEventListener('mousedown', (e) => {
    if (e.target.closest('.modal__container'))
        return;
    MicroModal.close('modal-1');
});

React inlined SVG paths are not responding to css animations

import React from 'react';
import './style.css';

import Triangles from './svg/Triangles';

export default function App() {
  return (
    <div>
      <Triangles />
    </div>
  );
}
import React from 'react';

export default function Triangles() {
  return (
    <div className="triangles">
      <svg className="triangle one">
        <path d="M150 0 L30 200 L270 200 Z" />
      </svg>
      <svg className="triangle two">
        <path d="M120 0 L30 180 L200 200 Z" />
      </svg>
      <svg className="triangle three">
        <path d="M10 0 L40 280 L190 170 Z" />
      </svg>
    </div>
  );
}
/* Triangles */
.triangles {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50vh;
}
.triangle {
  position: absolute;
  fill: rgb(23, 233, 224);
  fill-opacity: 0.4;
  animation-name: spin;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
.triangle.one {
  height: 210px;
  width: 300px;
  animation-duration: 5000ms;
}
.triangle.two {
  height: 150px;
  width: 400px;
  animation-duration: 9000ms;
}
.triangle.three {
  height: 120px;
  width: 300px;
  animation-duration: 3000ms;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
-----------------------
import React from 'react';
import './style.css';

import Triangles from './svg/Triangles';

export default function App() {
  return (
    <div>
      <Triangles />
    </div>
  );
}
import React from 'react';

export default function Triangles() {
  return (
    <div className="triangles">
      <svg className="triangle one">
        <path d="M150 0 L30 200 L270 200 Z" />
      </svg>
      <svg className="triangle two">
        <path d="M120 0 L30 180 L200 200 Z" />
      </svg>
      <svg className="triangle three">
        <path d="M10 0 L40 280 L190 170 Z" />
      </svg>
    </div>
  );
}
/* Triangles */
.triangles {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50vh;
}
.triangle {
  position: absolute;
  fill: rgb(23, 233, 224);
  fill-opacity: 0.4;
  animation-name: spin;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
.triangle.one {
  height: 210px;
  width: 300px;
  animation-duration: 5000ms;
}
.triangle.two {
  height: 150px;
  width: 400px;
  animation-duration: 9000ms;
}
.triangle.three {
  height: 120px;
  width: 300px;
  animation-duration: 3000ms;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
-----------------------
import React from 'react';
import './style.css';

import Triangles from './svg/Triangles';

export default function App() {
  return (
    <div>
      <Triangles />
    </div>
  );
}
import React from 'react';

export default function Triangles() {
  return (
    <div className="triangles">
      <svg className="triangle one">
        <path d="M150 0 L30 200 L270 200 Z" />
      </svg>
      <svg className="triangle two">
        <path d="M120 0 L30 180 L200 200 Z" />
      </svg>
      <svg className="triangle three">
        <path d="M10 0 L40 280 L190 170 Z" />
      </svg>
    </div>
  );
}
/* Triangles */
.triangles {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50vh;
}
.triangle {
  position: absolute;
  fill: rgb(23, 233, 224);
  fill-opacity: 0.4;
  animation-name: spin;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
.triangle.one {
  height: 210px;
  width: 300px;
  animation-duration: 5000ms;
}
.triangle.two {
  height: 150px;
  width: 400px;
  animation-duration: 9000ms;
}
.triangle.three {
  height: 120px;
  width: 300px;
  animation-duration: 3000ms;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

Is there a convenient way to draw arc only using two points and curve radius in Android?

    val startAngle = acos((x1 - x0) / r) / Math.PI.toFloat() * 180
    val endAngle = acos((x2 - x0) / r) / Math.PI.toFloat() * 180
    val sweepAngle = endAngle - startAngle
    /**
     * Append the arc which is starting at ([x1], [y1]), ending at ([x2], [y2])
     * and with the curve radius [r] to the path.
     * The Boolean value [clockwise] shows whether the process drawing the arc
     * is clockwise.
     */
    @Throws(Exception::class)
    private fun Path.arcFromTo(
        x1: Float, y1: Float, x2: Float, y2: Float, r: Float,
        clockwise: Boolean = true
    ) {
        val c = centerPos(x1, y1, x2, y2, r, clockwise) // circle centers
        // RectF borders
        val left = c.x - r
        val top = c.y - r
        val right = c.x + r
        val bottom = c.y + r
        val startAngle = acos((x1 - c.x) / r) / Math.PI.toFloat() * 180
        val endAngle = acos((x2 - c.x) / r) / Math.PI.toFloat() * 180
        arcTo(
            left, top, right, bottom,
            if (clockwise) startAngle else -startAngle,
            if (clockwise) endAngle - startAngle else startAngle - endAngle,
            false
        )
    }

    // use similar triangles to calculate circle center
    @Throws(Exception::class)
    private fun centerPos(
        x1: Float, y1: Float, x2: Float, y2: Float, r: Float,
        clockwise: Boolean
    ): Point {
        val ab = ((x1 - x2).p2 + (y1 - y2).p2).sqrt
        if (ab > r * 2) throw Exception("No circle fits the condition.")
        val a = ab / 2
        val oc = (r.p2 - a.p2).sqrt
        val dx = (oc * (y2 - y1) / ab).absoluteValue.toInt()
        val dy = (oc * (x2 - x1) / ab).absoluteValue.toInt()
        val cx = ((x1 + x2) / 2).toInt()
        val cy = ((y1 + y2) / 2).toInt()
        return if (x1 >= x2 && y1 >= y2 || x1 <= x2 && y1 <= y2)
            if (clockwise) Point(cx + dx, cy - dy) else Point(cx - dx, cy + dy)
        else
            if (clockwise) Point(cx - dx, cy - dy) else Point(cx + dx, cy + dy)
    }
-----------------------
    val startAngle = acos((x1 - x0) / r) / Math.PI.toFloat() * 180
    val endAngle = acos((x2 - x0) / r) / Math.PI.toFloat() * 180
    val sweepAngle = endAngle - startAngle
    /**
     * Append the arc which is starting at ([x1], [y1]), ending at ([x2], [y2])
     * and with the curve radius [r] to the path.
     * The Boolean value [clockwise] shows whether the process drawing the arc
     * is clockwise.
     */
    @Throws(Exception::class)
    private fun Path.arcFromTo(
        x1: Float, y1: Float, x2: Float, y2: Float, r: Float,
        clockwise: Boolean = true
    ) {
        val c = centerPos(x1, y1, x2, y2, r, clockwise) // circle centers
        // RectF borders
        val left = c.x - r
        val top = c.y - r
        val right = c.x + r
        val bottom = c.y + r
        val startAngle = acos((x1 - c.x) / r) / Math.PI.toFloat() * 180
        val endAngle = acos((x2 - c.x) / r) / Math.PI.toFloat() * 180
        arcTo(
            left, top, right, bottom,
            if (clockwise) startAngle else -startAngle,
            if (clockwise) endAngle - startAngle else startAngle - endAngle,
            false
        )
    }

    // use similar triangles to calculate circle center
    @Throws(Exception::class)
    private fun centerPos(
        x1: Float, y1: Float, x2: Float, y2: Float, r: Float,
        clockwise: Boolean
    ): Point {
        val ab = ((x1 - x2).p2 + (y1 - y2).p2).sqrt
        if (ab > r * 2) throw Exception("No circle fits the condition.")
        val a = ab / 2
        val oc = (r.p2 - a.p2).sqrt
        val dx = (oc * (y2 - y1) / ab).absoluteValue.toInt()
        val dy = (oc * (x2 - x1) / ab).absoluteValue.toInt()
        val cx = ((x1 + x2) / 2).toInt()
        val cy = ((y1 + y2) / 2).toInt()
        return if (x1 >= x2 && y1 >= y2 || x1 <= x2 && y1 <= y2)
            if (clockwise) Point(cx + dx, cy - dy) else Point(cx - dx, cy + dy)
        else
            if (clockwise) Point(cx - dx, cy - dy) else Point(cx + dx, cy + dy)
    }
-----------------------
@Throws(Exception::class)
private fun Path.arcFromTo2(
    x1: Float, y1: Float, x2: Float, y2: Float, r: Float,
    clockwise: Boolean = true
) {

    val d = PointF((x2 - x1) * 0.5F, (y2 - y1) * 0.5F)
    val a = d.length()
    if (a > r) throw Exception()

    val side = if (clockwise) 1 else -1

    val oc = sqrt(r * r - a * a)
    val ox = (x1 + x2) * 0.5F - side * oc * d.y / a
    val oy = (y1 + y2) * 0.5F + side * oc * d.x / a

    val startAngle = atan2(y1 - oy, x1 - ox) * 180F / Math.PI.toFloat()
    val sweepAngle = side * 2.0F * asin(a / r) * 180F / Math.PI.toFloat()

    arcTo(
        ox - r, oy - r, ox + r, oy + r,
        startAngle, sweepAngle,
        false
    )
}

animate Kivy Bezier curve with custom width ? (a bit silly question)

from kivy.animation import Animation
from kivy.app import App
from kivy.clock import Clock
from kivy.properties import NumericProperty
from kivy.uix.widget import Widget
from kivy.graphics import *

class MyLayout(Widget):
    line_width = NumericProperty(12)
    def __init__(self):
        super(MyLayout, self).__init__()
        with self.canvas:
            self.L=Bezier(points=[200,450,500,300,600,150],width=self.line_width)
            self.k=Line  (bezier=[100,350,400,200,500,50 ],width=self.line_width)

    def on_line_width(self, instance, new_width):
        self.k.width = new_width

class MyApp(App):

    def build(self):
        Clock.schedule_once(self.anim)
        return MyLayout()

    def anim(self, dt):
        a = Animation(line_width=3)
        a.start(self.root)

if __name__=="__main__":
    MyApp().run()
-----------------------
Line:
    bezier:[n1,n2,n3,n4]
    width:3
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.boxlayout import BoxLayout

posicao=[]
class Draw(BoxLayout):
    def __init__(self, **kwargs):
        super(Draw, self).__init__(**kwargs)
    
    def on_touch_down(self,touch):
        posicao.append(touch.pos)
        
    def on_touch_up(self,touch):
        posicao.clear()
        
    def on_touch_move(self,touch):
        Line = Builder.load_string(
"""
FloatLayout:
    canvas:
        Color:
            rgba:11,.1,1,1
        Line:
            points: {pos}
            width:14
""".format(pos=(touch.pos, posicao[0])))
        self.add_widget(Line)
        posicao.clear()
        posicao.append(touch.pos)
        
class Code(App):
    def build(self):
        return Draw()
        
if __name__ == '__main__':
    Code().run()
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.graphics import *

posi = []

Builder.load_string(
"""
<Draw>:
    
""")
class Draw(BoxLayout):
    def __init__(self, **kwargs):
        super(Draw, self).__init__(**kwargs)
    
    def on_touch_down(self,touch):
        posi.clear()
        posi.append(touch.pos)
        
    def on_touch_up(self,touch):
        posi.clear()
        
    def on_touch_move(self,touch):
        with self.canvas:
            Line(points=[posi[0], touch.pos],width=14)
        posi.clear()
        posi.append(touch.pos)
            
class Code(App):
    def build(self):
        return Draw()
        
if __name__ == '__main__':
    Code().run()
-----------------------
Line:
    bezier:[n1,n2,n3,n4]
    width:3
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.boxlayout import BoxLayout

posicao=[]
class Draw(BoxLayout):
    def __init__(self, **kwargs):
        super(Draw, self).__init__(**kwargs)
    
    def on_touch_down(self,touch):
        posicao.append(touch.pos)
        
    def on_touch_up(self,touch):
        posicao.clear()
        
    def on_touch_move(self,touch):
        Line = Builder.load_string(
"""
FloatLayout:
    canvas:
        Color:
            rgba:11,.1,1,1
        Line:
            points: {pos}
            width:14
""".format(pos=(touch.pos, posicao[0])))
        self.add_widget(Line)
        posicao.clear()
        posicao.append(touch.pos)
        
class Code(App):
    def build(self):
        return Draw()
        
if __name__ == '__main__':
    Code().run()
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.graphics import *

posi = []

Builder.load_string(
"""
<Draw>:
    
""")
class Draw(BoxLayout):
    def __init__(self, **kwargs):
        super(Draw, self).__init__(**kwargs)
    
    def on_touch_down(self,touch):
        posi.clear()
        posi.append(touch.pos)
        
    def on_touch_up(self,touch):
        posi.clear()
        
    def on_touch_move(self,touch):
        with self.canvas:
            Line(points=[posi[0], touch.pos],width=14)
        posi.clear()
        posi.append(touch.pos)
            
class Code(App):
    def build(self):
        return Draw()
        
if __name__ == '__main__':
    Code().run()
-----------------------
Line:
    bezier:[n1,n2,n3,n4]
    width:3
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.boxlayout import BoxLayout

posicao=[]
class Draw(BoxLayout):
    def __init__(self, **kwargs):
        super(Draw, self).__init__(**kwargs)
    
    def on_touch_down(self,touch):
        posicao.append(touch.pos)
        
    def on_touch_up(self,touch):
        posicao.clear()
        
    def on_touch_move(self,touch):
        Line = Builder.load_string(
"""
FloatLayout:
    canvas:
        Color:
            rgba:11,.1,1,1
        Line:
            points: {pos}
            width:14
""".format(pos=(touch.pos, posicao[0])))
        self.add_widget(Line)
        posicao.clear()
        posicao.append(touch.pos)
        
class Code(App):
    def build(self):
        return Draw()
        
if __name__ == '__main__':
    Code().run()
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.graphics import *

posi = []

Builder.load_string(
"""
<Draw>:
    
""")
class Draw(BoxLayout):
    def __init__(self, **kwargs):
        super(Draw, self).__init__(**kwargs)
    
    def on_touch_down(self,touch):
        posi.clear()
        posi.append(touch.pos)
        
    def on_touch_up(self,touch):
        posi.clear()
        
    def on_touch_move(self,touch):
        with self.canvas:
            Line(points=[posi[0], touch.pos],width=14)
        posi.clear()
        posi.append(touch.pos)
            
class Code(App):
    def build(self):
        return Draw()
        
if __name__ == '__main__':
    Code().run()

How to draw another layer of hexagon UIBezier Path and animate accordingly

var grayLayer = CAShapeLayer()
grayLayer.lineWidth = lineWidth
grayLayer.fillColor = nil
grayLayer.strokeColor = UIColor.gray.cgColor
backgroundMask.path = path.cgPath
grayLayer.path = path.cgPath
layer.addSublayer(grayLayer)
layer.addSublayer(backgroundMask)
-----------------------
var grayLayer = CAShapeLayer()
grayLayer.lineWidth = lineWidth
grayLayer.fillColor = nil
grayLayer.strokeColor = UIColor.gray.cgColor
backgroundMask.path = path.cgPath
grayLayer.path = path.cgPath
layer.addSublayer(grayLayer)
layer.addSublayer(backgroundMask)
-----------------------
var grayLayer = CAShapeLayer()
grayLayer.lineWidth = lineWidth
grayLayer.fillColor = nil
grayLayer.strokeColor = UIColor.gray.cgColor
backgroundMask.path = path.cgPath
grayLayer.path = path.cgPath
layer.addSublayer(grayLayer)
layer.addSublayer(backgroundMask)
-----------------------
var grayLayer = CAShapeLayer()
grayLayer.lineWidth = lineWidth
grayLayer.fillColor = nil
grayLayer.strokeColor = UIColor.gray.cgColor
backgroundMask.path = path.cgPath
grayLayer.path = path.cgPath
layer.addSublayer(grayLayer)
layer.addSublayer(backgroundMask)

How to put an element (a grid) under an image?

.card {
    background: #fff;
    border-radius: 2px;
    display: inline-block;
    height: 188px;
    width: 255px;
    margin: 1rem;
    position: relative;
}

.card-1 {
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}

.card-1:hover {
    box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0px 0px;
    grid-template-areas:
            ". . ."
            ". . .";
    max-width: 60%;
    position: relative; 
    top: 50%;
    left: 50%;
    transform: translate(-50%, 0);

}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Dogodki</title>
</head>
<body>

        <div id="test1">
            <img src="https://htmlcolorcodes.com/assets/images/html-color-codes-color-palette-generators.jpg">
        </div>
        <div class="grid-container">
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
        </div>


</body>
</html>
-----------------------
.card {
    background: #fff;
    border-radius: 2px;
    display: inline-block;
    height: 188px;
    width: 255px;
    margin: 1rem;
    position: relative;
}

.card-1 {
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}

.card-1:hover {
    box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0px 0px;
    grid-template-areas:
            ". . ."
            ". . .";
    max-width: 60%;
    position: relative; 
    top: 50%;
    left: 50%;
    transform: translate(-50%, 0);

}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Dogodki</title>
</head>
<body>

        <div id="test1">
            <img src="https://htmlcolorcodes.com/assets/images/html-color-codes-color-palette-generators.jpg">
        </div>
        <div class="grid-container">
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
        </div>


</body>
</html>

Merging two SVG Paths: Open Bezier and Line

d="M 7700,4900 C 7816,4847 7964,4842 8000,4700 M 8800,6100 L 8827,6100"/>
Box 1: minX="7699" minY="4699" maxX="7699 + 303 = 8002" maxY="4699 + 203 = 4902"
Box 2: minX="8799" minY="6099" maxX="8799 + 30 = 8829" maxY="6099 + 3 = 6102"

Union: minX="7699" minY="4699" maxX="8829" maxY="6102"
Box:   x="7699" y="4699" width="1130" height="1403"
<g id="merged">
  <rect class="BoundingBox" stroke="none" fill="none" x="7699" y="4699" width="1130" height="1403"/>
  <path fill="none" stroke="rgb(52,101,164)" d="M 7700,4900 C 7816,4847 7964,4842 8000,4700 M 8800,6100 L 8827,6100"/>
</g>
-----------------------
d="M 7700,4900 C 7816,4847 7964,4842 8000,4700 M 8800,6100 L 8827,6100"/>
Box 1: minX="7699" minY="4699" maxX="7699 + 303 = 8002" maxY="4699 + 203 = 4902"
Box 2: minX="8799" minY="6099" maxX="8799 + 30 = 8829" maxY="6099 + 3 = 6102"

Union: minX="7699" minY="4699" maxX="8829" maxY="6102"
Box:   x="7699" y="4699" width="1130" height="1403"
<g id="merged">
  <rect class="BoundingBox" stroke="none" fill="none" x="7699" y="4699" width="1130" height="1403"/>
  <path fill="none" stroke="rgb(52,101,164)" d="M 7700,4900 C 7816,4847 7964,4842 8000,4700 M 8800,6100 L 8827,6100"/>
</g>
-----------------------
d="M 7700,4900 C 7816,4847 7964,4842 8000,4700 M 8800,6100 L 8827,6100"/>
Box 1: minX="7699" minY="4699" maxX="7699 + 303 = 8002" maxY="4699 + 203 = 4902"
Box 2: minX="8799" minY="6099" maxX="8799 + 30 = 8829" maxY="6099 + 3 = 6102"

Union: minX="7699" minY="4699" maxX="8829" maxY="6102"
Box:   x="7699" y="4699" width="1130" height="1403"
<g id="merged">
  <rect class="BoundingBox" stroke="none" fill="none" x="7699" y="4699" width="1130" height="1403"/>
  <path fill="none" stroke="rgb(52,101,164)" d="M 7700,4900 C 7816,4847 7964,4842 8000,4700 M 8800,6100 L 8827,6100"/>
</g>

How to make Canvas vertex instructions relative to a widget in Kivy

<HangManFig1>:
    canvas:
        Line:
            points: (root.width*0.1, root.height * 0.1, root.width * 0.1, root.height * 0.8)
            width: 10
-----------------------
class ourLine(Line):
    widget=None
    vLines=[]
    firstime=True

    def __init__(self,relto=Window,**kwargs):
        self.kwargs=kwargs
        if not self.widget:
            print('you should inherit a new class with \'widget\' attr')
        super(ourLine,self).__init__(**kwargs)
        W, H = Window.width, Window.height
        self.rBezier=kwargs['bezier']
        self.vBezier=[]
        c=0
        for p in self.rBezier:
            c+=1
            if not c%2:
                self.vBezier.append(p/H)
            else:
                self.vBezier.append(p/W)
        self.__class__.vLines.append(self)
        del self.kwargs['bezier']

    def deAbstractor(self):
        W, H = self.__class__.widget.width, self.__class__.widget.height
        _vBezier=[]
        c=0
        with self.__class__.widget.canvas:
            for p in self.vBezier:
                c+=1
                if not c%2:
                    _vBezier.append(p*H)
                else:
                    _vBezier.append(p*W)
            Line(bezier=_vBezier, **self.kwargs)

    def dyna(c,w,s):
        print(w)
        for l in c.vLines:
            l.__class__.widget.canvas.clear()
        for l in c.vLines:
            l.deAbstractor()
    def activate(c):
        c.widget.bind(size=lambda w,s: myLine.dyna(myLine,w,s))
import kivy
from kivy.app import App
from kivy.graphics import *
from kivy.core.window import Window
from kivy.uix.floatlayout import FloatLayout
from guy.who.helped import ourLine
root=FloatLayout()

#tell us your widget so we can refer
class myLine(ourLine):
    widget=root

#you may want to start listening later, so it is manual.
ourLine.activate(myLine)

#you can start using like a normal Line
with root.canvas:
    Color(1,1,0,1)
    myLine(bezier=[2,70,90,80,Window.width,Window.height])
    myLine(bezier=[200,170,309,80,Window.width/2,Window.height*0.8], width=12)

class MyApp(App):
    def build(self):
        return root

if __name__ == '__main__':
    MyApp().run()
-----------------------
class ourLine(Line):
    widget=None
    vLines=[]
    firstime=True

    def __init__(self,relto=Window,**kwargs):
        self.kwargs=kwargs
        if not self.widget:
            print('you should inherit a new class with \'widget\' attr')
        super(ourLine,self).__init__(**kwargs)
        W, H = Window.width, Window.height
        self.rBezier=kwargs['bezier']
        self.vBezier=[]
        c=0
        for p in self.rBezier:
            c+=1
            if not c%2:
                self.vBezier.append(p/H)
            else:
                self.vBezier.append(p/W)
        self.__class__.vLines.append(self)
        del self.kwargs['bezier']

    def deAbstractor(self):
        W, H = self.__class__.widget.width, self.__class__.widget.height
        _vBezier=[]
        c=0
        with self.__class__.widget.canvas:
            for p in self.vBezier:
                c+=1
                if not c%2:
                    _vBezier.append(p*H)
                else:
                    _vBezier.append(p*W)
            Line(bezier=_vBezier, **self.kwargs)

    def dyna(c,w,s):
        print(w)
        for l in c.vLines:
            l.__class__.widget.canvas.clear()
        for l in c.vLines:
            l.deAbstractor()
    def activate(c):
        c.widget.bind(size=lambda w,s: myLine.dyna(myLine,w,s))
import kivy
from kivy.app import App
from kivy.graphics import *
from kivy.core.window import Window
from kivy.uix.floatlayout import FloatLayout
from guy.who.helped import ourLine
root=FloatLayout()

#tell us your widget so we can refer
class myLine(ourLine):
    widget=root

#you may want to start listening later, so it is manual.
ourLine.activate(myLine)

#you can start using like a normal Line
with root.canvas:
    Color(1,1,0,1)
    myLine(bezier=[2,70,90,80,Window.width,Window.height])
    myLine(bezier=[200,170,309,80,Window.width/2,Window.height*0.8], width=12)

class MyApp(App):
    def build(self):
        return root

if __name__ == '__main__':
    MyApp().run()
-----------------------
<HangManFig1>:
    h: 600
    w: 800 # just guessing the size you used to design it, adjust as needed
    canvas:
        PushMatrix:
        Scale:
           xy: self.width / self.w, self.height / self.h

        Line:
            points: (150, 100, 150, 700)
            width: 10

        Ellipse:
            pos: (550, 500)
        ... # etc, all the other instructions remain unchanged

        PopMatrix: # restore the initial canvas so it doesn't affect other instructions after your drawing
def rscale(size, *args):
    w, h = size
    ws = w / 800  # adjust accordingly, as in the first example
    hs = h / 600
    return (x / (ws if i % 2 else hs) for i, x in enumerate(args))
        Line:
           points: rscale(self.size, 150, 100, 150, 700)

def rscale(size, *args):
    w, h = size
    scale = min(w / 800, h / 600) # pick the smallest scale of the two
    return (x / s for x in args)
-----------------------
<HangManFig1>:
    h: 600
    w: 800 # just guessing the size you used to design it, adjust as needed
    canvas:
        PushMatrix:
        Scale:
           xy: self.width / self.w, self.height / self.h

        Line:
            points: (150, 100, 150, 700)
            width: 10

        Ellipse:
            pos: (550, 500)
        ... # etc, all the other instructions remain unchanged

        PopMatrix: # restore the initial canvas so it doesn't affect other instructions after your drawing
def rscale(size, *args):
    w, h = size
    ws = w / 800  # adjust accordingly, as in the first example
    hs = h / 600
    return (x / (ws if i % 2 else hs) for i, x in enumerate(args))
        Line:
           points: rscale(self.size, 150, 100, 150, 700)

def rscale(size, *args):
    w, h = size
    scale = min(w / 800, h / 600) # pick the smallest scale of the two
    return (x / s for x in args)
-----------------------
<HangManFig1>:
    h: 600
    w: 800 # just guessing the size you used to design it, adjust as needed
    canvas:
        PushMatrix:
        Scale:
           xy: self.width / self.w, self.height / self.h

        Line:
            points: (150, 100, 150, 700)
            width: 10

        Ellipse:
            pos: (550, 500)
        ... # etc, all the other instructions remain unchanged

        PopMatrix: # restore the initial canvas so it doesn't affect other instructions after your drawing
def rscale(size, *args):
    w, h = size
    ws = w / 800  # adjust accordingly, as in the first example
    hs = h / 600
    return (x / (ws if i % 2 else hs) for i, x in enumerate(args))
        Line:
           points: rscale(self.size, 150, 100, 150, 700)

def rscale(size, *args):
    w, h = size
    scale = min(w / 800, h / 600) # pick the smallest scale of the two
    return (x / s for x in args)
-----------------------
<HangManFig1>:
    h: 600
    w: 800 # just guessing the size you used to design it, adjust as needed
    canvas:
        PushMatrix:
        Scale:
           xy: self.width / self.w, self.height / self.h

        Line:
            points: (150, 100, 150, 700)
            width: 10

        Ellipse:
            pos: (550, 500)
        ... # etc, all the other instructions remain unchanged

        PopMatrix: # restore the initial canvas so it doesn't affect other instructions after your drawing
def rscale(size, *args):
    w, h = size
    ws = w / 800  # adjust accordingly, as in the first example
    hs = h / 600
    return (x / (ws if i % 2 else hs) for i, x in enumerate(args))
        Line:
           points: rscale(self.size, 150, 100, 150, 700)

def rscale(size, *args):
    w, h = size
    scale = min(w / 800, h / 600) # pick the smallest scale of the two
    return (x / s for x in args)

COMMUNITY DISCUSSIONS

Top Trending Discussions on Bezier
  • Vue add class before insert, leave it
  • Find point on cubic bezier given x-pos
  • Do not close the mode in the mouse up event
  • React inlined SVG paths are not responding to css animations
  • Is there a convenient way to draw arc only using two points and curve radius in Android?
  • animate Kivy Bezier curve with custom width ? (a bit silly question)
  • How to draw another layer of hexagon UIBezier Path and animate accordingly
  • How to put an element (a grid) under an image?
  • Merging two SVG Paths: Open Bezier and Line
  • How to fix odd color banding caused by CSS animation?
Top Trending Discussions on Bezier

QUESTION

Vue add class before insert, leave it

Asked 2021-Jun-15 at 15:23

I have a custom animation that the regular Vue transition doesn't quite cover. I have it implemented elsewhere with a conditional v-bind:class, but that doesn't work well for conditional v-if blocks or v-for groups.

I need to add a class ('open') one frame after the element is entered as with v-enter-to, but I need it to never be removed from the element.

I then need it removed removed when leaving to trigger the closing animation.

Am I using Vue Transition wrong and this is perfectly possible within transition, or is there a way to add/remove the class around the enter/leave functionality?

.accordion {
    overflow: hidden;

    > div {
        margin-bottom: -1000px;
        transition: margin-bottom .3s cubic-bezier(.5,0,.9,.8),visibility 0s .3s,max-height 0s .3s;
        max-height: 0;
        overflow: hidden;
    }

    &::after {
        content: "";
        height: 0;
        transition: height .3s cubic-bezier(.67,.9,.76,.37);
        max-height: 35px;
    }

    &.open {
        max-height: 8000px;

        > div {
            transition: margin-bottom .3s cubic-bezier(.24,.98,.26,.99);
            margin-bottom: 0;
            max-height: 100000000px;
            position: relative;
        }

        &::after {
            height: 35px;
            max-height: 0;
            transition: height .3s cubic-bezier(.76,.37,.67,.9),max-height 0s .3s;
        }
    }
}
<transition name="accordion" :duration="300">
  <div class="accordion" v-if="equipmentSelections.length === 0">
    <div>
      <p>Begin by selecting equipment from the list</p>
    </div>
  </div>
 </transition>
 
<transition-group name="accordion" :duration="300">
  <div v-for="equipment in equipmentSelections" v-bind:key="equipment.unitNumber" class="accordion">
    <div>
      <h3 v-on:click="updateSelections(equipment)">{{equipment.unitNumber}}</h3>
    </div>
  </div>
</transition-group>

ANSWER

Answered 2021-Jun-09 at 14:25

I could only think of a work-around. You could try to add the class in the created() or mounted() hook. Before you push another path to the router, you could remove it and add a fake timeout for the $router.push(path).

This is not clean but i am not sure if i fully understand what are you trying to do.

Source https://stackoverflow.com/questions/67793912

QUESTION

Find point on cubic bezier given x-pos

Asked 2021-Jun-15 at 09:12

I have a CSS-type cubic bezier where
A = 0,0
B = a, b where 0<a<1
C = p, q where 0<p<1
D = 1, 1

I want a function pointOnBezier(a,b,p,q,x) => {x:x, y:y}
I've found this which helps but no mathematical formula😓
https://upload.wikimedia.org/wikipedia/commons/d/db/B%C3%A9zier_3_big.gif
Any help would be appreciated. Thanks in advance!!!

ANSWER

Answered 2021-Jun-15 at 09:12

You can find the Cubic Bézier curve formula in Wikipedia. Cubic Bézier curve formula

Once you have the formula, you need to find t by x and then find y by t. To find t, you need to solve a cubic equation. You can find the code for solving cubic equation from other places such as this post.

Here is the code for your reference:

function getCubicBezierY(a, b, p, q, x) {
    // By the Cubic Bézier curve formula, we know that
    // 3(1-t)²ta + 3(1-t)t²p + t³ - x = 0
    // After formatting it to the cubic equation form, we have
    // (3a-3p+1)t³ + (3p-6a)t² + 3at - x = 0
    // Solve the equation
    const t = solveCubic(3*a-3*p+1, 3*p-6*a, 3*a, -x)[0]; // There should be only 1 root
    const r = 1 - t;
    // Find y by using the Cubic Bezier curve formula
    return 3*r*r*t*b + 3*r*t*t*q + t*t*t;
}

// Functions for solving cubic equation
function cuberoot(x) {
    var y = Math.pow(Math.abs(x), 1/3);
    return x < 0 ? -y : y;
}

function solveCubic(a, b, c, d) {
    if (Math.abs(a) < Number.EPSILON) { // Quadratic case, ax^2+bx+c=0
        a = b; b = c; c = d;
        if (Math.abs(a) < Number.EPSILON) { // Linear case, ax+b=0
            a = b; b = c;
            if (Math.abs(a) < Number.EPSILON) // Degenerate case
                return [];
            return [-b/a];
        }

        var D = b*b - 4*a*c;
        if (Math.abs(D) < Number.EPSILON)
            return [-b/(2*a)];
        else if (D > 0)
            return [(-b+Math.sqrt(D))/(2*a), (-b-Math.sqrt(D))/(2*a)];
        return [];
    }

    // Convert to depressed cubic t^3+pt+q = 0 (subst x = t - b/3a)
    var p = (3*a*c - b*b)/(3*a*a);
    var q = (2*b*b*b - 9*a*b*c + 27*a*a*d)/(27*a*a*a);
    var roots;

    if (Math.abs(p) < Number.EPSILON) { // p = 0 -> t^3 = -q -> t = -q^1/3
        roots = [cuberoot(-q)];
    } else if (Math.abs(q) < Number.EPSILON) { // q = 0 -> t^3 + pt = 0 -> t(t^2+p)=0
        roots = [0].concat(p < 0 ? [Math.sqrt(-p), -Math.sqrt(-p)] : []);
    } else {
        var D = q*q/4 + p*p*p/27;
        if (Math.abs(D) < Number.EPSILON) {       // D = 0 -> two roots
            roots = [-1.5*q/p, 3*q/p];
        } else if (D > 0) {             // Only one real root
            var u = cuberoot(-q/2 - Math.sqrt(D));
            roots = [u - p/(3*u)];
        } else {                        // D < 0, three roots, but needs to use complex numbers/trigonometric solution
            var u = 2*Math.sqrt(-p/3);
            var t = Math.acos(3*q/p/u)/3;  // D < 0 implies p < 0 and acos argument in [-1..1]
            var k = 2*Math.PI/3;
            roots = [u*Math.cos(t), u*Math.cos(t-k), u*Math.cos(t-2*k)];
        }
    }

    // Convert back from depressed cubic
    for (var i = 0; i < roots.length; i++)
        roots[i] -= b/(3*a);

    return roots;
}

Source https://stackoverflow.com/questions/67980505

QUESTION

Do not close the mode in the mouse up event

Asked 2021-Jun-06 at 16:26

I use the micro modal js package in my project but I have a problem. this modal closed when occurring mouse down or mouse up event Outside the medal range. but I want mouse-up event Do not do anything and just mouse-down event can close the medal. this is my HTML code.

let openButton = document.getElementById('open-modal');

openButton.addEventListener('click', function() {
    MicroModal.show('modal-1');
});
/**************************\
  Basic Modal Styles
\**************************/

.modal {
    font-family: -apple-system,BlinkMacSystemFont,avenir next,avenir,helvetica neue,helvetica,ubuntu,roboto,noto,segoe ui,arial,sans-serif;
}

.modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal__container {
    background-color: #fff;
    padding: 30px;
    max-width: 500px;
    max-height: 100vh;
    border-radius: 4px;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal__title {
    margin-top: 0;
    margin-bottom: 0;
    font-weight: 600;
    font-size: 1.25rem;
    line-height: 1.25;
    color: #00449e;
    box-sizing: border-box;
}

.modal__close {
    background: transparent;
    border: 0;
}

.modal__header .modal__close:before { content: "\2715"; }

.modal__content {
    margin-top: 2rem;
    margin-bottom: 2rem;
    line-height: 1.5;
    color: rgba(0,0,0,.8);
}

.modal__btn {
    font-size: .875rem;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: .5rem;
    padding-bottom: .5rem;
    background-color: #e6e6e6;
    color: rgba(0,0,0,.8);
    border-radius: .25rem;
    border-style: none;
    border-width: 0;
    cursor: pointer;
    -webkit-appearance: button;
    text-transform: none;
    overflow: visible;
    line-height: 1.15;
    margin: 0;
    will-change: transform;
    -moz-osx-font-smoothing: grayscale;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    transition: -webkit-transform .25s ease-out;
    transition: transform .25s ease-out;
    transition: transform .25s ease-out,-webkit-transform .25s ease-out;
}

.modal__btn:focus, .modal__btn:hover {
    -webkit-transform: scale(1.05);
    transform: scale(1.05);
}

.modal__btn-primary {
    background-color: #00449e;
    color: #fff;
}



/**************************\
  Demo Animation Style
\**************************/
@keyframes mmfadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes mmfadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes mmslideIn {
    from { transform: translateY(15%); }
    to { transform: translateY(0); }
}

@keyframes mmslideOut {
    from { transform: translateY(0); }
    to { transform: translateY(-10%); }
}

.micromodal-slide {
    display: none;
}

.micromodal-slide.is-open {
    display: block;
}

.micromodal-slide[aria-hidden="false"] .modal__overlay {
    animation: mmfadeIn .3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.micromodal-slide[aria-hidden="false"] .modal__container {
    animation: mmslideIn .3s cubic-bezier(0, 0, .2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__overlay {
    animation: mmfadeOut .3s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.micromodal-slide[aria-hidden="true"] .modal__container {
    animation: mmslideOut .3s cubic-bezier(0, 0, .2, 1);
}

.micromodal-slide .modal__container,
.micromodal-slide .modal__overlay {
    will-change: transform;
}
<html>
<head>
    <Title>MicroModal Toggle Pen</Title>
    <script defer  src="https://unpkg.com/micromodal/dist/micromodal.min.js"></script>
    <script  defer  src="script.js"></script>
    <link rel="stylesheet" href="style.css">
</head>
<body>

<button type="button" id="open-modal">Open new modal</button>

<!-- New event modal -->
<div class="modal micromodal-slide" id="modal-1" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    New event
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                <input type="text" placeholder="name">
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>

<!-- Event 1 -->
<div class="modal micromodal-slide" id="event-modal-1" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    Event 1
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                Blah
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>

<!-- Event Modal 2 -->
<div class="modal micromodal-slide" id="event-modal-2" aria-hidden="true">
    <div class="modal__overlay" tabindex="-1" data-micromodal-close>
        <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
            <header class="modal__header">
                <h2 class="modal__title" id="modal-1-title">
                    Event 2
                </h2>
                <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
            </header>
            <main class="modal__content" id="modal-1-content">
                blah
            </main>
            <footer class="modal__footer">
                <button class="modal__btn modal__btn-primary">Continue</button>
                <button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
            </footer>
        </div>
    </div>
</div>
</body>
</html>

I would be very grateful if anyone could help me.

ANSWER

Answered 2021-Jun-06 at 06:23

The solution is to remove data-micromodal-close from your modal__overlay. Doing that will prevent the modal from closing when you click on the backdrop.

<div class="modal__overlay" tabindex="-1">

Only put data-micromodal-close on elements that should dismiss the modal when clicked, like the close button.

https://github.com/ghosh/micromodal/issues/132#issuecomment-478688942

Source https://stackoverflow.com/questions/67856022

QUESTION

React inlined SVG paths are not responding to css animations

Asked 2021-Jun-06 at 13:31

I uploaded my code and svgs to this github repo.

I have some svgs of some circles, blobs and triangles. I am trying to make the circles shake, like how the guy shakes in this code pen when you hover on him, I am trying to make the blobs move like waves like in this code pen, and I'm trying to make the triangles spin around. The blobs and triangles are not responding at all, even though I can see that they have the styling applied when I inspect the html. The circles have some effect, but not the one I want.

enter image description here enter image description here


Here is the code for each

circles.scss

    .circles > circle {
        animation: shake 2.2s cubic-bezier(.36,.07,.19,.97) both;
    }
    
    @keyframes shake {
      10%, 90% {
        transform: translate3d(-1px, 0, 0);
      }
      
      20%, 80% {
        transform: translate3d(2px, 0, 0);
      }
    
      30%, 50%, 70% {
        transform: translate3d(-4px, 0, 0);
      }
    
      40%, 60% {
        transform: translate3d(4px, 0, 0);
      }
    }

triangles.scss

    .triangles > g > path {
        animation: triangle-animation 2.2s cubic-bezier(.36,.07,.19,.97) both;
    }
    
    @keyframes triangle-animation {
      10%, 90% {
        tranform: rotate(5deg);
      }
      
      20%, 80% {
        tranform: rotate(90deg);
      }
    
      30%, 50%, 70% {
        tranform: rotate(180deg);
      }
    
      40%, 60% {
        tranform: rotate(30deg);
      }
      100% { 
          tranform: rotate(0deg);
      }
    }

waves.scss

    .waves > path {
      animation: wave-animation 4s infinite alternate;
    //   animation-duration: 4s;
    //   animation-iteration-count: infinite;
    //   animation-direction: alternate;
    }
    
    @keyframes wave-animation {
      0%   {
        margin-left:0px;
        margin-top:0px;
        }  
      50%  {
        margin-left:-2000px;
        margin-top:200px;
        }  
      100% {
        margin-left:0px; 
        margin-top:0px;
        }
    }

And this is my main App.js file

    import React from 'react';
    
    import Blobs from 'svg/Blobs.svg'
    import Circles from 'svg/Circles.svg';
    import Triangles from 'svg/Triangles.svg';
    
    export default () => (
        <div>
            <Circles className="circles" />
            <Blobs className=" w-100 h-100 waves" />
            <Triangles className='w-100 triangles' />                
        </div>
    );

The styles are imported in index.js

Thank you

ANSWER

Answered 2021-Jun-06 at 13:31

Create components with the svg code inside then add your css classes ... I advise you to start from scratch and create your own svg, it's easier than using already created svg.

(check the demo at the bottom of the page with the triangles, circles and waves)

App.js

import React from 'react';
import './style.css';

import Triangles from './svg/Triangles';

export default function App() {
  return (
    <div>
      <Triangles />
    </div>
  );
}

Triangles.js

import React from 'react';

export default function Triangles() {
  return (
    <div className="triangles">
      <svg className="triangle one">
        <path d="M150 0 L30 200 L270 200 Z" />
      </svg>
      <svg className="triangle two">
        <path d="M120 0 L30 180 L200 200 Z" />
      </svg>
      <svg className="triangle three">
        <path d="M10 0 L40 280 L190 170 Z" />
      </svg>
    </div>
  );
}

style.css

/* Triangles */
.triangles {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50vh;
}
.triangle {
  position: absolute;
  fill: rgb(23, 233, 224);
  fill-opacity: 0.4;
  animation-name: spin;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
.triangle.one {
  height: 210px;
  width: 300px;
  animation-duration: 5000ms;
}
.triangle.two {
  height: 150px;
  width: 400px;
  animation-duration: 9000ms;
}
.triangle.three {
  height: 120px;
  width: 300px;
  animation-duration: 3000ms;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

Demo : Stackblitz

Source https://stackoverflow.com/questions/67857258

QUESTION

Is there a convenient way to draw arc only using two points and curve radius in Android?

Asked 2021-Jun-03 at 01:23

First of all

I searched for it for a long time, and I have already seen many questions including the two:

How to draw Arc between two points on the Canvas?

How to draw a curved line between 2 points on canvas?

Although they seem like the same question, I'm very sure they are not the same. In the first question, the center of the circle is known, and in the second, it draws a Bezier curve not an arc.

Description

Now we have two points A and B and the curve radius given, how to draw the arc as the image shows?

image

Since Path.arcTo's required arguments are RectF, startAngle and sweepAngle, there seems hardly a easy way.

My current solution

I now have my solution, I'll show that in the answer below.

Since the solution is so complex, I wonder if there is a easier way to solve it?

ANSWER

Answered 2021-Jun-01 at 03:14

1. find the center of the circle

This can be solved by a binary quadratic equation, as the image shows:

center

Though there are other solutions, anyway, now the position of circle center is known.

2. calculate start angle and sweep angle

According to the circle center, RectF is easy to know. Now calculate startAngle and sweepAngle.

calculate angle

Via geometric methods, we can calculate the startAngle and sweepAngle:

    val startAngle = acos((x1 - x0) / r) / Math.PI.toFloat() * 180
    val endAngle = acos((x2 - x0) / r) / Math.PI.toFloat() * 180
    val sweepAngle = endAngle - startAngle

In this case, x1 is the x-coordinary of point A, x2 if the x-coordinary of point B, and r is the curve radius of the arc. (There are possible results, the other is [-startAngle, startAngle - endAngle]. Choose one according to actual situation.)

Thus, we get all the required arguments for Path.arcTo method and we can draw the arc now.

3. kotlin code

the entire code of the help function:

    /**
     * Append the arc which is starting at ([x1], [y1]), ending at ([x2], [y2])
     * and with the curve radius [r] to the path.
     * The Boolean value [clockwise] shows whether the process drawing the arc
     * is clockwise.
     */
    @Throws(Exception::class)
    private fun Path.arcFromTo(
        x1: Float, y1: Float, x2: Float, y2: Float, r: Float,
        clockwise: Boolean = true
    ) {
        val c = centerPos(x1, y1, x2, y2, r, clockwise) // circle centers
        // RectF borders
        val left = c.x - r
        val top = c.y - r
        val right = c.x + r
        val bottom = c.y + r
        val startAngle = acos((x1 - c.x) / r) / Math.PI.toFloat() * 180
        val endAngle = acos((x2 - c.x) / r) / Math.PI.toFloat() * 180
        arcTo(
            left, top, right, bottom,
            if (clockwise) startAngle else -startAngle,
            if (clockwise) endAngle - startAngle else startAngle - endAngle,
            false
        )
    }

    // use similar triangles to calculate circle center
    @Throws(Exception::class)
    private fun centerPos(
        x1: Float, y1: Float, x2: Float, y2: Float, r: Float,
        clockwise: Boolean
    ): Point {
        val ab = ((x1 - x2).p2 + (y1 - y2).p2).sqrt
        if (ab > r * 2) throw Exception("No circle fits the condition.")
        val a = ab / 2
        val oc = (r.p2 - a.p2).sqrt
        val dx = (oc * (y2 - y1) / ab).absoluteValue.toInt()
        val dy = (oc * (x2 - x1) / ab).absoluteValue.toInt()
        val cx = ((x1 + x2) / 2).toInt()
        val cy = ((y1 + y2) / 2).toInt()
        return if (x1 >= x2 && y1 >= y2 || x1 <= x2 && y1 <= y2)
            if (clockwise) Point(cx + dx, cy - dy) else Point(cx - dx, cy + dy)
        else
            if (clockwise) Point(cx - dx, cy - dy) else Point(cx + dx, cy + dy)
    }

Source https://stackoverflow.com/questions/67782043

QUESTION

animate Kivy Bezier curve with custom width ? (a bit silly question)

Asked 2021-Jun-02 at 01:05

update: After discussing with others, I decided that it is a bit silly question. I wanted to animate Bezier curve with changed width, but it has no width property. with Line Bezier, I can change width, but then can't animate.


I can't change witdh of Bezier curve like Line.
here is the code:

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import *

class MyLayout(Widget):
    def __init__(self):
        super(MyLayout, self).__init__()
        with self.canvas:
            self.L=Bezier(points=[200,450,500,300,600,150],width=12)
            self.k=Line  (bezier=[100,350,400,200,500,50 ],width=12)

class MyApp(App):
    def __init__(self):
        super(MyApp, self).__init__()
    def build(self):
        return MyLayout()

if __name__=="__main__":
    MyApp().run()

and outupt: MyApp

the problem is,

the upper curve isn't width=12.

I think that's because Kivy's Bezier Class has no attribute width cuz when I do it on kv lang, it gives me AttributeError: 'kivy.graphics.vertex_instructions.Bezier' object has no attribute 'width'. Well, why not using Line with bezier ? I want to use Animation on it and when I try to on Line with bezier, I get AttributeError: attribute 'bezier' of 'kivy.graphics.vertex_instructions.Line' objects is not readable.

so the question,

how can I change width of Bezier. if it is not possible, is there any way like finding the y of cruve (or ys) for given x so I can put Ellipse on these points and resize them to simulate width ?

thanks and pardon my english

ANSWER

Answered 2021-Mar-21 at 13:47

The Bezier has no width property, but the Line does. So you can animate that width. An easy way to do that is by animating a NumericProperty that holds the width. Here is a modified version of your code that does that:

from kivy.animation import Animation
from kivy.app import App
from kivy.clock import Clock
from kivy.properties import NumericProperty
from kivy.uix.widget import Widget
from kivy.graphics import *

class MyLayout(Widget):
    line_width = NumericProperty(12)
    def __init__(self):
        super(MyLayout, self).__init__()
        with self.canvas:
            self.L=Bezier(points=[200,450,500,300,600,150],width=self.line_width)
            self.k=Line  (bezier=[100,350,400,200,500,50 ],width=self.line_width)

    def on_line_width(self, instance, new_width):
        self.k.width = new_width

class MyApp(App):

    def build(self):
        Clock.schedule_once(self.anim)
        return MyLayout()

    def anim(self, dt):
        a = Animation(line_width=3)
        a.start(self.root)

if __name__=="__main__":
    MyApp().run()

If you build the Line in kv, then you don't even need the on_line_width() method since kivy will do the binding for you.

Source https://stackoverflow.com/questions/66729316

QUESTION

How to draw another layer of hexagon UIBezier Path and animate accordingly

Asked 2021-Jun-01 at 11:02

I'm looking for a way to add another layer of hexagon bezier path like the ones below.

enter image description here

I have been able to create Hexagon using bezier path and animate accordingly but I am trying to add another grey colour layer of bezier path. I tried adding multiple bezier paths but it doesn't work.

This is the output I achieved.

enter image description here

Here is my LoaderView class

class LoaderView: UIView {

private let lineWidth : CGFloat = 5
internal var backgroundMask = CAShapeLayer()


override init(frame: CGRect) {
    super.init(frame: frame)
    setUpLayers()
    createAnimation()
}


required init?(coder: NSCoder) {
    super.init(coder: coder)
    setUpLayers()
    createAnimation()
}

func setUpLayers()
{
    backgroundMask.lineWidth = lineWidth
    backgroundMask.fillColor = nil
    backgroundMask.strokeColor = UIColor.blue.cgColor
    layer.mask = backgroundMask
    layer.addSublayer(backgroundMask)
}

func createAnimation()
{
    let animation = CABasicAnimation(keyPath: "strokeEnd")
    animation.fromValue = 0
    animation.duration = 1
    animation.repeatCount = .infinity
    backgroundMask.add(animation, forKey: "MyAnimation")
}

override func draw(_ rect: CGRect) {
    let sides = 6
    let rect = self.bounds
    let path = UIBezierPath()
    
    let cornerRadius : CGFloat = 10
    let rotationOffset = CGFloat(.pi / 2.0)
    
    let theta: CGFloat = CGFloat(2.0 * .pi) / CGFloat(sides) // How much to turn at every corner
    let width = min(rect.size.width, rect.size.height)        // Width of the square
    
    let center = CGPoint(x: rect.origin.x + width / 2.0, y: rect.origin.y + width / 2.0)
    
    // Radius of the circle that encircles the polygon
    // Notice that the radius is adjusted for the corners, that way the largest outer
    // dimension of the resulting shape is always exactly the width - linewidth
    let radius = (width - lineWidth + cornerRadius - (cos(theta) * cornerRadius)) / 2.0
    
    
    // Start drawing at a point, which by default is at the right hand edge
    // but can be offset
    var angle = CGFloat(rotationOffset)
    
    let corner = CGPoint(x: center.x + (radius - cornerRadius) * cos(angle), y: center.y + (radius - cornerRadius) * sin(angle))
    path.move(to: CGPoint(x: corner.x + cornerRadius * cos(angle + theta), y: corner.y + cornerRadius * sin(angle + theta)))
    
    for _ in 0..<sides {
        angle += theta
        
        let corner = CGPoint(x: center.x + (radius - cornerRadius) * cos(angle), y: center.y + (radius - cornerRadius) * sin(angle))
        let tip = CGPoint(x: center.x + radius * cos(angle), y: center.y + radius * sin(angle))
        let start = CGPoint(x: corner.x + cornerRadius * cos(angle - theta), y: corner.y + cornerRadius * sin(angle - theta))
        let end = CGPoint(x: corner.x + cornerRadius * cos(angle + theta), y: corner.y + cornerRadius * sin(angle + theta))
        
        path.addLine(to: start)
        path.addQuadCurve(to: end, controlPoint: tip)
        
    }
    path.close()
    backgroundMask.path = path.cgPath
}}

ANSWER

Answered 2021-Jun-01 at 11:02

To add the gray hexagon under the blue animating path, you can add another CAShapeLayer:

var grayLayer = CAShapeLayer()

Set it up in a similar way to backgroundMask:

grayLayer.lineWidth = lineWidth
grayLayer.fillColor = nil
grayLayer.strokeColor = UIColor.gray.cgColor

Set its path to be the same path as backgroundMask:

backgroundMask.path = path.cgPath
grayLayer.path = path.cgPath

Finally, add the gray layer before you add backgroundMask. This makes it go at the bottom:

layer.addSublayer(grayLayer)
layer.addSublayer(backgroundMask)

Also note that your path drawing code doesn't need to go in draw. It could just go in init.

Here's what one frame of the animation looks like:

enter image description here

Source https://stackoverflow.com/questions/67787268

QUESTION

How to put an element (a grid) under an image?

Asked 2021-May-30 at 20:20

I have built a grid, and centered it in the middle of the page with top: 50%; left: 50%; transform: translate(-50%, -50%);

The code above centered the grid exactly as i needed it to, in the middle of the page, but it also seems to have put the grid over the image. I need to put the grid under the image, centered in the middle of the screen.

.card {
    background: #fff;
    border-radius: 2px;
    display: inline-block;
    height: 188px;
    width: 255px;
    margin: 1rem;
    position: relative;
}

.card-1 {
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}

.card-1:hover {
    box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0px 0px;
    grid-template-areas:
            ". . ."
            ". . .";
    max-width: 60%;
    position: fixed; 
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Dogodki</title>
</head>
<body>

        <div id="test1">
            <img src="https://htmlcolorcodes.com/assets/images/html-color-codes-color-palette-generators.jpg">
        </div>
        <div class="grid-container">
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
        </div>


</body>
</html>

ANSWER

Answered 2021-May-30 at 20:20

Is that what you are trying to do ?

.card {
    background: #fff;
    border-radius: 2px;
    display: inline-block;
    height: 188px;
    width: 255px;
    margin: 1rem;
    position: relative;
}

.card-1 {
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}

.card-1:hover {
    box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0px 0px;
    grid-template-areas:
            ". . ."
            ". . .";
    max-width: 60%;
    position: relative; 
    top: 50%;
    left: 50%;
    transform: translate(-50%, 0);

}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Dogodki</title>
</head>
<body>

        <div id="test1">
            <img src="https://htmlcolorcodes.com/assets/images/html-color-codes-color-palette-generators.jpg">
        </div>
        <div class="grid-container">
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
            <div class="card card-1"></div>
        </div>


</body>
</html>

Source https://stackoverflow.com/questions/67765421

QUESTION

Merging two SVG Paths: Open Bezier and Line

Asked 2021-May-30 at 06:33

The merge portion of my question has been well answered here: https://stackoverflow.com/a/49051988/4272389 which resolved two LineGradients with one line node and the other a path node.

In my situation I have an Open Bezier path and a Line path and am not sure if that answer for LineGradient still applies

<g class="com.sun.star.drawing.OpenBezierShape">
 <g id="id5">
  <rect class="BoundingBox" stroke="none" fill="none" x="7699" y="4699" width="303" height="203"/>
  <path fill="none" stroke="rgb(52,101,164)" d="M 7700,4900 C 7816,4847 7964,4842 8000,4700"/>
 </g>
</g>
<g class="com.sun.star.drawing.LineShape">
 <g id="id6">
  <rect class="BoundingBox" stroke="none" fill="none" x="8799" y="6099" width="30" height="3"/>
  <path fill="none" stroke="rgb(52,101,164)" d="M 8800,6100 L 8827,6100"/>
 </g>
</g>

Using the viewbox transform procedure suggested in the prior answer (https://svgwg.org/svg2-draft/coords.html#ComputingAViewportsTransform), would the merge entail the expanding the bounding box then using the origin from id5 and then converting id6 coordinates into relative values inside the expanded box I call "merged"?: My arithmetic expression is pseudo code to indicate my transform formula)

<g id="merged">
  <rect class="BoundingBox" stroke="none" fill="none" x="8799" y="6099" width="300+(8799-7699)+30" height="203+(6100-4699)+3"/>
  <path fill="none" stroke="rgb(52,101,164)" d="M 7700,4900 C 7816,4847 7964,4842 8000,4700 m [(8799-7699) + (8800-8799), (6099-4699) + (6100-6099)] l (8827-8799),(6100-6099)"/>
</g>

Reason: The fragments were drawn with LibreOffice draw and the paths were joined using Inkscape, but I could not do so fully, so I have to manually close the paths in the final Inkscape result.

ANSWER

Answered 2021-May-30 at 06:33

Paths can have multiple subpaths. So most of the time, you can just append them together, like so:

d="M 7700,4900 C 7816,4847 7964,4842 8000,4700 M 8800,6100 L 8827,6100"/>

The only thing you need to watch for is if the move command in the second path is a lower-case m. In a single path, starting with an m (relative move) is an error, and it is interpreted as a M (absolute move). But if you append it to another path, a lower-case m would be valid. So you would need to change the m to an M when appending.

As for the bounding box, you just need to do a "union" operation. In other words finding the min and max X and Y coords of the two rectangles.

Box 1: minX="7699" minY="4699" maxX="7699 + 303 = 8002" maxY="4699 + 203 = 4902"
Box 2: minX="8799" minY="6099" maxX="8799 + 30 = 8829" maxY="6099 + 3 = 6102"

Union: minX="7699" minY="4699" maxX="8829" maxY="6102"
Box:   x="7699" y="4699" width="1130" height="1403"

So the merged paths should be:

<g id="merged">
  <rect class="BoundingBox" stroke="none" fill="none" x="7699" y="4699" width="1130" height="1403"/>
  <path fill="none" stroke="rgb(52,101,164)" d="M 7700,4900 C 7816,4847 7964,4842 8000,4700 M 8800,6100 L 8827,6100"/>
</g>

Source https://stackoverflow.com/questions/67751886

QUESTION

How to fix odd color banding caused by CSS animation?

Asked 2021-May-28 at 19:55

Hello everyone.

I have started making a small app in Electron, and want to make a loading screen.

But every time I add the animation to the container div, it gives its background color weird color banding.

Here's an image of it.

Basically the top is a color I do not even use anywhere, while the bottom is the actual color I want.

Here's an image with the animation disabled.

What I tried:

  1. Ran the website in Edge, did produce the color banding.
  2. Ran the website in the snippet, did not produce the color banding.
  3. Tried setting the background color in the animation itself, did not fix the problem.

Here's my code:

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600&family=Roboto&display=swap');
:root {
  --main1: #282b30;
  --main2: #1e2124;
  --main3: #16181a;
  --titleFont: 'Nunito', sans-serif;
  --textFont: 'Roboto', sans-serif;
  --textColor: #ffffff;
}

* {
  font-family: var(--textFont);
  color: white;
}

html {
  height: 100%;
}

body {
  overflow: hidden;
}

.transitionContainer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: var(--main2);
  color: var(--textColor);
  font-size: 500%;
  animation-name: hideTransition;
  animation-duration: 0.6s;
  animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
  animation-delay: 1.25s;
  animation-fill-mode: both;
  opacity: 1;
}

@keyframes hideTransition {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(1.5);
    opacity: 0;
    z-index: -1;
  }
}

@keyframes showTransition {
  from {
    transform: scale(1.5);
    opacity: 0;
    z-index: -1;
  }
  to {
    transform: scale(1);
    opacity: 1;
    z-index: 0;
  }
}

.logoText {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -49.258px;
  margin-top: -96px;
}

.loadingBarBack {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 25px;
  background-color: var(--main3);
}

.loadingBarFront {
  width: 0%;
  height: 100%;
  background-color: limegreen;
  animation: loading 1s;
  animation-fill-mode: forwards;
}

@keyframes loading {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">

  <link rel="stylesheet" href="index.css">

  <script src="./index.js" defer></script>
</head>

<body>
  <div class="transitionContainer">
    <h1 class="logoText">R</h1>
    <div class="loadingBarBack">
      <div class="loadingBarFront"></div>
    </div>
  </div>
</body>

</html>

Thanks for any help in advance!

ANSWER

Answered 2021-May-28 at 19:55

Figured it out!

Apparently animation-fill-mode: both; caused some of the div to go transparent before the animation even played.

Setting it to animation-fill-mode: forwards; fixed it.

Source https://stackoverflow.com/questions/67743862

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

VULNERABILITIES

No vulnerabilities reported

INSTALL Bezier

You can use Bezier like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the Bezier component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

SUPPORT

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

Implement Bezier faster with kandi.

  • Use the support, quality, security, license, reuse scores and reviewed functions to confirm the fit for your project.
  • Use the, Q & A, Installation and Support guides to implement faster.

Discover Millions of Libraries and
Pre-built Use Cases on kandi