• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Gradient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Gradient的典型用法代码示例。如果您正苦于以下问题:C# Gradient类的具体用法?C# Gradient怎么用?C# Gradient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Gradient类属于命名空间,在下文中一共展示了Gradient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Update

	// Update is called once per frame
	void Update () {
    if (timer == 0) {
      LastColor = SoupMaterial.color;
    }

    if (!NextColor.Equals(SoupMaterial.color)) {
      timer += Time.deltaTime;
      Color c = Color.Lerp(LastColor, NextColor, timer / duration);
      SoupMaterial.color = c;
      SoupLight.color = c;
      SoupLight.intensity = Mathf.Max(1.5f * (duration - timer), 1);

      var col = Smoke.colorOverLifetime;
      col.enabled = true;

      Gradient grad = new Gradient();
      grad.SetKeys( new GradientColorKey[] { new GradientColorKey(c, 0.0f), new GradientColorKey(Color.gray, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f) } );

      col.color = new ParticleSystem.MinMaxGradient(grad);

      if (timer >= duration) {
        SoupMaterial.color = NextColor;
        SoupLight.intensity = 1;
        timer = 0;
      }
    }
	}
开发者ID:HarrisonHough,项目名称:TheCauldrenRepo,代码行数:28,代码来源:SoupColor.cs


示例2: Start

    // Use this for initialization
    void Start()
    {
        //activated = true;
        //cachedY = timeTransform.position.y;

        minXValue = 0;
        maxXValue = timeTransform.rect.width;

        //currentTime = maxTime;
        g = new Gradient();

        // Populate the color keys at the relative time 0 and 1 (0 and 100%)
        gck = new GradientColorKey[3];
        gck[0].color = new Color32(9,183,62,1);
        gck[0].time = 0.0f;
        gck[1].color = new Color32(255,228,0,1);
        gck[1].time = 0.5f;
        gck[2].color = new Color32(219,101,63,1);
        gck[2].time = 1.0f;

        // Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
        gak = new GradientAlphaKey[2];
        gak[0].alpha = 1.0f;
        gak[0].time = 0.0f;
        gak[1].alpha = 1.0f;
        gak[1].time = 1.0f;
        g.SetKeys(gck, gak);

        CurrentTime = maxTime;
    }
开发者ID:daolf,项目名称:flyhigher,代码行数:31,代码来源:TimeBarscript.cs


示例3: LoadData

        private void LoadData(object sender, EventArgs e)
        {
            Gradient gradient = new Gradient(9, 0.01, 2.0, 10, 1.5);

            chart1.Series["Series1"].ChartType = SeriesChartType.Spline;

            gradient.SetStartPoint();

            double length = 0.0;
            int i = 0;
            do 
            {
                length = gradient.GetNext();
                chart1.Series["Series1"].Points.AddXY(i, length);
                i++;
            } while (length > epsilon && i < maxIteration);

            Console.WriteLine("\nIteration = " + (i - 1));
            Console.WriteLine("Distance between atoms = " + gradient.GetPoint() + "\n");

            chart1.ChartAreas[0].AxisX.Minimum = 0;
            chart1.ChartAreas[0].AxisY.Minimum = 0;

            chart1.Update();
        }
开发者ID:LukaszZapala,项目名称:Simulation-Methods-in-Nanotechnology,代码行数:25,代码来源:ChartView.cs


示例4: GradientPresets

        /// <summary>
        /// Initializes a new instance of Gradient.
        /// </summary>
        static GradientPresets()
        {
            // Grayscale gradient color keys
            var grayscaleColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(Color.black, 0),
                new GradientColorKey(Color.white, 1)
            };

            // RGB gradient color keys
            var rgbColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(Color.red, 0),
                new GradientColorKey(Color.green, 0.5f),
                new GradientColorKey(Color.blue, 1)
            };

            // RGBA gradient color keys
            var rgbaColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(Color.red, 0),
                new GradientColorKey(Color.green, 1 / 3f),
                new GradientColorKey(Color.blue, 2 / 3f),
                new GradientColorKey(Color.black, 1)
            };

            // RGBA gradient alpha keys
            var rgbaAlphaKeys = new List<GradientAlphaKey> {new GradientAlphaKey(0, 2 / 3f), new GradientAlphaKey(1, 1)};

            // Terrain gradient color keys
            var terrainColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(new Color(0, 0, 0.5f), 0),
                new GradientColorKey(new Color(0.125f, 0.25f, 0.5f), 0.4f),
                new GradientColorKey(new Color(0.25f, 0.375f, 0.75f), 0.48f),
                new GradientColorKey(new Color(0, 0.75f, 0), 0.5f),
                new GradientColorKey(new Color(0.75f, 0.75f, 0), 0.625f),
                new GradientColorKey(new Color(0.625f, 0.375f, 0.25f), 0.75f),
                new GradientColorKey(new Color(0.5f, 1, 1), 0.875f),
                new GradientColorKey(Color.white, 1)
            };

            // Generic gradient alpha keys
            var alphaKeys = new List<GradientAlphaKey> {new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1)};

            _empty = new Gradient();

            _rgb = new Gradient();
            _rgb.SetKeys(rgbColorKeys.ToArray(), alphaKeys.ToArray());

            _rgba = new Gradient();
            _rgba.SetKeys(rgbaColorKeys.ToArray(), rgbaAlphaKeys.ToArray());

            _grayscale = new Gradient();
            _grayscale.SetKeys(grayscaleColorKeys.ToArray(), alphaKeys.ToArray());

            _terrain = new Gradient();
            _terrain.SetKeys(terrainColorKeys.ToArray(), alphaKeys.ToArray());
        }
开发者ID:Andros-Spica,项目名称:LibNoise.Unity,代码行数:62,代码来源:GradientPresets.cs


示例5: CreateVerticalGradient

        /// <summary>
        /// Creates a 1 pixel wide vertical gradient texture using the provided <see cref="GradientStop"/> array.
        /// </summary>
        /// <param name="device"><see cref="Microsoft.Xna.Framework.Graphics.GraphicsDevice"/> instance to use.</param>
        /// <param name="gradientStops">Array of <see cref="GradientStop"/> instances to use when generating the gradient.</param>
        /// <param name="height">Height of the generated texture in pixels.</param>
        /// <returns>A texture 1 pixel wide and the height specified.</returns>
        public static Texture2D CreateVerticalGradient(GraphicsDevice device, Gradient gradient, int height)
        {
            Texture2D texture = new Texture2D(device, 1, height, false, SurfaceFormat.Color);
            Color[] colors = gradient.GetColors(height);
            texture.SetData<Color>(colors);

            return texture;
        }
开发者ID:bigangryguy,项目名称:BrassKnuckles,代码行数:15,代码来源:SimpleTexture.cs


示例6: CreateHorizontalGradient

        /// <summary>
        /// Creates a 1 pixel high horizontal gradient texture using the provided <see cref="GradientStop"/> array.
        /// </summary>
        /// <param name="device"><see cref="Microsoft.Xna.Framework.Graphics.GraphicsDevice"/> instance to use.</param>
        /// <param name="gradientStops">Array of <see cref="GradientStop"/> instances to use when generating the gradient.</param>
        /// <param name="width">Width of the generated texture in pixels.</param>
        /// <returns>A texture with the width specified and 1 pixel high.</returns>
        public static Texture2D CreateHorizontalGradient(GraphicsDevice device, Gradient gradient, int width)
        {
            Texture2D texture = new Texture2D(device, width, 1, false, SurfaceFormat.Color);
            Color[] colors = gradient.GetColors(width);
            texture.SetData<Color>(colors);

            return texture;
        }
开发者ID:bigangryguy,项目名称:BrassKnuckles,代码行数:15,代码来源:SimpleTexture.cs


示例7: SceneFilter

        public SceneFilter(float angle, Gradient gradient)
        {
            gradientFx = new GradientFilter();
            gradientFx.Gradientf = gradient;
            gradientFx.OriginAngleDegree = angle;

            saturationFx = new SaturationModifyFilter();
            saturationFx.SaturationFactor = -0.6f;
        }
开发者ID:olachan,项目名称:ImageFilterForWindowsPhone,代码行数:9,代码来源:SceneFilter.cs


示例8: SaveGraient

	void SaveGraient(Gradient gradient)
	{
		var path = EditorUtility.SaveFilePanel("Save gradient.", "Assets/", "", "asset");
		if (!string.IsNullOrEmpty(path))
		{
			GradientObject obj = GradientObject.CreateInstance<GradientObject>();
			obj.data = gradient;
			AssetDatabase.CreateAsset(obj, LocalPath(path));
		}
	}
开发者ID:fengqk,项目名称:Art,代码行数:10,代码来源:MaterialColorPropertyDrawer.cs


示例9: AddGradient_Click

 private void AddGradient_Click(object sender, EventArgs e)
 {
     Gradient newGradient = new Gradient();
       newGradient.Name = CreateUniqueGradientName(Strings.NewGradient);
       gradients.Add(newGradient);
       gradientList.DataSource = null;
       gradientList.DataSource = gradients;
       gradientList.SelectedIndex = gradients.Count - 1;
       deleteGradient.Enabled = (gradients.Count > 0);
       gradientNameTextbox.Focus();
 }
开发者ID:romanbdev,项目名称:quickroute-gps,代码行数:11,代码来源:GradientEditor.cs


示例10: ExtendedTerrainArea

    public ExtendedTerrainArea(float averageHeight, float flatness, float roughness, 
	                                  Gradient coloring00, Gradient coloring10, Gradient coloring01, Gradient coloring11,
	                                  float deltaX, float deltaY)
        : base(averageHeight, flatness, roughness, null)
    {
        this.coloring00 = coloring00;
        this.coloring10 = coloring10;
        this.coloring01 = coloring01;
        this.coloring11 = coloring11;
        this.deltaX = deltaX;
        this.deltaY = deltaY;
    }
开发者ID:parmandorc,项目名称:PCG,代码行数:12,代码来源:ExtendedTerrainArea.cs


示例11: GradientViewer

        // This constructor takes a Gradient value from the
        // design-time environment, which will be used to display
        // the initial state.
        public GradientViewer(Gradient gradient, IWindowsFormsEditorService editorService)
        {
            // This call is required by the designer.
              InitializeComponent();

              // Cache the light shape value provided by the
              // design-time environment.
              this.gradient = gradient;

              // Cache the reference to the editor service.
              this.editorService = editorService;
        }
开发者ID:romanbdev,项目名称:quickroute-gps,代码行数:15,代码来源:GradientViewer.cs


示例12: InitImpulseGradient

	private void InitImpulseGradient ()
	{
		impulseGradient = new Gradient ();
		GradientColorKey[] gck = new GradientColorKey[impulseGradientColors.Length];
		GradientAlphaKey[] gak = new GradientAlphaKey[impulseGradientColors.Length];
		for (int i = 0; i < impulseGradientColors.Length; i++) {
			gck [i].color = impulseGradientColors [i];
			gak [i].alpha = 1.0f;
			gck [i].time = gak [i].time = impulseGradientTimes [i];
		}
		impulseGradient.SetKeys (gck, gak);
	}
开发者ID:eriol1977,项目名称:Bullseye,代码行数:12,代码来源:UIControl.cs


示例13: WindParticle

	private int id; // just for debugging / can be deleted after

	#endregion

	public WindParticle(int _id, Vector3 _position, int _maxDistance, Quaternion _direction, float _speed, int _maxMountainHeight, float _temperature, float _saturation, Gradient _colorArea) {
		id = _id;
		position = _position;
		source = _position;
		maxDistance = _maxDistance;
		direction = _direction;
		speed = _speed;
		maxMountainHeight = _maxMountainHeight;
		temperature = _temperature;
		saturation = getSFromFRel(_saturation,getPFromHeight((position.y-groundHeight)/scale),temperature); // saturation kommt als relative Luftfeuchte, daher die Umrechnung
		colorArea = _colorArea;
		visible = true;
	}
开发者ID:tim-peters,项目名称:TheFoehnThing,代码行数:17,代码来源:WindParticle.cs


示例14: Awake

		// Use this for initialization
		void Awake () 
		{
		
			//set RectTransform parameters
			RectTransform rectTransform = this.GetComponent<RectTransform> ();
			rectTransform.anchorMin = new Vector2(0,0);
			rectTransform.anchorMax = new Vector2(1,1);
			rectTransform.anchoredPosition = new Vector2(1,1);

			colorGradient = GetColorGradient (bottomColor, topColor); // create the color gradient

	
		}
开发者ID:gcanedo,项目名称:globalgamejam2016,代码行数:14,代码来源:PanelWaveform.cs


示例15: BlendGradient

    public Gradient BlendGradient(Gradient terrain_gradient, Gradient object_gradient)
    {
        List<ColorHSV> targetPalette = new List<ColorHSV>();
        List<ColorHSV> currentPalette = new List<ColorHSV>();
        targetPalette = RandomE.TetradicPalette(0.25f, 0.75f);
        Debug.Log(targetPalette.Count);
        ColorHSV groundColor = new ColorHSV(terrain_gradient.Evaluate(0));
        ColorHSV newColor = new ColorHSV(object_gradient.Evaluate(1));
        targetPalette.Add(ColorHSV.Lerp(groundColor, newColor, 0.5f));
        var gradient = ColorE.Gradient(from: targetPalette[2].WithSV(0.8f, 0.8f),
            to: targetPalette[3].WithSV(0.8f, 0.8f));

        return object_gradient;
    }
开发者ID:emomper23,项目名称:PsychVR,代码行数:14,代码来源:ObjectColorSetter.cs


示例16: CreateGradTexture

	public void CreateGradTexture(){
		// Create gradient object and assign generic starting colours
		Grad = new Gradient();
		LastGrad = new Gradient();
		GradientColorKey[] gck = new GradientColorKey[2];
		gck[0] = new GradientColorKey(Color.black, 0f);
		gck[1] = new GradientColorKey(Color.white, 1f);
		GradientAlphaKey[] gak = new GradientAlphaKey[2];
		gak[0] = new GradientAlphaKey(1f, 0f);
		gak[1] = new GradientAlphaKey(1f, 1f);
		Grad.SetKeys(gck, gak);
		LastGrad.SetKeys(gck, gak);
		
		outTexture = new Texture2D(_gradientSizeX,_gradientSizeY);
		outTexture.hideFlags = HideFlags.HideAndDontSave;
//		Debug.Log (outTexture);
	}
开发者ID:haramako,项目名称:test02,代码行数:17,代码来源:GradientMaker.cs


示例17: Start

    void Start () {
        GradientColorKey[] gradColorKey;
        GradientAlphaKey[] gradAlphaKey;

        grad = new Gradient();
        gradColorKey = new GradientColorKey[3];
        gradAlphaKey = new GradientAlphaKey[1];

        gradColorKey[0].color = Color.magenta;
        gradColorKey[0].time = 0.0f;
        gradColorKey[1].color = Color.green;
        gradColorKey[1].time = 0.5f;
        gradColorKey[2].color = Color.magenta;
        gradColorKey[2].time = 1.0f;

        gradAlphaKey[0].alpha = 1.0f;

        grad.SetKeys(gradColorKey,gradAlphaKey);
    }
开发者ID:AlbinoShadow,项目名称:NecknNeck,代码行数:19,代码来源:WallColors.cs


示例18: Grad

    public static Color Grad(float x)
    {
        /*
        // Terrain gradient color keys
        List<GradientColorKey> terrainColorKeys = new List<GradientColorKey>
        {
            new GradientColorKey(new Color(0, 0, 0.5f), 0),
            new GradientColorKey(new Color(0.125f, 0.25f, 0.5f), 0.4f),
            new GradientColorKey(new Color(0.25f, 0.375f, 0.75f), 0.48f),
            new GradientColorKey(new Color(0, 0.75f, 0), 0.5f),
            new GradientColorKey(new Color(0.75f, 0.75f, 0), 0.625f),
            new GradientColorKey(new Color(0.625f, 0.375f, 0.25f), 0.75f),
            new GradientColorKey(new Color(0.5f, 1, 1), 0.875f),
            new GradientColorKey(Color.white, 1)
        };

        // Generic gradient alpha keys
        var alphaKeys = new List<GradientAlphaKey> {new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1)};
        */

        Gradient g = new Gradient();
        GradientColorKey[] gck;
        GradientAlphaKey[] gak;

        // Populate the color keys at the relative time 0 and 1 (0 and 100%)
        gck = new GradientColorKey[2];
        gck[0].color = Color.red;
        gck[0].time = 0.0f;
        gck[1].color = Color.blue;
        gck[1].time = 1.0f;

        // Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
        gak = new GradientAlphaKey[2];
        gak[0].alpha = 1.0f;
        gak[0].time = 0.0f;
        gak[1].alpha = 0.0f;
        gak[1].time = 1.0f;

        //g.SetKeys(terrainColorKeys.ToArray(), alphaKeys.ToArray());
        g.SetKeys(gck,gak);

        return g.Evaluate(x);;
    }
开发者ID:parthshah31,项目名称:HackMITAudio,代码行数:43,代码来源:Tools.cs


示例19: ListParameters

        /*
        protected override IEnumerable ListParameters()
        {
          yield return "Type: " + Abbreviations.Get(_type.Value);
          yield return ((_dither) ? "With" : "Without") + " Dither";
          yield return ((_useMask) ? "With" : "Without") + " Use Mask";
        }
        */
        public static Gradient CreateGradient(string name, ListParameter colors)
        {
            Gradient gradient = new Gradient("Photoshop." + name);
              gradient.SegmentRangeSplitUniform(0, -1, colors.Count);

              int segment = 0;

              foreach (ObjcParameter parameter in colors)
            {
              RGB color;

              string type = parameter.GetValueAsString("Type");
              switch (type)
            {
            case "BckC":
              color = Context.Background;
              break;
            case "FrgC":
              color = Context.Foreground;
              break;
            case "UsrS":
              color = parameter.GetValueAsColor("Clr");
              break;
            default:
              Console.WriteLine("Gradient-1: " + type);
              color = new RGB(0, 0, 0);
              break;
            }

              long location = parameter.GetValueAsLong("Lctn");
              long midpoint = parameter.GetValueAsLong("Mdpn");
              Console.WriteLine("type: {0}, location: {1}, midpoint: {2}",
                type, location, midpoint);
              gradient.SegmentSetLeftPosition(segment, location / 4096.0);
              gradient.SegmentSetLeftColor(segment, color, 100);
              if (segment > 0)
            {
              gradient.SegmentSetRightColor(segment - 1, color, 100);
            }
              segment++;
            }
              return gradient;
        }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:51,代码来源:GradientClassEvent.cs


示例20: GetTexture

        /// <summary>
        /// Returns a gradient filled into a shape.
        /// </summary>
        public static Texture2D GetTexture(GraphicsDevice device, Gradient gradient, IShape shape)
        {
            string comparer = string.Concat(new string[] { shape.GetType().Name, shape.ToString(), gradient.ToString() });

            Texture2D texture;

            //Search for the texture in the dictionary, so it doesn't have to be created twice.
            if (_tempTextures.Keys.Contains(comparer))
            {
                texture = _tempTextures[comparer];
            }
            else
            {
                texture = createTexture(device, gradient, shape);
                _tempTextures.Add(comparer, texture);
            }

            return texture;
        }
开发者ID:Aragas,项目名称:Pokemon3D-1,代码行数:22,代码来源:GradientTextureProvider.cs



注:本文中的Gradient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GradientStopCollection类代码示例发布时间:2022-05-24
下一篇:
C# Grade类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap