Exemplo n.º 1
0
		static void Main(string[] args)
		{
			VectorDesign design = VectorDesign.Load(@"SetPrimaryAndSecondaryColours.PV", VectorDesignFileTypes.Pv);

			// Replace all spot colours called "Primary" with red, and "Secondary" with blue

			// VectorDesign.ProcessColours with iterate through all colours of all objects
			// in the design calling the supplied delegate passing each colour as the single parameter.
			// The return value is the new (or old) colour to use to replace the pre-exising one.
			design.ProcessColours((c) =>
			{
				if (c is SpotColour)
				{
					SpotColour s = (SpotColour)c;

					switch (s.Name)
					{
						case "Primary":
							c = new SpotColour(s.Name, s.Tint, new RGBColour(255, 0, 0));
							break;
						case "Secondary":
							c = new SpotColour(s.Name, s.Tint, new RGBColour(0, 0, 255));
							break;
						default:
							// Otherwise no change to colour
							break;
					}
				}

				return c;
			});

			design.Render(@"SetPrimaryAndSecondaryColours.PNG", RenderFormats.Png, 96, design.ColourContext);
		}
Exemplo n.º 2
0
        /// <summary>Return a colour for the given snap type</summary>
        private Colour32 SnapTypeToColour(View3d.ESnapType snap_type)
        {
            switch (snap_type)
            {
            default:
                throw new Exception($"Unknown snap type: {snap_type}");

            case View3d.ESnapType.Vert:
            case View3d.ESnapType.EdgeCentre:
            case View3d.ESnapType.FaceCentre:
            case View3d.ESnapType.Edge:
                return(SpotColour);

            case View3d.ESnapType.Face:
                return(SpotColour.Lerp(0xFF000000, 0.4f));
            }
        }