home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / freeware / pixeltoolbox / Setup.exe / Main / PixelToolbox.exe / PixelToolbox.dxr / Scripts_16_canvas script - 8bit.ls < prev    next >
Encoding:
Text File  |  2002-06-08  |  21.3 KB  |  531 lines

  1. property pSprite, pUndoTrigger
  2. global gProject, gSize, gCast, gVariable, gFirstColor, gSecondColor, gPencilSize, gPencilShape, gEraserSize, gEraserShape, gBrushSize, gBrushShape, gAirbrushSize, gAirbrushShape, gGradientDirection, gClonerShape, gClonerSize, gClonerFlag, gClonerHDist, gClonerVDist, myCurrentImage, pPixelActorListX, pPixelActorListY, pSpreadListX, pSpreadListY, currentCursor, gCurrentColor, gShapeType, gRectStyle, gOvalStyle, gRoundRectStyle, gWvBgColor, gWvBgShadow, gWvVcolor, gWvVShadow, gWvHcolor, gWvHShadow, gMarqueeRect
  3.  
  4. on beginSprite me
  5.   pSprite = sprite(me.spriteNum)
  6.   pUndoTrigger = 0
  7. end
  8.  
  9. on mouseWithin me
  10.   if sprite(64).pState = 1 then
  11.     if gPencilSize = 1 then
  12.       nothing()
  13.     else
  14.       sprite(8).rect = rect(the mouseH - (gPencilSize * gVariable / 2), the mouseV - (gPencilSize * gVariable / 2), the mouseH + (gPencilSize * gVariable / 2), the mouseV + (gPencilSize * gVariable / 2))
  15.     end if
  16.   else
  17.     if sprite(73).pState = 1 then
  18.       sprite(8).rect = rect(the mouseH - (gBrushSize * gVariable / 2), the mouseV - (gBrushSize * gVariable / 2), the mouseH + (gBrushSize * gVariable / 2), the mouseV + (gBrushSize * gVariable / 2))
  19.     else
  20.       if sprite(84).pState = 1 then
  21.         if gEraserSize = 1 then
  22.           nothing()
  23.         else
  24.           sprite(8).rect = rect(the mouseH - (gEraserSize * gVariable / 2), the mouseV - (gEraserSize * gVariable / 2), the mouseH + (gEraserSize * gVariable / 2), the mouseV + (gEraserSize * gVariable / 2))
  25.         end if
  26.       else
  27.         if sprite(96).pState = 1 then
  28.           sprite(8).rect = rect(the mouseH - (gAirbrushSize * gVariable / 2), the mouseV - (gAirbrushSize * gVariable / 2), the mouseH + (gAirbrushSize * gVariable / 2), the mouseV + (gAirbrushSize * gVariable / 2))
  29.         else
  30.           if sprite(104).pState = 1 then
  31.             if gClonerSize = 1 then
  32.               if gClonerFlag = 0 then
  33.                 nothing()
  34.               else
  35.                 sprite(9).loc = point(((the mouseH - sprite(1).left) * 2 / gVariable / 2 * gVariable) + sprite(1).left + (gVariable / 2) + (gClonerHDist * gVariable), ((the mouseV - sprite(1).top) * 2 / gVariable / 2 * gVariable) + sprite(1).top + (gVariable / 2) + (gClonerVDist * gVariable))
  36.               end if
  37.             else
  38.               if gClonerFlag = 0 then
  39.                 sprite(8).rect = rect(the mouseH - (gClonerSize * gVariable / 2), the mouseV - (gClonerSize * gVariable / 2), the mouseH + (gClonerSize * gVariable / 2), the mouseV + (gClonerSize * gVariable / 2))
  40.               else
  41.                 sprite(8).rect = rect(the mouseH - (gClonerSize * gVariable / 2), the mouseV - (gClonerSize * gVariable / 2), the mouseH + (gClonerSize * gVariable / 2), the mouseV + (gClonerSize * gVariable / 2))
  42.                 sprite(9).loc = point(((the mouseH - sprite(1).left) * 2 / gVariable / 2 * gVariable) + sprite(1).left + (gVariable / 2) + (gClonerHDist * gVariable), ((the mouseV - sprite(1).top) * 2 / gVariable / 2 * gVariable) + sprite(1).top + (gVariable / 2) + (gClonerVDist * gVariable))
  43.               end if
  44.             end if
  45.           else
  46.             if sprite(145).pState = 1 then
  47.               toolColorFinder()
  48.             else
  49.               if sprite(146).pState = 1 then
  50.                 if (gMarqueeRect <> rect(0, 0, 0, 0)) and inside(point(the mouseH, the mouseV), gMarqueeRect) then
  51.                   pSprite.cursor = [412, 413]
  52.                 else
  53.                   pSprite.cursor = 271
  54.                 end if
  55.               end if
  56.             end if
  57.           end if
  58.         end if
  59.       end if
  60.     end if
  61.   end if
  62.   put (the mouseH - sprite(1).left) * 2 / gVariable / 2 into field "location status X"
  63.   put (the mouseV - sprite(1).top) * 2 / gVariable / 2 into field "location status Y"
  64. end
  65.  
  66. on mouseEnter me
  67.   if sprite(64).pState = 1 then
  68.     pSprite.cursor = 256
  69.     member(391).shapeType = gPencilShape
  70.   else
  71.     if sprite(73).pState = 1 then
  72.       pSprite.cursor = [350, 351]
  73.       member(391).shapeType = gBrushShape
  74.     else
  75.       if sprite(84).pState = 1 then
  76.         pSprite.cursor = [352, 353]
  77.         member(391).shapeType = gEraserShape
  78.       else
  79.         if sprite(96).pState = 1 then
  80.           pSprite.cursor = [354, 355]
  81.           member(391).shapeType = gAirbrushShape
  82.         else
  83.           if sprite(104).pState = 1 then
  84.             pSprite.cursor = [348, 349]
  85.             member(391).shapeType = gClonerShape
  86.           else
  87.             if sprite(116).pState = 1 then
  88.               pSprite.cursor = 271
  89.               gShapeType = #rect
  90.             else
  91.               if sprite(121).pState = 1 then
  92.                 pSprite.cursor = 271
  93.                 gShapeType = #oval
  94.               else
  95.                 if sprite(126).pState = 1 then
  96.                   pSprite.cursor = 271
  97.                   gShapeType = #roundRect
  98.                 else
  99.                   if sprite(131).pState = 1 then
  100.                     pSprite.cursor = 271
  101.                   else
  102.                     if sprite(138).pState = 1 then
  103.                       pSprite.cursor = 271
  104.                     else
  105.                       if sprite(142).pState = 1 then
  106.                         pSprite.cursor = 259
  107.                       else
  108.                         if sprite(143).pState = 1 then
  109.                           pSprite.cursor = [344, 345]
  110.                         else
  111.                           if sprite(144).pState = 1 then
  112.                             pSprite.cursor = [346, 347]
  113.                           else
  114.                             if sprite(145).pState = 1 then
  115.                               pSprite.cursor = [356, 357]
  116.                             else
  117.                               if sprite(146).pState = 1 then
  118.                                 pSprite.cursor = 271
  119.                               else
  120.                                 if sprite(147).pState = 1 then
  121.                                   pSprite.cursor = 1
  122.                                 else
  123.                                   if sprite(240).pState = 1 then
  124.                                     pSprite.cursor = [432, 433]
  125.                                   else
  126.                                     if sprite(272).pState = 1 then
  127.                                       pSprite.cursor = [466, 467]
  128.                                       sendSprite(3, #hotspotOn)
  129.                                     end if
  130.                                   end if
  131.                                 end if
  132.                               end if
  133.                             end if
  134.                           end if
  135.                         end if
  136.                       end if
  137.                     end if
  138.                   end if
  139.                 end if
  140.               end if
  141.             end if
  142.           end if
  143.         end if
  144.       end if
  145.     end if
  146.   end if
  147.   currentCursor = pSprite.cursor
  148. end
  149.  
  150. on mouseLeave me
  151.   pSprite.cursor = 0
  152.   put EMPTY into field "location status X"
  153.   put EMPTY into field "location status Y"
  154.   if (sprite(64).pState = 1) or (sprite(73).pState = 1) or (sprite(84).pState = 1) or (sprite(96).pState = 1) or (sprite(104).pState = 1) then
  155.     sprite(8).rect = rect(-60, -60, 0, 0)
  156.   else
  157.     if sprite(145).pState = 1 then
  158.       sprite(48).rect = rect(-20, -20, 0, 0)
  159.       put EMPTY into field "red status"
  160.       put EMPTY into field "green status"
  161.       put EMPTY into field "blue status"
  162.       put EMPTY into field "hex status"
  163.       put EMPTY into field "paletteIndex status"
  164.     end if
  165.   end if
  166.   if gProject = "cursor" then
  167.     if sprite(272).pState = 1 then
  168.       sendSprite(3, #hotspotOff)
  169.     end if
  170.   end if
  171. end
  172.  
  173. on mouseDown
  174.   if pUndoTrigger = 0 then
  175.     if sprite(146).pState <> 1 then
  176.       pUndoTrigger = 1
  177.     end if
  178.   end if
  179.   if sprite(64).pState = 1 then
  180.     if gPencilSize = 1 then
  181.       tool1PxPencil()
  182.     else
  183.       toolPencil()
  184.     end if
  185.   else
  186.     if sprite(73).pState = 1 then
  187.       toolBrush()
  188.     else
  189.       if sprite(84).pState = 1 then
  190.         if gEraserSize = 1 then
  191.           tool1PxEraser()
  192.         else
  193.           toolEraser()
  194.         end if
  195.       else
  196.         if sprite(96).pState = 1 then
  197.           toolAirbrush()
  198.         else
  199.           if sprite(104).pState = 1 then
  200.             if gClonerSize = 1 then
  201.               tool1PxCloner()
  202.             else
  203.               toolCloner()
  204.             end if
  205.           else
  206.             if sprite(116).pState = 1 then
  207.               if gRectStyle = "outline" then
  208.                 toolOutlineShape()
  209.               else
  210.                 if gRectStyle = "filled" then
  211.                   toolFilledShape()
  212.                 else
  213.                   if gRectStyle = "solid" then
  214.                     toolSolidShape()
  215.                   end if
  216.                 end if
  217.               end if
  218.             else
  219.               if sprite(121).pState = 1 then
  220.                 if gOvalStyle = "outline" then
  221.                   toolOutlineShape()
  222.                 else
  223.                   if gOvalStyle = "filled" then
  224.                     toolFilledShape()
  225.                   else
  226.                     if gOvalStyle = "solid" then
  227.                       toolSolidShape()
  228.                     end if
  229.                   end if
  230.                 end if
  231.               else
  232.                 if sprite(126).pState = 1 then
  233.                   if gRoundRectStyle = "outline" then
  234.                     toolOutlineShape()
  235.                   else
  236.                     if gRoundRectStyle = "filled" then
  237.                       toolFilledShape()
  238.                     else
  239.                       if gRoundRectStyle = "solid" then
  240.                         toolSolidShape()
  241.                       end if
  242.                     end if
  243.                   end if
  244.                 else
  245.                   if sprite(131).pState = 1 then
  246.                     toolStraightLine()
  247.                   else
  248.                     if sprite(138).pState = 1 then
  249.                       if gGradientDirection = "H" then
  250.                         toolGradientH()
  251.                       else
  252.                         if gGradientDirection = "V" then
  253.                           toolGradientV()
  254.                         else
  255.                           if gGradientDirection = "rect" then
  256.                             toolGradientRect()
  257.                           else
  258.                             if gGradientDirection = "oval" then
  259.                               toolGradientOval()
  260.                             end if
  261.                           end if
  262.                         end if
  263.                       end if
  264.                     else
  265.                       if sprite(142).pState = 1 then
  266.                         toolFill()
  267.                       else
  268.                         if sprite(143).pState = 1 then
  269.                           toolCheckerFill()
  270.                         else
  271.                           if sprite(144).pState = 1 then
  272.                             toolChangeColor()
  273.                           else
  274.                             if sprite(145).pState = 1 then
  275.                               pSprite.cursor = [361, 362]
  276.                               toolColorFinder()
  277.                             else
  278.                               if sprite(146).pState = 1 then
  279.                                 if (gMarqueeRect <> rect(0, 0, 0, 0)) and inside(point(the mouseH, the mouseV), gMarqueeRect) then
  280.                                   moveSelect()
  281.                                 else
  282.                                   toolSelect()
  283.                                 end if
  284.                               else
  285.                                 if sprite(147).pState = 1 then
  286.                                   toolText()
  287.                                 else
  288.                                   if sprite(240).pState = 1 then
  289.                                     toolWarp()
  290.                                   else
  291.                                     if sprite(272).pState = 1 then
  292.                                       toolHotspot()
  293.                                     end if
  294.                                   end if
  295.                                 end if
  296.                               end if
  297.                             end if
  298.                           end if
  299.                         end if
  300.                       end if
  301.                     end if
  302.                   end if
  303.                 end if
  304.               end if
  305.             end if
  306.           end if
  307.         end if
  308.       end if
  309.     end if
  310.   end if
  311. end
  312.  
  313. on mouseUp
  314.   if sprite(145).pState = 1 then
  315.     pSprite.cursor = currentCursor
  316.     if sprite(47).rect = rect(598, 13, 622, 37) then
  317.       gFirstColor = gCurrentColor
  318.       member("1st Color", gCast).image.fill(member("1st Color", gCast).rect, gFirstColor)
  319.     else
  320.       if sprite(47).rect = rect(598, 43, 622, 67) then
  321.         gSecondColor = gCurrentColor
  322.         member("2nd Color", gCast).image.fill(member("2nd Color", gCast).rect, gSecondColor)
  323.       else
  324.         if sprite(47).rect = rect(48, 518, 67, 537) then
  325.           gWvBgColor = gCurrentColor
  326.           member("weave - bg color", gCast).image.fill(member("weave - bg color", gCast).rect, gWvBgColor)
  327.         else
  328.           if sprite(47).rect = rect(68, 518, 87, 537) then
  329.             gWvBgShadow = gCurrentColor
  330.             member("weave - bg shadow", gCast).image.fill(member("weave - bg shadow", gCast).rect, gWvBgShadow)
  331.           else
  332.             if sprite(47).rect = rect(48, 543, 67, 562) then
  333.               gWvVcolor = gCurrentColor
  334.               member("weave - V color", gCast).image.fill(member("weave - V color", gCast).rect, gWvVcolor)
  335.             else
  336.               if sprite(47).rect = rect(68, 543, 87, 562) then
  337.                 gWvVShadow = gCurrentColor
  338.                 member("weave - V shadow", gCast).image.fill(member("weave - V shadow", gCast).rect, gWvVShadow)
  339.               else
  340.                 if sprite(47).rect = rect(48, 568, 67, 587) then
  341.                   gWvHcolor = gCurrentColor
  342.                   member("weave - H color", gCast).image.fill(member("weave - H color", gCast).rect, gWvHcolor)
  343.                 else
  344.                   if sprite(47).rect = rect(68, 568, 87, 587) then
  345.                     gWvHShadow = gCurrentColor
  346.                     member("weave - H shadow", gCast).image.fill(member("weave - H shadow", gCast).rect, gWvHShadow)
  347.                   else
  348.                     if sprite(47).rect = rect(593, 263, 617, 287) then
  349.                       member("palette transparency color", gCast).image.fill(member("palette transparency color", gCast).rect, gCurrentColor)
  350.                       sprite(1).bgColor = gCurrentColor
  351.                       sprite(20).bgColor = gCurrentColor
  352.                       sprite(261).bgColor = gCurrentColor
  353.                       sprite(262).bgColor = gCurrentColor
  354.                       sprite(263).bgColor = gCurrentColor
  355.                       sprite(264).bgColor = gCurrentColor
  356.                       sprite(47).rect = rect(598, 13, 622, 37)
  357.                     end if
  358.                   end if
  359.                 end if
  360.               end if
  361.             end if
  362.           end if
  363.         end if
  364.       end if
  365.     end if
  366.     gCurrentColor = VOID
  367.   end if
  368. end
  369.  
  370. on rightMouseDown
  371.   if (sprite(145).pState = 1) or (sprite(146).pState = 1) then
  372.     nothing()
  373.   else
  374.     if sprite(104).pState = 1 then
  375.       pSprite.cursor = [359, 360]
  376.       gClonerFlag = 0
  377.       sprite(9).blend = 100
  378.       sprite(9).loc = point(((the mouseH - sprite(1).left) * 2 / gVariable / 2 * gVariable) + sprite(1).left + (gVariable / 2), ((the mouseV - sprite(1).top) * 2 / gVariable / 2 * gVariable) + sprite(1).top + (gVariable / 2))
  379.     else
  380.       pSprite.cursor = [361, 362]
  381.       gCurrentColor = member(gSize & "x" & gSize, gCast).image.getPixel((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2)
  382.       put gCurrentColor.red into field "red status"
  383.       put gCurrentColor.green into field "green status"
  384.       put gCurrentColor.blue into field "blue status"
  385.       put gCurrentColor.hexString() into field "hex status"
  386.       put gCurrentColor.paletteIndex into field "paletteIndex status"
  387.       if sprite(47).rect = rect(598, 13, 622, 37) then
  388.         gFirstColor = gCurrentColor
  389.         member("1st Color", gCast).image.fill(member("1st Color", gCast).rect, gFirstColor)
  390.       else
  391.         if sprite(47).rect = rect(598, 43, 622, 67) then
  392.           gSecondColor = gCurrentColor
  393.           member("2nd Color", gCast).image.fill(member("2nd Color", gCast).rect, gSecondColor)
  394.         else
  395.           if sprite(47).rect = rect(48, 518, 67, 537) then
  396.             gWvBgColor = gCurrentColor
  397.             member("weave - bg color", gCast).image.fill(member("weave - bg color", gCast).rect, gWvBgColor)
  398.           else
  399.             if sprite(47).rect = rect(68, 518, 87, 537) then
  400.               gWvBgShadow = gCurrentColor
  401.               member("weave - bg shadow", gCast).image.fill(member("weave - bg shadow", gCast).rect, gWvBgShadow)
  402.             else
  403.               if sprite(47).rect = rect(48, 543, 67, 562) then
  404.                 gWvVcolor = gCurrentColor
  405.                 member("weave - V color", gCast).image.fill(member("weave - V color", gCast).rect, gWvVcolor)
  406.               else
  407.                 if sprite(47).rect = rect(68, 543, 87, 562) then
  408.                   gWvVShadow = gCurrentColor
  409.                   member("weave - V shadow", gCast).image.fill(member("weave - V shadow", gCast).rect, gWvVShadow)
  410.                 else
  411.                   if sprite(47).rect = rect(48, 568, 67, 587) then
  412.                     gWvHcolor = gCurrentColor
  413.                     member("weave - H color", gCast).image.fill(member("weave - H color", gCast).rect, gWvHcolor)
  414.                   else
  415.                     if sprite(47).rect = rect(68, 568, 87, 587) then
  416.                       gWvHShadow = gCurrentColor
  417.                       member("weave - H shadow", gCast).image.fill(member("weave - H shadow", gCast).rect, gWvHShadow)
  418.                     else
  419.                       if sprite(47).rect = rect(593, 263, 617, 287) then
  420.                         member("palette transparency color", gCast).image.fill(member("palette transparency color", gCast).rect, gCurrentColor)
  421.                         sprite(1).bgColor = gCurrentColor
  422.                         sprite(20).bgColor = gCurrentColor
  423.                         sprite(261).bgColor = gCurrentColor
  424.                         sprite(262).bgColor = gCurrentColor
  425.                         sprite(263).bgColor = gCurrentColor
  426.                         sprite(264).bgColor = gCurrentColor
  427.                         sprite(47).rect = rect(598, 13, 622, 37)
  428.                       end if
  429.                     end if
  430.                   end if
  431.                 end if
  432.               end if
  433.             end if
  434.           end if
  435.         end if
  436.       end if
  437.       gCurrentColor = VOID
  438.     end if
  439.   end if
  440. end
  441.  
  442. on rightMouseUp
  443.   if (sprite(145).pState = 1) or (sprite(146).pState = 1) then
  444.     nothing()
  445.   else
  446.     pSprite.cursor = currentCursor
  447.     put EMPTY into field "red status"
  448.     put EMPTY into field "green status"
  449.     put EMPTY into field "blue status"
  450.     put EMPTY into field "hex status"
  451.     put EMPTY into field "paletteIndex status"
  452.   end if
  453. end
  454.  
  455. on mouseUpOutSide
  456.   if the rightMouseUp then
  457.     if (sprite(145).pState = 1) or (sprite(146).pState = 1) then
  458.       nothing()
  459.     else
  460.       pSprite.cursor = currentCursor
  461.       put EMPTY into field "red status"
  462.       put EMPTY into field "green status"
  463.       put EMPTY into field "blue status"
  464.       put EMPTY into field "hex status"
  465.       put EMPTY into field "paletteIndex status"
  466.     end if
  467.   end if
  468. end
  469.  
  470. on mFlood me, aX, aY, aSourceColor
  471.   targetColor = myCurrentImage.getPixel(aX, aY)
  472.   myCurrentImage.setPixel(aX, aY, aSourceColor)
  473.   append(pPixelActorListX, aX)
  474.   append(pPixelActorListY, aY)
  475.   repeat while count(pPixelActorListX)
  476.     xCur = getAt(pPixelActorListX, 1)
  477.     yCur = getAt(pPixelActorListY, 1)
  478.     deleteAt(pPixelActorListX, 1)
  479.     deleteAt(pPixelActorListY, 1)
  480.     repeat with n = 1 to 4
  481.       xTest = xCur + getAt(pSpreadListX, n)
  482.       yTest = yCur + getAt(pSpreadListY, n)
  483.       if myCurrentImage.getPixel(xTest, yTest) = targetColor then
  484.         myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  485.         append(pPixelActorListX, xTest)
  486.         append(pPixelActorListY, yTest)
  487.       end if
  488.     end repeat
  489.   end repeat
  490. end
  491.  
  492. on mFlood2 me, aX, aY, aSourceColor
  493.   targetColor = myCurrentImage.getPixel(aX, aY)
  494.   myCurrentImage.setPixel(aX, aY, aSourceColor)
  495.   append(pPixelActorListX, aX)
  496.   append(pPixelActorListY, aY)
  497.   repeat while count(pPixelActorListX)
  498.     xCur = getAt(pPixelActorListX, 1)
  499.     yCur = getAt(pPixelActorListY, 1)
  500.     deleteAt(pPixelActorListX, 1)
  501.     deleteAt(pPixelActorListY, 1)
  502.     repeat with n = 1 to 4
  503.       xTest = xCur + getAt(pSpreadListX, n)
  504.       yTest = yCur + getAt(pSpreadListY, n)
  505.       if myCurrentImage.getPixel(xTest, yTest) = targetColor then
  506.         if (((aX mod 2) = 1) and ((aY mod 2) = 0)) or (((aX mod 2) = 0) and ((aY mod 2) = 1)) then
  507.           if (((xTest mod 2) = 1) and ((yTest mod 2) = 0)) or (((xTest mod 2) = 0) and ((yTest mod 2) = 1)) then
  508.             myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  509.             append(pPixelActorListX, xTest)
  510.             append(pPixelActorListY, yTest)
  511.           else
  512.             myCurrentImage.setPixel(xTest, yTest, targetColor)
  513.             append(pPixelActorListX, xTest)
  514.             append(pPixelActorListY, yTest)
  515.           end if
  516.           next repeat
  517.         end if
  518.         if (((xTest mod 2) = 1) and ((yTest mod 2) = 0)) or (((xTest mod 2) = 0) and ((yTest mod 2) = 1)) then
  519.           myCurrentImage.setPixel(xTest, yTest, targetColor)
  520.           append(pPixelActorListX, xTest)
  521.           append(pPixelActorListY, yTest)
  522.           next repeat
  523.         end if
  524.         myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  525.         append(pPixelActorListX, xTest)
  526.         append(pPixelActorListY, yTest)
  527.       end if
  528.     end repeat
  529.   end repeat
  530. end
  531.