/// <summary> /// Grid Range constructor /// </summary> /// <param name="address1">The first corner of the range.</param> /// <param name="address2">The opposite corner of the range.</param> public GridRange(GridAddress address1, GridAddress address2) { int lowRow; int lowCol; int highRow; int highCol; if (address1.Row < address2.Row) { lowRow = address1.Row; highRow = address2.Row; } else { lowRow = address2.Row; highRow = address1.Row; } if (address1.Column < address2.Column) { lowCol = address1.Column; highCol = address2.Column; } else { lowCol = address2.Column; highCol = address1.Column; } _bottomLeft = new GridAddress(lowRow, lowCol); _topRight = new GridAddress(highRow, highCol); _topLeft = new GridAddress(highRow, lowCol); _bottomRight = new GridAddress(lowRow, highCol); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Color areaColor = Color.FromArgb(50, 130, 190); GridAddress address = new GridAddress(1, 1); int width = 1000; int height = 500; string yAxisLabel = "Label"; int tickMarks = 2; Margins margins = new Margins(); DA.GetData <Color>(0, ref areaColor); DA.GetData <GridAddress>(1, ref address); DA.GetData <Margins>(2, ref margins); DA.GetData <int>(3, ref width); DA.GetData <int>(4, ref height); DA.GetData <string>(5, ref yAxisLabel); DA.GetData <int>(6, ref tickMarks); // create style D3jsLib.d3AreaCharts.AreaChartStyle style = new D3jsLib.d3AreaCharts.AreaChartStyle(); style.AreaColor = areaColor; style.GridRow = address.X; style.GridColumn = address.Y; style.Width = width; style.Height = height; style.YAxisLabel = yAxisLabel; style.TickMarksX = tickMarks; style.Margins = margins; DA.SetData(0, style); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { List <Color> colors = new List <Color>(); GridAddress address = new GridAddress(1, 1); int width = 1000; DA.GetData <GridAddress>(1, ref address); DA.GetData <int>(2, ref width); // create style ScatterPlotMatrixStyle style = new ScatterPlotMatrixStyle(); if (DA.GetDataList <Color>(0, colors)) { List <string> hexColors = colors.Select(x => ChartsUtilities.ColorToHexString(Color.FromArgb(x.A, x.R, x.G, x.B))).ToList(); style.Colors = hexColors; } else { style.Colors = null; } style.GridRow = address.X; style.GridColumn = address.Y; style.Width = width; DA.SetData(0, style); }
public void AddStreetAtPoint(StreetSegment seg, Vector2 pt) { GridAddress addr = new GridAddress(pt); if (!addressToStreetSegmentIdListDict.ContainsKey(addr)) { addressToStreetSegmentIdListDict[addr] = new List <int>(); } int streetSegmentId = -1; if (!StreetSegmentIdToStreetSegmentDict.ContainsValue(seg)) { streetSegmentId = nextStreetSegmentId++; StreetSegmentIdToStreetSegmentDict[streetSegmentId] = seg; } else { foreach (int segId in StreetSegmentIdToStreetSegmentDict.Keys) { if (seg == StreetSegmentIdToStreetSegmentDict[segId]) { streetSegmentId = segId; break; } } } if (!addressToStreetSegmentIdListDict[addr].Contains(streetSegmentId)) { addressToStreetSegmentIdListDict[addr].Add(streetSegmentId); } }
/// <summary> /// Line Chart Style object. /// </summary> /// <param name="Address">Grid Coordinates.</param> /// <param name="Margins">Margins in pixels.</param> /// <param name="Width">Width of the entire chart in pixels.</param> /// <param name="Height">Height of the entire chart in pixels.</param> /// <param name="YAxisLabel">Text used to label Y Axis.</param> /// <param name="LineColor">Color for Line Chart Line.</param> /// <param name="TickMarksX">Approximate number of tick mark values for X Axis.</param> /// <returns name="Style">Line Chart Style.</returns> /// <search>line, style</search> public static LineChartStyle Style( [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color LineColor, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins, int Width = 1000, int Height = 500, string YAxisLabel = "Label", int TickMarksX = 10) { LineChartStyle style = new LineChartStyle(); style.Width = Width; style.Height = Height; style.YAxisLabel = YAxisLabel; style.LineColor = sColor.FromArgb(LineColor.Alpha, LineColor.Red, LineColor.Green, LineColor.Blue); style.TickMarksX = TickMarksX; style.Margins = Margins; if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Color lineColor = Color.FromArgb(50, 130, 190); GridAddress address = new GridAddress(1, 1); Margins margins = new Margins(); int width = 1000; int height = 500; DA.GetData <Color>(0, ref lineColor); DA.GetData <GridAddress>(1, ref address); DA.GetData <Margins>(2, ref margins); DA.GetData <int>(3, ref width); DA.GetData <int>(4, ref height); // create style ParallelCoordinatesStyle style = new ParallelCoordinatesStyle(); style.LineColor = ChartsUtilities.ColorToHexString(lineColor); style.GridRow = address.X; style.GridColumn = address.Y; style.Width = width; style.Height = height; style.Margins = margins; style.SizeX = (int)Math.Ceiling(width / 100d); style.SizeY = (int)Math.Ceiling(height / 100d); DA.SetData(0, style); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Color barColor = Color.FromArgb(50, 130, 190); Color hoverColor = Color.FromArgb(255, 0, 0); GridAddress address = new GridAddress(1, 1); int width = 1000; int height = 500; string xAxisLabel = "Label"; Margins margins = new Margins(); DA.GetData <Color>(0, ref barColor); DA.GetData <Color>(1, ref hoverColor); DA.GetData <GridAddress>(2, ref address); DA.GetData <Margins>(3, ref margins); DA.GetData <int>(4, ref width); DA.GetData <int>(5, ref height); DA.GetData <string>(6, ref xAxisLabel); // create style HorizontalBarChartStyle style = new HorizontalBarChartStyle(); style.BarColor = barColor; style.BarHoverColor = hoverColor; style.GridRow = address.X; style.GridColumn = address.Y; style.Width = width; style.Height = height; style.YAxisLabel = xAxisLabel; style.Margins = margins; DA.SetData(0, style); }
/// <summary> /// Image Style object /// </summary> /// <param name="Address">Grid Coordinates.</param> /// <param name="Width">Width of the image.</param> /// <param name="Height">Height of the image.</param> /// <param name="Tooltip">Tooltip message that will appear when you hover over image.</param> /// <returns name="Style">Style object.</returns> /// <search>image style, style</search> public static ImageStyle Style( [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, int Width = 150, int Height = 150, string Tooltip = "") { ImageStyle style = new ImageStyle(); style.Width = Width; style.Height = Height; style.Tooltip = Tooltip; if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }
/// <summary> /// Horizontal Bar Chart Style /// </summary> /// <param name="BarColor">Fill color for bars.</param> /// <param name="BarHoverColor">Fill color when hovered over.</param> /// <param name="Address">Grid Coordinates.</param> /// <param name="Margins">Margins in pixels.</param> /// <param name="Width">Width of the entire chart in pixels.</param> /// <param name="Height">Height of the entire chart in pixels.</param> /// <param name="XAxisLabel">Text displayed in bottom-right corner of chart.</param> /// <returns name="Style">Style</returns> public static HorizontalBarChartStyle Style( [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color BarColor, [DefaultArgument("DSCore.Color.ByARGB(1,255,0,0)")] DSCore.Color BarHoverColor, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, [DefaultArgument("Charts.MiscNodes.Margins(20,40,20,40)")] Margins Margins, int Width = 1000, int Height = 500, string XAxisLabel = "Label") { HorizontalBarChartStyle style = new HorizontalBarChartStyle(); style.BarColor = sColor.FromArgb(BarColor.Alpha, BarColor.Red, BarColor.Green, BarColor.Blue); style.BarHoverColor = sColor.FromArgb(BarHoverColor.Alpha, BarHoverColor.Red, BarHoverColor.Green, BarHoverColor.Blue); style.Width = Width; style.Height = Height; style.YAxisLabel = XAxisLabel; style.Margins = Margins; if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Color dotColor = Color.FromArgb(50, 130, 190); GridAddress address = new GridAddress(1, 1); Margins margins = new Margins(); int width = 1000; int height = 500; string yAxisLabel = "LabelY"; string xAxisLabel = "LabelX"; DA.GetData <Color>(0, ref dotColor); DA.GetData <GridAddress>(1, ref address); DA.GetData <Margins>(2, ref margins); DA.GetData <int>(3, ref width); DA.GetData <int>(4, ref height); DA.GetData <string>(5, ref yAxisLabel); DA.GetData <string>(6, ref xAxisLabel); // create style ScatterPlotStyle style = new ScatterPlotStyle(); style.DotColor = dotColor; style.GridRow = address.X; style.GridColumn = address.Y; style.Margins = margins; style.Width = width; style.Height = height; style.YAxisLabel = yAxisLabel; style.XAxisLabel = xAxisLabel; DA.SetData(0, style); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Color fontColor = Color.FromArgb(0, 0, 0); GridAddress address = new GridAddress(1, 1); int width = 200; int height = 100; double fontSize = 20.0; string fontWeight = "1"; string fontStyle = "1"; string fontTransform = "1"; DA.GetData <Color>(0, ref fontColor); DA.GetData <GridAddress>(1, ref address); DA.GetData <int>(2, ref width); DA.GetData <int>(3, ref height); DA.GetData <double>(4, ref fontSize); DA.GetData <string>(5, ref fontWeight); DA.GetData <string>(6, ref fontStyle); DA.GetData <string>(7, ref fontTransform); TextStyle style = new TextStyle(); style.FontSize = fontSize; style.FontColor = fontColor; style.FontWeight = ((D3jsLib.Text.FontWeights) int.Parse(fontWeight)).ToString(); style.FontStyle = ((D3jsLib.Text.FontStyle) int.Parse(fontStyle)).ToString(); style.FontTransform = ((D3jsLib.Text.FontTransform) int.Parse(fontTransform)).ToString(); style.Width = width; style.Height = height; style.GridRow = address.X; style.GridColumn = address.Y; DA.SetData(0, style); }
/// <summary> /// Area Chart Style object. /// </summary> /// <param name="Address">Grid Coordinates.</param> /// <param name="Margins">Marings in pixels.</param> /// <param name="Width">Width of the entire chart in pixels.</param> /// <param name="Height">Height of the entire chart in pixels.</param> /// <param name="YAxisLabel">Text used to label Y Axis.</param> /// <param name="AreaColor">Color for Area Chart fill.</param> /// <param name="TickMarksX">Approximate number of tick marks on X Axis.</param> /// <returns name="Style">Area Chart Style.</returns> /// <search>area, chart, style</search> public static AreaChartStyle Style( [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color AreaColor, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, [DefaultArgument("Charts.MiscNodes.Margins(20,40,20,40)")] Margins Margins, int Width = 1000, int Height = 500, string YAxisLabel = "Label", int TickMarksX = 10) { AreaChartStyle style = new AreaChartStyle(); style.Width = Width; style.Height = Height; style.YAxisLabel = YAxisLabel; style.AreaColor = ChartsUtilities.ColorToHexString(sColor.FromArgb(AreaColor.Alpha, AreaColor.Red, AreaColor.Green, AreaColor.Blue)); style.TickMarksX = TickMarksX; style.Margins = Margins; style.SizeX = (int)Math.Ceiling(Width / 100d); style.SizeY = (int)Math.Ceiling(Height / 100d); if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Color lineColor = Color.FromArgb(50, 130, 190); GridAddress address = new GridAddress(1, 1); int width = 1000; int height = 500; string yAxisLabel = "Label"; int tickMarks = 2; Margins margins = new Margins(); DA.GetData <Color>(0, ref lineColor); DA.GetData <GridAddress>(1, ref address); DA.GetData <Margins>(2, ref margins); DA.GetData <int>(3, ref width); DA.GetData <int>(4, ref height); DA.GetData <string>(5, ref yAxisLabel); DA.GetData <int>(6, ref tickMarks); // create style LineChartStyle style = new LineChartStyle(); style.LineColor = ChartsUtilities.ColorToHexString(lineColor); style.GridRow = address.X; style.GridColumn = address.Y; style.Width = width; style.Height = height; style.YAxisLabel = yAxisLabel; style.TickMarksX = tickMarks; style.Margins = margins; style.SizeX = (int)Math.Ceiling(width / 100d); style.SizeY = (int)Math.Ceiling(height / 100d); DA.SetData(0, style); }
/// <summary> /// Scatter Plot Style. /// </summary> /// <param name="Address">Grid Coordinates.</param> /// <param name="Margins">Margins in pixels.</param> /// <param name="Width">Width in pixels.</param> /// <param name="Height">Height in pixels.</param> /// <param name="YAxisLabel">Label displayed for Y Axis.</param> /// <param name="XAxisLabel">Label displayed for X Axis.</param> /// <param name="DotColor">Color of Scatter Plot dot.</param> /// <returns name="Style">Scatter Plot Style.</returns> /// <search>style, scatter plot</search> public static ScatterPlotStyle Style( [DefaultArgument("DSCore.Color.ByARGB(1,100,100,100)")] DSCore.Color DotColor, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins, int Width = 1000, int Height = 500, string YAxisLabel = "Label", string XAxisLabel = "Label") { ScatterPlotStyle style = new ScatterPlotStyle(); style.Width = Width; style.Height = Height; style.YAxisLabel = YAxisLabel; style.XAxisLabel = XAxisLabel; style.DotColor = sColor.FromArgb(DotColor.Alpha, DotColor.Red, DotColor.Green, DotColor.Blue); style.Margins = Margins; if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return style; }
/// <summary> /// Style /// </summary> /// <param name="Colors">List of Colors.</param> /// <param name="Address">Grid Coordinates.</param> /// <param name="Width">Width in pixels.</param> /// <returns name="Style">Style</returns> public static ScatterPlotMatrixStyle Style( [DefaultArgumentAttribute("Charts.MiscNodes.GetNull()")] List <DSCore.Color> Colors, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, int Width = 1000 ) { ScatterPlotMatrixStyle style = new ScatterPlotMatrixStyle(); style.Width = Width; if (Colors != null) { List <string> hexColors = Colors.Select(x => ChartsUtilities.ColorToHexString(sColor.FromArgb(x.Alpha, x.Red, x.Green, x.Blue))).ToList(); style.Colors = hexColors; } else { style.Colors = null; } if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }
void AddStreetRange(StreetSegment seg, float f0, float f1) { //Debug.Log(string.Format("Adding segment with values {0} {1}", f0, f1)); Vector2 v0 = seg.InterpolateEndpoints(f0); Vector2 v1 = seg.InterpolateEndpoints(f1); GridAddress a0 = new GridAddress(v0); GridAddress a1 = new GridAddress(v1); if (a0 == a1) { //Debug.Log(string.Format("Adding segment at location {0}", a0)); AddStreetAtPoint(seg, v0); } else if ((Mathf.Abs(a0.x - a1.x) <= 1) && (Mathf.Abs(a0.y - a1.y) <= 1)) { //Debug.Log(string.Format("Adding segment at locations {0} and {1}", a0, a1)); AddStreetAtPoint(seg, v0); AddStreetAtPoint(seg, v1); } else { float fh = (f0 + f1) / 2.0f; AddStreetRange(seg, f0, fh); AddStreetRange(seg, fh, f1); } }
/// <summary> /// Bar Chart Style object. /// </summary> /// <param name="BarColor">Fill color for bars.</param> /// <param name="BarHoverColor">Fill color when hovered over.</param> /// <param name="Address">Grid Coordinates.</param> /// <param name="Margins">Margins in pixels.</param> /// <param name="Width">Width of the entire chart in pixels.</param> /// <param name="Height">Height of the entire chart in pixels.</param> /// <param name="YAxisLabel">Text displayed in top-left corner of chart.</param> /// <param name="TickMarksX">Approximate number of tick mark values for X Axis.</param> /// <param name="xTextRotation">Indicates if labels along x-axis are rotated.</param> /// <returns name="Style">Bar Chart Style.</returns> /// <search>bar, chart, style</search> public static BarStyle Style( [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color BarColor, [DefaultArgument("DSCore.Color.ByARGB(1,255,0,0)")] DSCore.Color BarHoverColor, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, [DefaultArgument("Charts.MiscNodes.Margins(20,40,20,40)")] Margins Margins, int Width = 1000, int Height = 500, string YAxisLabel = "Label", int TickMarksX = 10, bool xTextRotation = false) { BarStyle style = new BarStyle(); style.BarColor = sColor.FromArgb(BarColor.Alpha, BarColor.Red, BarColor.Green, BarColor.Blue); style.BarHoverColor = sColor.FromArgb(BarHoverColor.Alpha, BarHoverColor.Red, BarHoverColor.Green, BarHoverColor.Blue); style.Width = Width; style.Height = Height; style.YAxisLabel = YAxisLabel; style.TickMarksX = TickMarksX; style.xTextRotation = xTextRotation; style.Margins = Margins; if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }
/// <summary> /// Create Text Style /// </summary> /// <param name="FontColor">Color</param> /// <param name="Address">Grid Coordinates</param> /// <param name="Width">Width of Grid container.</param> /// <param name="Height">Height of Grid Container.</param> /// <param name="FontSize">Size</param> /// <param name="FontWeight">Weight</param> /// <param name="FontStyle">Style</param> /// <param name="FontTransform">Transform</param> /// <returns name="Style">Style for the Text Note object</returns> public static TextStyle Style( [DefaultArgument("DSCore.Color.ByARGB(1,0,0,0)")] Color FontColor, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, int Width = 200, int Height = 100, double FontSize = 20.0, string FontWeight = "normal", string FontStyle = "normal", string FontTransform = "none") { TextStyle style = new TextStyle(); style.FontSize = FontSize; style.FontColor = ChartsUtilities.ColorToHexString(sColor.FromArgb(FontColor.Alpha, FontColor.Red, FontColor.Green, FontColor.Blue)); style.FontWeight = FontWeight; style.FontStyle = FontStyle; style.FontTransform = FontTransform; style.Width = Width; style.Height = Height; style.SizeX = (int)System.Math.Ceiling(Width / 100d); style.SizeY = (int)System.Math.Ceiling(Height / 100d); if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }
/// <summary> /// Parallel Coordinates Style object. /// </summary> /// <param name="LineColor">Color of the selected Lines/Values.</param> /// <param name="Address">Grid Coordinates.</param> /// <param name="Margins">Margins in pixels.</param> /// <param name="Width">Width of the Chart in pixels.</param> /// <param name="Height">Height of the Chart in pixels.</param> /// <returns name="Style">Parallel Coordinates Style.</returns> /// <search>parallel, coordinates, style</search> public static ParallelCoordinatesStyle Style( [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color LineColor, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins, int Width = 1000, int Height = 500) { ParallelCoordinatesStyle style = new ParallelCoordinatesStyle(); style.Width = Width; style.Height = Height; style.LineColor = ChartsUtilities.ColorToHexString(sColor.FromArgb(LineColor.Alpha, LineColor.Red, LineColor.Green, LineColor.Blue)); style.Margins = Margins; style.SizeX = (int)Math.Ceiling(Width / 100d); style.SizeY = (int)Math.Ceiling(Height / 100d); if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }
public List <StreetSegment> GetSegmentsNear(Vector2 point, float radius) { List <int> segmentIds = new List <int>(); for (float fx = point.x - radius; fx < point.x + radius + GridAddress.Resolution; fx += GridAddress.Resolution) { for (float fy = point.y - radius; fy < point.y + radius + GridAddress.Resolution; fy += GridAddress.Resolution) { GridAddress addr = new GridAddress(fx, fy); if (addressToStreetSegmentIdListDict.ContainsKey(addr)) { foreach (int segId in addressToStreetSegmentIdListDict[addr]) { if (!segmentIds.Contains(segId)) { segmentIds.Add(segId); } } } } } List <StreetSegment> segments = new List <StreetSegment>(); foreach (int segId in segmentIds) { segments.Add(StreetSegmentIdToStreetSegmentDict[segId]); } return(segments); }
/*------------------------------------------------------------------------------------------------------------------*/ /********************************************************************************************************************/ /*************************************************** Behaviours *****************************************************/ /********************************************************************************************************************/ /*------------------------------------------------------------------------------------------------------------------*/ /// <summary> /// Initializes the mask to a specified number of rows and columns, off set by a specified amount. /// </summary> /// <param name="rows">The number of rows in the mask.</param> /// <param name="columns">The number of columns in the mask.</param> /// <param name="rowOffset">The number of rows to offset the mask by.</param> /// <param name="colOffset">The number of columns to offset the mask by.</param> public void Initialize(int rows, int columns, float rowOffset, float colOffset) { Rows = rows; Columns = columns; selectionTiles = new SelectionTile[rows, columns]; maskBarrier.transform.localScale = new Vector3(columns, rows, 1); Transform tileHolder = transform.Find("MaskTiles"); for (int row = 0; row < rows; row++) { for (int col = 0; col < columns; col++) { GridAddress address = new GridAddress(row, col); GameObject t = Instantiate(maskTile, tileHolder); t.transform.localPosition = new Vector3(col + colOffset, row + rowOffset, 0); selectionTiles[row, col] = t.GetComponent <SelectionTile>(); selectionTiles[row, col].Address = address; selectionTiles[row, col].Mask = this; t.SetActive(false); } } gameObject.SetActive(false); }
public void SetSelectionMask(List <GameTile> tiles) { GridAddress[] addresses = new GridAddress[tiles.Count]; for (int i = 0; i < tiles.Count; i++) { addresses[i] = tiles[i].Address; } SelectMask.SetSelectionMask(addresses); }
public override bool Equals(object otherObj) { GridAddress otherAddress = otherObj as GridAddress; if (otherAddress == null) { return(false); } return((otherAddress.x == this.x) && (otherAddress.y == this.y)); }
/// <summary> /// Gets whether or not a specific tile is active (ie. selectable) /// </summary> /// <param name="address">The address of the tile to check.</param> /// <returns>True if the tile is selectable, false if it is not.</returns> public bool GetSelectionTileActive(GridAddress address) { if (!IsValidTile(address.Row, address.Column)) { Debug.Log("Invalid tile selected for GetSelectionTileActive"); return(false); } return(selectionTiles[address.Row, address.Column].gameObject.activeSelf); }
public void ToggleSelectionTile(GridAddress address) { if (SelectMask.GetSelectionTileActive(address)) { SelectMask.DisableSelectionTile(address); } else { SelectMask.EnableSelectionTile(address); } }
/// <summary> /// Checks if a given address is within this GridRange. /// </summary> /// <param name="address">The address to check.</param> /// <returns>True if the address is within the GridRange. False if not.</returns> public bool IsWithin(GridAddress address) { if (address.Row <= TopLeft.Row && address.Row >= BottomRight.Row && address.Column >= TopLeft.Column && address.Column <= BottomRight.Column) { return(true); } else { return(false); } }
/// <summary> /// Removes a specified GridAddress from the selectableTiles list. /// </summary> /// <param name="address"></param> private void RemoveSelectableTile(GridAddress address) { for (int i = 0; i < selectableTiles.Count; i++) { if (selectableTiles[i].Equals(address)) { selectableTiles.RemoveAt(i); i--; } } gameBoard.ToggleSelectionTile(address); }
/// <summary> /// Selects the specified tile. /// Raises the TileSelected event using the passed tile. /// </summary> /// <param name="address">The address of the tile to select.</param> public void SelectTile(GridAddress address) { if (!IsValidTile(address)) { Debug.LogError("Attempting to select invalid tile at address " + address.ToString()); return; } if (!GetSelectionTileActive(address)) { Debug.LogError("Attempting to select in active tile at address " + address.ToString()); return; } SelectTile(selectionTiles[address.Row, address.Column]); }
/// <summary> /// Legend Style /// </summary> /// <param name="Colors">List of colors for each rectangle.</param> /// <param name="Address">Grid Coordinates.</param> /// <param name="Width">Width in pixels.</param> /// <param name="Height">Height in pixels.</param> /// <param name="Title">Title below legend.</param> /// <param name="RectangleSize">Rectangle size in pixels.</param> /// <returns name="Style">Style</returns> public static LegendStyle Style( [DefaultArgumentAttribute("Charts.MiscNodes.GetNull()")] List <DSCore.Color> Colors, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, int Width = 200, int Height = 400, string Title = "Title", int RectangleSize = 20 ) { LegendStyle style = new LegendStyle(); style.Width = Width; style.Height = Height; style.Title = Title; style.RectangleSize = RectangleSize; if (Colors != null) { List <string> hexColors = new List <string>(); foreach (DSCore.Color color in Colors) { string col = ChartsUtilities.ColorToHexString(sColor.FromArgb(color.Alpha, color.Red, color.Green, color.Blue)); hexColors.Add(col); } style.Colors = hexColors; } else { style.Colors = null; } if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }
/// <summary> /// Grouped Bar Chart Style. /// </summary> /// <param name="BarHoverColor">Hover over color.</param> /// <param name="Address">Grid Coordinates</param> /// <param name="Margins">Margins in pixels.</param> /// <param name="Width">Width in pixels.</param> /// <param name="Height">Height in pixels.</param> /// <param name="YAxisLabel">Label for Y-Axis.</param> /// <param name="Colors">Optional list of colors for each group.</param> /// <returns name="Style">Bar Chart Style object.</returns> /// <search>grouped, bar, chart, style</search> public static GroupedBarChartStyle Style( [DefaultArgument("DSCore.Color.ByARGB(1,255,0,0)")] DSCore.Color BarHoverColor, [DefaultArgumentAttribute("Charts.MiscNodes.GetNull()")] List <DSCore.Color> Colors, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins, int Width = 1000, int Height = 500, string YAxisLabel = "Label" ) { GroupedBarChartStyle style = new GroupedBarChartStyle(); style.Width = Width; style.Height = Height; style.YAxisLabel = YAxisLabel; style.BarHoverColor = ChartsUtilities.ColorToHexString(sColor.FromArgb(BarHoverColor.Alpha, BarHoverColor.Red, BarHoverColor.Green, BarHoverColor.Blue)); style.Margins = Margins; style.SizeX = (int)Math.Ceiling(Width / 100d); style.SizeY = (int)Math.Ceiling(Height / 100d); if (Colors != null) { List <string> hexColors = Colors.Select(x => ChartsUtilities.ColorToHexString(sColor.FromArgb(x.Alpha, x.Red, x.Green, x.Blue))).ToList(); style.Colors = new JavaScriptSerializer().Serialize(hexColors); } else { style.Colors = null; } if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }