Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] 增加一鍵 清空頭部 和 水平鏡像 更多頭部的選擇 #3

Closed
fz6m opened this issue Jun 29, 2020 · 1 comment
Closed

Comments

@fz6m
Copy link

fz6m commented Jun 29, 2020

App.svelte :

<div class="flex-row d-flex justify-content-center my-3">
      <div class="col text-center">
        <button class='btn btn-outline-secondary' on:click={restart}>
          清空頭部
        </button>
      </div>

      <div class="col text-center"> 
        <button class='btn btn-outline-secondary' on:click={reverse}>
          水平鏡像
        </button>
      </div>
</div>
let flip = false

function restart() {
    heads = []
}

function reverse() {
    flip = !flip
    let nodes = document.getElementsByClassName('add-head-button')
    for(let element of nodes) {
      if(flip) {
        element.style.transform = 'rotateY(180deg)'
      } else {
        element.style.transform = ''
      }
    };
}
{#each heads as head (head.id)}
      <Head {canvas} {head} {flip}/>
{/each}

Head.svelte:

export let canvas, head, flip

fabricImage = new fabric.Image(image, {
        rotatingPointOffset: 15,
        cornerStyle: 'circle',
        cornerColor: 'red',
        transparentCorners: false,
        borderColor: 'red',
        scaleX: scale,
        scaleY: scale,
        flipX: flip
      })
ayamomiji added a commit that referenced this issue Jun 29, 2020
@ayamomiji
Copy link
Owner

👍
下次可以嘗試使用 pull request 提交

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants