REVO8000 selectiveGray89 ################################################################# ## [ Raspi stack #99 = selectiveGray67 (= LC-Magick 9) ] ## ## Widget version = selectiveGray89 [-hh fecit, May 2017] ## ################################################################# ## The main scripts are in card, fld "HTML" (js) and button ## ## "selectiveGray-LCS" (the pure LCS-version from LC-Magick 9) ## ## Simple window dragging only here. ## ## Save as stackfileversion 8.0 (script creates browser widget ## local iDrag=false, repeatCycle=8 on preopenstack set the acceleratedRendering of this stack to true set the paintcompression to RLE set defaultcursor to hand set selectionhandlecolor to "0,203,203" set hilite of btn "useLCS" to true send "choose browse tool" to me in 1 tick send "mouseUp" to btn "reset" in 1 ticks end preopenstack on mouseDown n if the target begins with "card " then lock cursor; set cursor to hand; put true into iDrag dragMe repeatCycle, clickH(), clickV() else pass mousedown end mouseDown on mouseUp unlock cursor; put false into iDrag; killDrags end mouseUp on mouseRelease mouseUp end mouseRelease -- N = "repeat cycle" in millisecs; x,y = the loc of dragging cursor on dragMe N,x,y if not iDrag or the shiftkey is down then exit dragMe put the screenMouseloc into sL set topleft of this stack to (-x + item 1 of sL, -y + item 2 of sL) send "dragMe N,x,y" to me in (N - the millisecs mod N) millisecs end dragMe on killDrags repeat 2 repeat for each line L in the pendingMessages if "dragMe" is item 3 of L then cancel item 1 of L end repeat end repeat end killDrags s i5J 5J U (System) U (Menu) U (Text),unicode U (Text),unicode W (Text),unicode U Monaco U Monaco,unicode U (Message),unicode W (Message) U Droid Sans U Droid Sans U Droid Sans,unicode cREVGeneral breakpoints breakpointstates scripteditorselection 398 breakpointconditions scripteditorvscroll stackfileversion 5.5 scalefactor ? cREVGeometryCache stackID card_1 ################################################################# ## [ Raspi stack #99 = selectiveGray67 (= LC-Magick 9) ] ## ## Widget version = selectiveGray89 [-hh fecit, May 2017] ## ################################################################# ## The main scripts is here and in fld "HTML" (js) and button ## ## "selectiveGray-LCS" (the pure LCS-version from LC-Magick 9) ## ## Save as stackfileversion 8.0 (script creates browser widget ## local bw="hhSelectiveGray", lci="Image1", lcii="Image2" function jsExecute scrpt if the htmltext of widget bw is empty then htmlSet fld "HTML" do scrpt in widget bw return the result end jsExecute on htmlSet txt if there is no widget bw then create invisible widget bw as "com.livecode.widget.browser" set the javascriptHandlers of widget bw to "jsGetImageData" end if set htmltext of widget bw to txt end htmlSet on jsGetImageData tData,tWidth,tHeight lock screen; lock messages set lockloc of img lcii to false set the width of img lcii to tWidth set the height of img lcii to tHeight set the text of img lcii to base64Decode(item 2 of tData) set lockloc of img lcii to true set backcolor of this card to the backcolor of this card unlock screen; unlock messages end jsGetImageData on getImage get jsExecute("var dd=document.getElementById('myCanvas');" & \ "liveCode.jsGetImageData(dd.toDataURL(),dd.width,dd.height)") end getImage on chooseImage eins if eins is empty then put lci into eins put base64encode(img eins) into tData replace linefeed with empty in tData put the width of img eins into tWidth put the height of img eins into tHeight get jsExecute("var hhimg = document.getElementById('hh0');" & \ "hhimg.setAttribute('src','data:image/png;base64," & tData & "');" & \ "hhimg.setAttribute('width','" & tWidth & "');" & \ "hhimg.setAttribute('height','" & tHeight & "');" & \ "hhimg.setAttribute('alt','iAmTheWalrus');") -- jsGetImageData ("data:image/png;base64," & tData),tWidth,tHeight -- test it end chooseImage on doJob pNb lock screen; lock messages put the millisecs into m1 put "applyEffect("& pNb &");" into js get jsExecute(js & "var dd=document.getElementById('myCanvas');" & \ "liveCode.jsGetImageData(dd.toDataURL(),dd.width,dd.height)") put the millisecs-m1 & " ms" into fld "timing" unlock screen; unlock messages end doJob function xeffects pName put true into aa -- switch for using img as input switch pName case "grayscale"; return (0,aa) case "selectiveGray" put the backcolor of grc (the currentColor of grp "colors") into cc0 put "["& cc0 &"]" into cc0 put the relativePos of grp "colorRadius" into dc0 put the hilite of btn "NOT" into hnot if the hilite of btn "usePoly" then put "["& (the width of img lci,the topleft of img lci) &"]" into coords put the points of grc "hhPoly" into pnts replace cr with "],[" in pnts put "[[" & pnts & "]]" into pnts2 put the hilite of btn "notpoly" into np return (1,aa,cc0,dc0*dc0,coords,pnts2,np,hnot) else return (1,aa,cc0,dc0*dc0,"[0,0,0]","[]",false,hnot) default; return -1 end switch end xeffects LLLLLL 5J z theHTML F
cREVGeneral scripteditorvscroll r scripteditorselection 1470 cREVGeometryCacheIDs F 1495385280446 1495375189294 b 1495317490038 1495317490051 1495346972216 E 1495317490041 1494941538325 1495285922012 1495375307524 c 1495317490024 1494787243693 1495317490032 r 1495317490047 1495382642222 1495317483653 1495317490037 } 1494939394624 1495317490050 1494944223342 1495317490042 1495214650069 t 1495319685238 1495317483654 1495317490031 n 1495317490025 1495317490028 1495375571751 1495372811308 ] 1495345340529 C 1494787670364 1494941100534 1495312802275 1495317490036 | 1495317483652 ~ 1495375571754 1495317490043 1494940175004 1494941367961 1495311495505 1495249055879 1495317490035 { 1495317490030 ^ 1495317490029 J 1495249055880 1495375571752 1495317490049 1495373045909 ^ 1494941733804 1494940679427 1495318320811 1495375571755 1495378268023 u 1495317490034 z 1495317490026 1495372062048 \ 1495317490023 K 1495317490045 1495375571753 1495285651402 1495317483651 1495317490039 1494795558009 1495214650044 u 1494799302079 1495317490040 1495375571756 1495317576922 1495317490033 s 1495317490027 1495317490046 cREVGeometrycache total F order \ C t K ^ n r s z } E ] b u ResetEpilocal i1="Image1", i2="Image2" on mouseUp lock screen; lock messages put the topright of btn "imagesInput" into TR set topleft of img i1 to (14+item 1 of TR,item 2 of TR) set rect of img i2 to the rect of img i1 if not the hilite of btn "useLCS" then doJob xeffects("grayscale") set the savedData of img i2 to the imagedata of img i2 else setGray i1,i2 set defaultcursor to hand show img i1 unlock screen; unlock messages end mouseUp on setGray j1,j2 set cursor to watch put the alphaData of img j1 into mData put the imageData of img j1 into iData put the width of img j2 into w repeat with i=1 to the height of img j2 put 4*(i-1)*w into i0 repeat with j=1 to w put i0+4*(j-1) into j0 put numToByte( min(255,trunc(0.299*byteToNum(byte j0+2 of iData) + \ 0.687*byteToNum(byte j0+3 of iData) + \ 0.114*byteToNum(byte j0+4 of iData))) ) into c put c&c&c into byte j0+2 to j0+4 of iData end repeat end repeat set the alphaData of img j2 to mData set the imageData of img j2 to iData set the savedData of img j2 to iData end setGray N cREVGeneral revUniqueID 1494787243693 scripteditorvscroll scripteditorselection 435 tools iP 0 z > cREVGeneral revUniqueID 1494787670364 scripteditorvscroll scripteditorselection 277 ^ Sizee n 3 Small 1 Large 2 Medium 3 Small 4 Tiny cREVGeneral revUniqueID P uB scripteditorvscroll scripteditorselection 44 c ptools ilocal oldchoice on mouseDown b if b=3 then edit script of me exit mouseDown end if put the hilitedButtonName of me into oldchoice pass mouseDown end mouseDown on mouseUp b if b=3 then exit mouseUp lock screen put the hilitedButtonName of me into hb --if oldchoice is "reveal" then send "mouseUp" to btn "reset" put char 1 of the label of btn "size" into sz switch hb case "square"; choose eraser tool ; set eraser to sz; break case "circle"; choose eraser tool ; set eraser to sz+4; break case "slash"; choose eraser can tool ; set eraser to sz+8; break case "backslash"; choose eraser tool ; set eraser to sz+12; break case "vertical bar"; choose eraser tool ; set eraser to sz+16; break case "horizontal bar"; choose eraser tool ; set eraser to sz+20; break case "reveal"; lock screen put img "image1" into img "image2" unlock screen; break end switch unlock screen end mouseUp on mouseEnter if the tool is not "pointer tool" then choose "browse tool" end mouseEnter 4 r r cREVGeneral revUniqueID @0uB scripteditorvscroll scripteditorselection 1048 squarehD on mouseUp end mouseUp 8 j w cREVGeneral scripteditorvscroll 0 revUniqueID pFuB scripteditorselection 13 circlehD M j w cREVGeneral revUniqueID FuB scripteditorvscroll 0 scripteditorselection 0 slashhD c j q cREVGeneral scripteditorvscroll 0 revUniqueID FuB scripteditorselection 11 backslashhD y j q cREVGeneral revUniqueID FuB scripteditorvscroll 0 scripteditorselection 0 vertical barhD j u cREVGeneral revUniqueID FuB scripteditorvscroll 0 scripteditorselection 13 horizontal barhD j w cREVGeneral scripteditorvscroll 0 revUniqueID FuB scripteditorselection 11 t stackPathH i u cREVGeneral scripteditorvscroll 0 revUniqueID 1495214650069 scripteditorselection 0 u StackPathn] on mouseDown put the long id of this stack into M set itemdelimiter to quote put item-1 of M into M set itemdelimiter to comma replace "/" with CR in M if line 1 of M is empty then put "[Top]" into line 1 of M if line 2 of M is empty then put "[]"& line 3 of M into line 1 to 3 of M end if put "(" before last line of M put M into me end mouseDown on mouseUp end mouseUp on mouseRelease end mouseRelease on menuPick goTo line 1 to (the menuhistory of me) of me -- in script of grp "stackPath" end menuPick on mouseEnter set tooltip of me to "Select from the path to this stack." end mouseENter on goTo t set itemdelimiter to "]" put item 1 of line 1 of t into t1 if colon is in t1 then // do nothing else if "[Top"is t1 then put empty into line 1 of t else if "[" is t1 then put "//" into char 1 to 2 of t else put CR before t set itemdelimiter to comma if t is empty then put CR into t replace CR with "/" in t if the platform is "linux" then try launch document t get shell("xdg-open " & quote&t"e) end try else launch document t end if end goTo @@ ff #Select from the path to this stack. 4 O[Top] Users admin Documents [-hh] hhSelectiveGray (selectiveGray89_100.livecode cGlx2TimeStamp checksum ¥·VfiØ͡¯V0Ÿük0Ê cGLX2General cConstants cHandlers 'menuPick mouseDown mouseRelease mouseUp cScriptChecksum cHtmlHandlers 㠕á !Ö·}Oq1h+bísW=@=Äc∑îGÊ&Ω~∂hÈÚ>[–éhπé¿!>fiÉ–múû¿ãoCk•ç ‹2hI∂+ÇK ÇÀ˜D[Ÿ YpcÓ∂Ê¥∆‘;®£ŸÎl¢\/—ø˙êπ2ùÁOÓWÆî»1ıC∑Ú3æXH˝c cVscrollScript 5891 cHandlersListWidth 93 cLocals 'shifty m me m mm line line me last CR ( cGlobals cHscrollScript 0 cFolders all handlers cSelectedChunk char 10741 to 10740 cVscrollHandlers 0 cHscrollHandlers 0 cDirtyFlag false cHTMLScriptã mSMo€0Ω˚W>¨Œ¡€öÏvi7`áEõù∫¬–l:¢ØYÚ2ˇ˚ëíÌ∏≈Ç@(æ'æG™,?ÉP :aÖΩœ≤≤| OñK^∂p•d}Ñ`¡#ÇÄV*º°ÉÔhhm°C®áæG¿ç°≥&&Ω$Ùn,¿1B‘–ˆVGàf<—,ØÈ#‰MÑHs %|HΖ¯rc…‹p탫·’'ǧ[ ˝F;\¸°Ç:ΗLıI+4 Û-Ô8˘=‹w≤ I‡(Q5ûJ’g]ÑÛA‘«ø(˙¿¿èº@µ˙¡ûí+˙SM’I6°´î‘2Tfl™¡dÙH_\C≤å*÷ñ¢◊ˆd2 7(䮘lõl“î≠7 ûQî∑7¯IÙ£nB¡«ûïq“0∏ H√‰‡H…≤ùˆLe"öØW“ lô∂U ‰n¸J™ç–ò'ºéô÷Lã⁄≠ E^‹XJÊm¥‹£¬:`33‡îãex"‡ÀÕ5q”Y≈I'çÇlíÏπ!Ár<¶i0˙ç=”Ô¡ú,Â√2∫¶'√ztJ‘˘´<Õ“’ù¶3“çH†gRì»áΩuèì§uÓ Ω˝zq:xÃ_§ƒ›ú∏"£›na\|!jc√∫sìÂ9¸BöXLO&rÃ`Nò……|Ê:ªæå‡w>°˝ø£Ó øÇÕÅòAÖfl*›r∞˚uÌ≈¸æ©a¡ˆ„4®Èì»&Ï?ÒŒxá cHilitedLine cExplicitVariables cREVGeneral revUniqueID 1495214650044 scripteditorvscroll 124 scripteditorselection 1154 Image1@ @ ? 'PNG IHDR @ O*<