예제 #1
0
 private void SetRowColor(RGBi color, int rowNum)
 {
     for (int x = 0; x < squares.Length; ++x)
     {
         squares[x][rowNum].color   = color;
         squares[x][rowNum].isDirty = true;
     }
 }
예제 #2
0
 public static void InitializeClass()
 {
     disappearingColor = new RGBi[numDisappearingColors];
     for (int i = 0; i < disappearingColor.Length; ++i)
     {
         disappearingColor[i] = RGBi.Lerp(emptyColor, rowFilledColor, (double)i / numDisappearingColors);
     }
 }
예제 #3
0
    public static RGBi Lerp(RGBi color1, RGBi color2, double blend)
    {
        RGBi retColor = new RGBi(
            (int)(color1.r * (1.0 - blend) + color2.r * blend),
            (int)(color1.g * (1.0 - blend) + color2.g * blend),
            (int)(color1.b * (1.0 - blend) + color2.b * blend)
            );

        return(retColor);
    }
예제 #4
0
    public void Clear()
    {
        if (color != null)
        {
            isDirty = true;
        }

        color    = null;
        isActive = false;
    }
예제 #5
0
 public void SetColor(RGBi color, int x, int y, bool isActive)
 {
     if (IsValid(x, y))
     {
         if (squares[x][y].color != color)
         {
             squares[x][y].color    = color;
             squares[x][y].isDirty  = true;
             squares[x][y].isActive = isActive;
         }
     }
 }
예제 #6
0
    public void CopyFrom(Square other)
    {
        isDirty = isDirty || other.isDirty;

        if (color != other.color)
        {
            isDirty = true;
        }

        color    = other.color;
        isActive = false;
    }
예제 #7
0
 public void SetAllBlocksColor(RGBi color)
 {
     for (int x = 0; x < squares.Length; ++x)
     {
         for (int y = 0; y < squares[0].Length; ++y)
         {
             if (squares[x][y].color != null)
             {
                 squares[x][y].color    = color;
                 squares[x][y].isDirty  = true;
                 squares[x][y].isActive = false;
             }
         }
     }
 }
예제 #8
0
 public bool Equals(RGBi other)
 {
     return((r == other.r) &&
            (g == other.g) &&
            (b == other.b));
 }
예제 #9
0
파일: Block.cs 프로젝트: sskafandri/debtris
 private Block(bool[][] squares, RGBi color)
 {
     this.squares = squares;
     this.color   = color;
 }
예제 #10
0
파일: Block.cs 프로젝트: sskafandri/debtris
 public void SetType(int type)
 {
     squares = (bool[][])allBlockTypes[type].squares.Clone();
     color   = (RGBi)allBlockTypes[type].color;
 }
예제 #11
0
    public void Draw(bool isDrawingSquareLayer)
    {
        if (isDrawingSquareLayer)
        {
            psDoc.ActiveLayer = squareLayer;
        }
        else
        {
            psDoc.ActiveLayer = blockLayer;
        }

        // This unwrapped javascript code runs faster due to
        // suspendHistory capability in the javascript library.

        //have one subpath for each color
        Dictionary <RGBi, List <Pt2i> > colorSubpaths = new Dictionary <RGBi, List <Pt2i> >();

        //Take all dirtied squares and add to respective color subpath
        for (int y = 0; y < numSquaresY; ++y)
        {
            for (int x = 0; x < numSquaresX; ++x)
            {
                if (squares[x][y].isDirty)
                {
                    int  xBrushLoc = boardX + x * (squareSize + squareSpacing) + squareSize / 2;
                    int  yBrushLoc = boardY + y * (squareSize + squareSpacing) + squareSize / 2;
                    RGBi colorKey  = squares[x][y].color;

                    if (colorKey == null)
                    {
                        colorKey = Square.emptyColor;
                    }

                    if (!colorSubpaths.ContainsKey(colorKey))
                    {
                        colorSubpaths[colorKey] = new List <Pt2i>();
                    }

                    colorSubpaths[colorKey].Add(new Pt2i(xBrushLoc, yBrushLoc));
                    squares[x][y].isDirty = false;
                }
            }
        }

        javascriptBuffer.Append("activeDocument.suspendHistory(\"DrawBoard\",\"");

        //Loop through all colors and stroke the subpaths
        int i = 0;

        foreach (KeyValuePair <RGBi, List <Pt2i> > colorSubpathEntry in colorSubpaths)
        {
            //if drawing square layer, then only draw when RGBi is empty color
            if (isDrawingSquareLayer && colorSubpathEntry.Key != Square.emptyColor)
            {
                continue;
            }

            RGBi   strokeColor  = colorSubpathEntry.Key;
            Pt2i[] colorSubpath = colorSubpathEntry.Value.ToArray();

            if (colorSubpath.Length > 0)
            {
                for (int j = 0; j < colorSubpath.Length; ++j)
                {
                    javascriptBuffer.Append("var lineArray" + i + "_" + j + " = new Array(); ");
                    javascriptBuffer.Append("lineArray" + i + "_" + j + "[0] = new PathPointInfo; ");
                    javascriptBuffer.Append("lineArray" + i + "_" + j + "[0].kind = PointKind.CORNERPOINT; ");
                    javascriptBuffer.Append("lineArray" + i + "_" + j + "[0].anchor = Array(" + colorSubpath[j].x + ", " + colorSubpath[j].y + "); ");
                    javascriptBuffer.Append("lineArray" + i + "_" + j + "[0].leftDirection = lineArray" + i + "_" + j + "[0].anchor; ");
                    javascriptBuffer.Append("lineArray" + i + "_" + j + "[0].rightDirection = lineArray" + i + "_" + j + "[0].anchor; ");
                }

                javascriptBuffer.Append("var lineSubPathArray" + i + " = new Array(); ");

                for (int j = 0; j < colorSubpath.Length; ++j)
                {
                    javascriptBuffer.Append("lineSubPathArray" + i + "[" + j + "] = new SubPathInfo(); ");
                    javascriptBuffer.Append("lineSubPathArray" + i + "[" + j + "].operation = ShapeOperation.SHAPEXOR; ");
                    javascriptBuffer.Append("lineSubPathArray" + i + "[" + j + "].closed = false; ");
                    javascriptBuffer.Append("lineSubPathArray" + i + "[" + j + "].entireSubPath = lineArray" + i + "_" + j + "; ");
                }

                //create the path item
                javascriptBuffer.Append("var myPathItem" + i + " = activeDocument.pathItems.add(\\\"Color" + i + "\\\", lineSubPathArray" + i + "); ");

                //Stroke it so we can see something.
                // if drawing block layer and RGBi is empty color, then use eraser
                if (!isDrawingSquareLayer && colorSubpathEntry.Key == Square.emptyColor)
                {
                    javascriptBuffer.Append("myPathItem" + i + ".strokePath(ToolType.ERASER); ");
                }
                // otherwise, use pencil
                else
                {
                    //set foreground color
                    javascriptBuffer.Append("app.foregroundColor.rgb.hexValue = \'" + strokeColor.ToHexString() + "\'; ");
                    javascriptBuffer.Append("myPathItem" + i + ".strokePath(ToolType.PENCIL); ");
                }
            }
            ++i;
        }

        javascriptBuffer.Append("activeDocument.pathItems.removeAll(); ");
        javascriptBuffer.Append("\")");

        try { psApp.DoJavaScript(javascriptBuffer.ToString()); }
        catch (Exception) { }

        javascriptBuffer.Clear();
    }
예제 #12
0
 public Square()
 {
     color    = null;
     isDirty  = true;
     isActive = false;
 }