{deck}
version:1
card:0
size:[512,342]
name:"patedit.deck"

{card:home}
image:"%%[encoded data, 8072 characters]"
script:"home.0"
{widgets}
pat:{"type":"contraption","size":[148,82],"pos":[360,20],"script":"home.1","def":"patternPicker","widgets":{"c":{"size":[148,82],"image":"%%IMG2AJQAUgD/ANEBFgB+AQEAFAEBAG8BEAABARIAAQFlAAsBAQIOAQEAAQEBAxABAQABAQEEDgEBBRABAQYQAQEHEAEBCBABAQkQAQEACwEBAg4BAQABAQEDEAEBAAEBAQQOAQEFEAEBBhABAQcQAQEIEAEBCRABAQALAQECDgEBAAEBAQMQAQEAAQEBBA4BAQUQAQEGEAEBBxABAQgQAQEJEAEBAAsBAQIOAQEAAQEBAxABAQABAQEEDgEBBRABAQYQAQEHEAEBCBABAQkQAQEACwEBAg4BAQABAQEDEAEBAAEBAQQOAQEFEAEBBhABAQcQAQEIEAEBCRABAQALAQECDgEBAAEBAQMQAQEAAQEBBA4BAQUQAQEGEAEBBxABAQgQAQEJEAEBAAsBAQIOAQEAAQEBAxABAQABAQEEDgEBBRABAQYQAQEHEAEBCBABAQkQAQEACwEBAg4BAQABAQEDEAEBAAEBAQQOAQEFEAEBBhABAQcQAQEIEAEBCRABAQALAQECDgEBAAEBAQMQAQEAAQEBBA4BAQUQAQEGEAEBBxABAQgQAQEJEAEBAAsBAQIOAQEAAQEBAxABAQABAQEEDgEBBRABAQYQAQEHEAEBCBABAQkQAQEACwEBAg4BAQABAQEDEAEBAAEBAQQOAQEFEAEBBhABAQcQAQEIEAEBCRABAQALAQECDgEBAAEBAQMQAQEAAQEBBA4BAQUQAQEGEAEBBxABAQgQAQEJEAEBAAsBAQIOAQEAAQEBAxABAQABAQEEDgEBBRABAQYQAQEHEAEBCBABAQkQAQEACwEBAg4BAQABAQEDEAEBAAEBAQQOAQEFEAEBBhABAQcQAQEIEAEBCRABAQALAQECDgEBAAEBAQMQAQEAAQEBBA4BAQUQAQEGEAEBBxABAQgQAQEJEAEBAAsBAQIOAQEAAQEBAxABAQABAQEEDgEBBRABAQYQAQEHEAEBCBABAQkQAQEACwEBAg4BAQABAQEDEAEBAAEBAQQOAQEFEAEBBhABAQcQAQEIEAEBCRABAQALARAAAQESAAEBZQALAQEKDgEBABQBAQwOAQENEAEBDhABAQ8QAQEQEAEBERABAQALAQEKDgEWDA4BAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBAQoQAQELEAEBDBABAQ0QAQEOEAEBDxABARAQAQEREAEBAAsBiQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAQESEAEBExABARQQAQEVEAEBFhABARcQAQEYEAEBGRABAQALAYkACwEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEBGhABARsQAQEAcQEjAP8A/wC+"},"v":{"size":[90,25],"value":3},"cc":{"size":[21,20],"pos":[108,-40],"value":0}}}
canv:{"type":"canvas","size":[160,160],"pos":[47,60],"script":"home.2","image":"%%IMG0AAgACCBAgMEiHAgQ","scale":20}
button1:{"type":"button","size":[46,20],"pos":[64,310],"script":"home.3","text":"Invert"}
button2:{"type":"button","size":[60,20],"pos":[186,296],"script":"home.4","text":"Clear"}
button3:{"type":"button","size":[60,20],"pos":[288,29],"script":"home.5","text":"Copy"}
button4:{"type":"button","size":[60,20],"pos":[279,55],"script":"home.6","text":"Paste"}
button5:{"type":"button","size":[30,60],"pos":[215,107],"script":"home.7","show":"transparent"}
button6:{"type":"button","size":[30,60],"pos":[8,108],"script":"home.8","show":"transparent"}
button7:{"type":"button","size":[73,31],"pos":[94,228],"script":"home.9","show":"transparent"}
button8:{"type":"button","size":[73,31],"pos":[89,22],"script":"home.10","show":"transparent"}
clip:{"type":"canvas","size":[40,40],"pos":[228,35],"locked":1,"script":"home.2","image":"%%IMG0AAgACIgiiCKIIogi","pattern":0,"scale":5}
field1:{"type":"field","size":[230,55],"pos":[271,276],"locked":1,"style":"plain","value":"Note: if you save this deck, you can import the custom patterns into another deck via the Font/DA Mover. Alternatively, you can copy this card directly into your deck, edit the patterns in-place, and delete the card when you're satisfied."}
button9:{"type":"button","size":[60,20],"pos":[25,286],"script":"home.11","show":"transparent","text":"Flip        "}
button10:{"type":"button","size":[60,20],"pos":[90,286],"script":"home.12","show":"transparent","text":"Flip        "}
field2:{"type":"field","size":[80,15],"pos":[176,271],"show":"transparent","border":0,"style":"plain","align":"center","value":"danger, danger!"}
field3:{"type":"field","size":[80,14],"pos":[176,326],"show":"transparent","border":0,"style":"plain","align":"center","value":"high voltage!"}
button11:{"type":"button","size":[52,20],"pos":[7,310],"script":"home.13","show":"transparent","text":"     Rot"}
button12:{"type":"button","size":[52,20],"pos":[114,310],"script":"home.14","show":"transparent","text":"Rot     "}

{script:home.0}
on edit do
 patterns[pat.value]:canv.copy[]
end

on view do
 
end
{end}

{script:home.1}
on change val do
 canv.clear[]
 canv.paste[patterns[val]]
end
{end}

{script:home.2}
on click pos do
 me.pattern:!me[pos]
 edit[]
end

on drag pos do
 send drag[pos]
 edit[]
end

on release pos do
 drag[pos]
end
{end}

{script:home.3}
on click do
 canv.invert[]
 edit[]
end
{end}

{script:home.4}
on click do
 canv.clear[]
 edit[]
end
{end}

{script:home.5}
on click do
 clip.paste[patterns[pat.value]]
end
{end}

{script:home.6}
on click do
 patterns[pat.value]:clip.copy[]
end
{end}

{script:home.7}
on click do
 canv.paste[canv.copy[].translate[1,0 1]]
 edit[]
end
{end}

{script:home.8}
on click do
 canv.paste[canv.copy[].translate[-1,0 1]]
 edit[]
end
{end}

{script:home.9}
on click do
 canv.paste[canv.copy[].translate[0,1 1]]
 edit[]
end
{end}

{script:home.10}
on click do
 canv.paste[canv.copy[].translate[0,-1 1]]
 edit[]
end
{end}

{script:home.11}
on click do
 canv.paste[canv.copy[].transform["horiz"]]
 edit[]
end
{end}

{script:home.12}
on click do
 canv.paste[canv.copy[].transform["vert"]]
 edit[]
end
{end}

{script:home.13}
on click do
 canv.paste[canv.copy[].transform["left"]]
 edit[]
end
{end}

{script:home.14}
on click do
 canv.paste[canv.copy[].transform["right"]]
 edit[]
end
{end}

{contraption:patternPicker}
size:[100,100]
resizable:1
margin:[10,10,10,10]
description:"a palette of mutable patterns"
script:"patternPicker.0p"
template:"on change val do\n \nend"
attributes:{"name":["value","color"],"label":["Value","Color"],"type":["number","bool"]}
{widgets}
c:{"type":"canvas","size":[100,100],"pos":[0,0],"locked":1,"border":1,"scale":1}
v:{"type":"slider","size":[60,25],"pos":[2,-41],"locked":1,"show":"none","interval":[0,47]}
cc:{"type":"button","size":[14,20],"pos":[73,-40],"locked":1,"show":"none","style":"check","value":1}

{script:patternPicker.0p}
on get_value do v.value end
on set_value x do v.value:x view[] end
on get_color do cc.value end
on set_color x do cc.value:x view[] end

b:5
r:4+2*cc.value
s:floor(c.size-2*b)/8,r

on boxes do
 flip b+s*flip 8 cross r
end

on view do
 o:-50
 c.clear[]
 each p i in boxes[]
  if i<26
   c.pattern:2+i
   c.rect[p s]
   c.pattern:1
   c.box[p s+1]
   if (2+i)=v.value o:p end
  end
 end
 c.pattern:0
 c.box[o-1 s+3]
 c.pattern:1
 c.box[o-2 s+5]
end

on inside p r do
 min(p>r)&(r+s>p)
end
on click pos do
 each p i in boxes[]
  if inside[pos p]
   set_value[i+2]
   card.event["change" i+2]
  end
 end
end

{end}

