<div x-data="{
shape: null,
canvas: null,
ctx: null,
size: 100,
init(){
this.shape = {{$getRecord()->id}}
this.canvas = $refs.colorProfilePreview
this.ctx = this.canvas.getContext('2d')
this.drawCanvas()
},
drawCanvas(){
this.ctx.clearRect(0,0,this.canvas.width, this.canvas.height)
{{-- border --}}
this.ctx.globalAlpha = 1
this.ctx.beginPath()
this.ctx.roundRect(3, 3,this.size-6 , this.size-6, [12])
this.ctx.fillStyle = '#fff'
this.ctx.fill()
this.ctx.beginPath()
this.ctx.roundRect(4, 4,this.size-8 , this.size-8, [11])
this.ctx.fillStyle = '#000'
this.ctx.fill()
{{-- base --}}
this.ctx.beginPath()
this.ctx.roundRect(5, 5,this.size-10 , this.size-10, [10])
this.ctx.fillStyle = '{{$getRecord()->baseColor->hex}}'
this.ctx.fill()
this.ctx.beginPath()
this.ctx.roundRect(10, 10,this.size-20 , this.size-20 , [5])
this.ctx.strokeStyle = '#000'
this.ctx.globalAlpha = .3
this.ctx.stroke()
this.ctx.globalAlpha = 1
{{-- sticker --}}
this.ctx.fillStyle = '{{$getRecord()->stickerColor->hex}}'
this.ctx.fill()
this.ctx.fillStyle = '{{$getRecord()->defaultColor->hex}}'
this.ctx.font = '20px sans-serif'
this.ctx.textBaseline = 'top'
this.ctx.textAlign = 'center'
this.ctx.fillText('text', 50, 20, 80)
{{-- arrow --}}
this.ctx.fillStyle = '{{$getRecord()->imageColor->hex}}'
this.ctx.beginPath()
this.ctx.moveTo(25, 65)
this.ctx.lineTo(40, 80)
this.ctx.lineTo(40, 50)
this.ctx.fill()
this.ctx.fillRect(40, 60 ,30 , 10)
}
}" x-init="drawCanvas">
<canvas x-ref="colorProfilePreview" width="100" height="100"></canvas>
</div>