Пример #1
0
    void Awake()
    {
        PlayerPrefs.DeleteKey("bleed_character");


        armature = icon_character.GetComponent <UnityArmatureComponent>().armature;
        icon_character.SetActive(false);
        panel_appearence.SetActive(false);
        panel_position.SetActive(true);
        panel_delete.SetActive(false);

        if (!PlayerPrefs.HasKey("bleed_character"))
        {
            icon_character.SetActive(true);
            panel_appearence.SetActive(true);
        }
        else
        {
            string[] str = PlayerPrefs.GetString("bleed_character").Split(',');
            headIndex      = int.Parse(str[0]);
            hairIndex      = int.Parse(str[1]);
            hairColorIndex = int.Parse(str[2]);

            UnityFactory.factory.ReplaceSlotDisplay("soldiers", "Armature", "hair11", HAIRARRAY[hairIndex], armature.GetSlot("hair11"));
            UnityFactory.factory.ReplaceSlotDisplay("soldiers", "Armature", "head", HEADARRAY[headIndex], armature.GetSlot("head"));
            ColorTransform color = new ColorTransform();
            color.redMultiplier = HAIRCOLORARRAY[hairColorIndex];
            armature.GetSlot("hair11")._setColor(color);
        }
    }
        public ColorizeViewer()
        {
            InitializeComponent();
            colorizePixel = new ColorTransform(ColorizePixelExpandMult);
            colorizeModeCombobox.SelectedIndex = 1;

            refColorModeComboBox.SelectedIndex = 0;

            InitRefColorMenu();

            library = new ColorLibrary();

            // initialize color array
            baseColors    = new HSVColor[4];
            baseColors[0] = HSVColor.FromRGB(255, 0, 0);
            baseColors[1] = HSVColor.FromRGB(0, 255, 0);
            baseColors[2] = HSVColor.FromRGB(0, 0, 255);
            baseColors[3] = HSVColor.FromRGB(255, 255, 255);

            fileColors = new HSVColor[4];

            // save buttons in an array for easy lookup
            colorButtons    = new Button[4];
            colorButtons[0] = color0Button;
            colorButtons[1] = color1Button;
            colorButtons[2] = color2Button;
            colorButtons[3] = color3Button;

            // init button background colors
            UpdateButtons();
        }
Пример #3
0
        public override void DrawContents()
        {
            base.DrawContents();
            if (Image != null)
            {
                var origonalTransform = Image.ColorTransform;

                ColorTransform effectTranform = ColorTransform.Identity;

                if (IsMouseOver)
                {
                    effectTranform = ColorTransform.Multiply(new Color(1.3f, 1.3f, 1.2f));
                }
                if (Depressed)
                {
                    effectTranform = ColorTransform.Multiply(new Color(0.8f, 0.8f, 0.8f));
                }
                if (!Enabled)
                {
                    effectTranform = ColorTransform.BlackAndWhite;
                }

                if (!effectTranform.IsIdentity)
                {
                    Image.ColorTransform = Image.ColorTransform + effectTranform;
                }

                Image.Update();
                Image.Draw();

                Image.ColorTransform = origonalTransform;
            }
        }
Пример #4
0
            public override void Render(Matrix matrix, ColorTransform colorTransform,
                                        int renderingIndex, int renderingCount, bool visible)
            {
#if UNITY_EDITOR
                m_visible = visible;
#endif
                if (m_context == null || !visible)
                {
                    return;
                }

                float scale = 1;
                if (m_context.systemFontRenderer != null)
                {
                    scale /= m_lwf.scaleByStage;
                }

                Factory factory = m_context.factory;
                factory.ConvertMatrix(ref m_matrix, matrix, scale,
                                      m_shouldBeOnTop ? m_zOffset : renderingCount - renderingIndex);
                Factory.MultiplyMatrix(ref m_renderMatrix,
                                       m_context.parent.transform.localToWorldMatrix, m_matrix);

#if LWF_USE_ADDITIONALCOLOR
                factory.ConvertColorTransform(
                    ref m_colorMult, ref m_colorAdd, colorTransform);
                m_context.Render(m_renderMatrix, m_colorMult, m_colorAdd,
                                 m_context.parent.layer, factory.camera);
#else
                factory.ConvertColorTransform(ref m_colorMult, colorTransform);
                m_context.Render(m_renderMatrix, m_colorMult,
                                 m_context.parent.layer, factory.camera);
#endif
            }
Пример #5
0
	public Property(LWF lwf)
	{
		m_lwf = lwf;
		m_matrix = new Matrix();
		m_colorTransform = new ColorTransform();
		ClearRenderingOffset();
	}
Пример #6
0
        /// <summary>
        /// Transforms a color value assumed to be in the default CS_sRGB
        /// color space into this ColorSpace.
        /// <para>
        /// This method transforms color values using algorithms designed
        /// to produce the best perceptual match between input and output
        /// colors.  In order to do colorimetric conversion of color values,
        /// you should use the <code>toCIEXYZ</code>
        /// method of the CS_sRGB color space to first convert from the input
        /// color space to the CS_CIEXYZ color space, and then use the
        /// <code>fromCIEXYZ</code> method of this color space to
        /// convert from CS_CIEXYZ to the output color space.
        /// See <seealso cref="#toCIEXYZ(float[]) toCIEXYZ"/> and
        /// <seealso cref="#fromCIEXYZ(float[]) fromCIEXYZ"/> for further information.
        /// </para>
        /// <para>
        /// </para>
        /// </summary>
        /// <param name="rgbvalue"> a float array with length of at least 3. </param>
        /// <returns> a float array with length equal to the number of
        ///       components in this ColorSpace. </returns>
        /// <exception cref="ArrayIndexOutOfBoundsException"> if array length is not
        /// at least 3. </exception>
        public override float[] FromRGB(float[] rgbvalue)
        {
            if (Srgb2this == null)
            {
                ColorTransform[] transformList = new ColorTransform [2];
                ICC_ColorSpace   srgbCS        = (ICC_ColorSpace)ColorSpace.GetInstance(CS_sRGB_Renamed);
                PCMM             mdl           = CMSManager.Module;
                transformList[0] = mdl.createTransform(srgbCS.Profile, ColorTransform.Any, ColorTransform.In);
                transformList[1] = mdl.createTransform(ThisProfile, ColorTransform.Any, ColorTransform.Out);
                Srgb2this        = mdl.createTransform(transformList);
                if (NeedScaleInit)
                {
                    SetComponentScaling();
                }
            }

            short[] tmp = new short[3];
            for (int i = 0; i < 3; i++)
            {
                tmp[i] = (short)((rgbvalue[i] * 65535.0f) + 0.5f);
            }
            tmp = Srgb2this.colorConvert(tmp, null);
            int nc = this.NumComponents;

            float[] result = new float [nc];
            for (int i = 0; i < nc; i++)
            {
                result[i] = (((float)(tmp[i] & 0xffff)) / 65535.0f) * DiffMinMax[i] + MinVal[i];
            }
            return(result);
        }
Пример #7
0
        public void ColorTransform(Rectangle rect, ColorTransform colorTransform)
        {
            float redMultiplier   = colorTransform.redMultiplier;
            float greenMultiplier = colorTransform.greenMultiplier;
            float blueMultiplier  = colorTransform.blueMultiplier;
            float alphaMultiplier = colorTransform.alphaMultiplier;
            int   redOffset       = colorTransform.redOffset;
            int   greenOffset     = colorTransform.greenOffset;
            int   blueOffset      = colorTransform.blueOffset;
            int   alphaOffset     = colorTransform.alphaOffset;

            int w = this.width;

            for (int y = rect.y; y < rect.y + rect.height; y++)
            {
                for (int x = rect.x; x < rect.x + rect.width; x++)
                {
                    int index = x * 4 + y * w * 4;
                    // old
                    int r = this._data[index + 0],
                        g = this._data[index + 1],
                        b = this._data[index + 2],
                        a = this._data[index + 3];
                    // new
                    this._data[index + 0] = (byte)((int)(r * redMultiplier) + redOffset);                   //Rnew
                    this._data[index + 1] = (byte)((int)(g * greenMultiplier) + greenOffset);               //Gnew
                    this._data[index + 2] = (byte)((int)(b * blueMultiplier) + blueOffset);                 //Bnew
                    this._data[index + 3] = (byte)((int)(a * alphaMultiplier) + alphaOffset);               //Anew
                }
            }
        }
Пример #8
0
 /** Styles a component with a red tint suitable for warnings. */
 public static void RedWarning(GuiComponent component)
 {
     Util.Assert(component != null, "Component must not be null.");
     component.ColorTransform  = ColorTransform.BlackAndWhite;
     component.ColorTransform += ColorTransform.Multiply(1.2f, 1.2f, 1.2f);
     component.Color           = new Color(1f, 0.4f, 0.3f);
 }
Пример #9
0
            public UnityEngine.Color ConvertColor(Color c, ColorTransform t)
            {
                Color nc = new Color();

                Utility.CalcColor(nc, c, t);
                return(new UnityEngine.Color(nc.red, nc.green, nc.blue, nc.alpha));
            }
Пример #10
0
        private static void ColorSample(HtmlRenderer html, string s)
        {
            int        c     = ColorParser.Parse(s);
            Parameters style = new Parameters();

            if (c == ColorParser.InvalidColor)
            {
                style["color"]            = "#000000";
                style["background-color"] = "#ffffff";
            }
            else
            {
                s = "#" + c.ToString("x6");
                style["color"]            = s;
                style["background-color"] = s;
                HlsColor hls = ColorTransform.RgbToHls(ColorTransform.IntToRgb(c));
                if (hls.L > 800)
                {
                    style["border"] = "1px solid #808080";
                }
            }
            html.Add("<div");
            html.Style(style);
            html.Add(">");
            html.Add(String.IsNullOrEmpty(s) ? "X" : "?");
            html.Add("</div>");
        }
Пример #11
0
            public override void Render(Matrix matrix, ColorTransform colorTransform,
                                        int renderingIndex, int renderingCount, bool visible)
            {
                if (!visible || m_empty)
                {
                    return;
                }

                Factory factory = (Factory)m_context.factory;

                factory.ConvertColorTransform(
                    ref m_colorMult, ref m_colorAdd, colorTransform);
                if (m_colorMult.a <= 0)
                {
                    return;
                }

                m_color = m_colors32[0] * m_colorMult + m_colorAdd;

                int z = renderingCount - renderingIndex;

                if (m_z != z || m_matrix.SetWithComparing(matrix))
                {
                    m_z = z;
                    factory.ConvertMatrix(
                        ref m_matrixForRender, matrix, 1, z, m_context.height);
                }

                factory.Render(this, m_vertices.Length / 4,
                               m_context.settings.font.material, m_colorAdd);
            }
Пример #12
0
        public void WriteColorTransform(ColorTransform cxform, bool withAlpha)
        {
            this.Align8();

            this.WriteBit(cxform.HasAdd);
            this.WriteBit(cxform.HasMult);

            int numBits = 10; /* 10-bits for 9-bit 1.00 fixed 8.8 signed value */

            this.WriteUBits(10, 4);

            if (cxform.HasMult)
            {
                HDRColor m = cxform.Mult;
                this.WriteColorComponent((int)m.Red, numBits);
                this.WriteColorComponent((int)m.Green, numBits);
                this.WriteColorComponent((int)m.Blue, numBits);
                if (withAlpha)
                {
                    this.WriteColorComponent((int)m.Alpha, numBits);
                }
            }

            if (cxform.HasAdd)
            {
                HDRColor a = cxform.Add;
                this.WriteColorComponent((int)a.Red, numBits);
                this.WriteColorComponent((int)a.Green, numBits);
                this.WriteColorComponent((int)a.Blue, numBits);
                if (withAlpha)
                {
                    this.WriteColorComponent((int)a.Alpha, numBits);
                }
            }
        }
Пример #13
0
	public override void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
	{
#if UNITY_EDITOR
		m_visible = visible;
#endif
		if (!visible || m_empty)
			return;

		Factory factory = (Factory)m_context.factory;
		factory.ConvertMatrix(ref m_matrix, matrix, 1,
			renderingCount - renderingIndex, m_context.height);
		Factory.MultiplyMatrix(ref m_renderMatrix,
			factory.gameObject.transform.localToWorldMatrix, m_matrix);

		factory.ConvertColorTransform(
			ref m_colorMult, ref m_colorAdd, colorTransform);

		var color = m_color * m_colorMult + m_colorAdd;
		for (int i = 0; i < m_colors32.Length; ++i)
			m_colors32[i] = color;

		m_mesh.Clear(true);
		m_mesh.vertices = m_vertices;
		m_mesh.uv = m_uv;
		m_mesh.triangles = m_triangles;
		m_mesh.colors32 = m_colors32;

		Graphics.DrawMesh(m_mesh,
			m_renderMatrix, m_context.settings.font.material, 0);
	}
Пример #14
0
 public void UpdateColor(ref ColorTransform color)
 {
     leftTop.color     = color;
     rightTop.color    = color;
     leftBottom.color  = color;
     rightBottom.color = color;
 }
Пример #15
0
 public Property(LWF lwf)
 {
     m_lwf            = lwf;
     m_matrix         = new Matrix();
     m_colorTransform = new ColorTransform();
     ClearRenderingOffset();
 }
Пример #16
0
 /// <summary>
 /// Updates color transform for each quad.
 /// </summary>
 public void UpdateColor(ref ColorTransform color)
 {
     for (int i = 0; i < quadsCount; i++)
     {
         quads[i].UpdateColor(ref color);
     }
 }
Пример #17
0
            public override void Render(Matrix matrix, ColorTransform colorTransform,
                                        int renderingIndex, int renderingCount, bool visible)
            {
#if UNITY_EDITOR
                m_visible = visible;
#endif
                if (!visible || m_empty)
                {
                    return;
                }

                Factory factory = (Factory)m_context.factory;
                factory.ConvertMatrix(ref m_matrix, matrix, 1,
                                      renderingCount - renderingIndex, m_context.height);
                Factory.MultiplyMatrix(ref m_renderMatrix,
                                       factory.gameObject.transform.localToWorldMatrix, m_matrix);

                factory.ConvertColorTransform(
                    ref m_colorMult, ref m_colorAdd, colorTransform);

                var color = m_color * m_colorMult + m_colorAdd;
                for (int i = 0; i < m_colors32.Length; ++i)
                {
                    m_colors32[i] = color;
                }

                m_mesh.Clear(true);
                m_mesh.vertices  = m_vertices;
                m_mesh.uv        = m_uv;
                m_mesh.triangles = m_triangles;
                m_mesh.colors32  = m_colors32;

                Graphics.DrawMesh(m_mesh,
                                  m_renderMatrix, m_context.settings.font.material, 0);
            }
        public static void ToMouseCursor(this Sprite c)
        {
            // http://www.kirupa.com/forum/showthread.php?274754-bitmapData-transparency

            var u = new BitmapData(32, 32, transparent: true, fillColor: 0x00FFFFFFu);

            var adjustAlpha = new ColorTransform();

            //adjustAlpha.alphaMultiplier = 0.5;

            var m = new Matrix();

            u.draw(c, m, adjustAlpha, BlendMode.NORMAL);


            var data = new BitmapData[] {
                u
            };

            // X:\jsc.svn\examples\actionscript\FlashMouseCursorDataExperiment\FlashMouseCursorDataExperiment\ApplicationSprite.cs
            var cursor = new MouseCursorData
            {
                data = data
            };

            // http://stackoverflow.com/questions/16004940/error-2136-swf-contains-invalid-data
            //Error: Error #2136: The SWF file file:///X|/jsc.svn/examples/actionscript/svg/FlashSVGCursorExperiment/FlashSVGCursorExperiment/bin/Debug/staging/FlashSVGCursorExperiment.ApplicationSprite/web/FlashSVGCursorExperiment.ApplicationSprite.swf contains invalid data.
            //    at FlashSVGCursorExperiment::ApplicationSprite()[V:\web\FlashSVGCursorExperiment\ApplicationSprite.as:34]


            Mouse.registerCursor("c", cursor);
            Mouse.cursor = "c";
        }
Пример #19
0
	public override void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
	{
		if (!visible || m_empty)
			return;

		Factory factory = (Factory)m_context.factory;
		factory.ConvertColorTransform(
			ref m_colorMult, ref m_colorAdd, colorTransform);
		if (m_colorMult.a <= 0)
			return;

		m_color = m_colors32[0] * m_colorMult + m_colorAdd;

		m_updated = m_matrix.SetWithComparing(matrix);

		int z = renderingCount - renderingIndex;
		if (m_z != z) {
			m_updated = true;
			m_z = z;
		}

		if (m_updated) {
			factory.ConvertMatrix(
				ref m_matrixForRender, matrix, 1, z, m_context.height);
		}

		factory.Render(this, m_vertices.Length / 4,
			m_context.settings.font.material, m_colorAdd);
	}
Пример #20
0
        public override void DumpBody(XmlWriter writer)
        {
            if ((Flags & SwfPlaceFlags.HasCharacter) != 0)
            {
                writer.WriteAttributeString("cid", _cid.ToString());
            }

            writer.WriteAttributeString("depth", Depth.ToString());
            writer.WriteAttributeString("flags", Flags.ToString());

            if (SwfDumpService.DumpDisplayListTags)
            {
                if ((Flags & SwfPlaceFlags.HasMatrix) != 0)
                {
                    writer.WriteElementString("matrix", _matrix.GetMatrixString());
                }
                if ((Flags & SwfPlaceFlags.HasColorTransform) != 0)
                {
                    ColorTransform.Dump(writer, true);
                }
                if ((Flags & SwfPlaceFlags.HasRatio) != 0)
                {
                    writer.WriteElementString("ratio", Ratio.ToString());
                }
                //if ((_flags & SwfPlaceFlags.HasName) != 0)
                //    writer.WriteElementString("name", XmlHelper.EntifyString(_name));
                if ((Flags & SwfPlaceFlags.HasClipDepth) != 0)
                {
                    writer.WriteElementString("clip-depth", _clipDepth.ToString());
                }
            }
        }
Пример #21
0
        /// <summary>
        /// Clones this symbol.
        /// </summary>
        /// <returns>
        /// A duplicate of this <see cref="Symbol{TPoint,TSize}"/>.
        /// </returns>
        public Symbol <TPoint, TSize> Clone()
        {
            Symbol <TPoint, TSize> clone = CreateNew(Size);
            MemoryStream           copy;

            lock (_symbolData)
            {
                // Record the original position
                Int64 streamPos = _symbolData.Position;
                _symbolData.Seek(0, SeekOrigin.Begin);

                Byte[] buffer = new Byte[_symbolData.Length];
                _symbolData.Read(buffer, 0, buffer.Length);
                copy = new MemoryStream(buffer);

                // Restore the original position
                _symbolData.Position = streamPos;
            }
            clone.SymbolData            = copy;
            clone._symbolDataHash       = _symbolDataHash;
            clone.ColorTransform        = ColorTransform.Clone();
            clone._rotationTransform    = CreateMatrix(_rotationTransform.Clone());
            clone._translationTransform = CreateMatrix(_translationTransform.Clone());
            clone._scalingTransform     = CreateMatrix(_scalingTransform.Clone());
            return(clone);
        }
Пример #22
0
    /** Overload addition to allow transformation combining */
    public static ColorTransform operator +(ColorTransform t1, ColorTransform t2)
    {
        ColorTransform result = new ColorTransform();

        result.Matrix      = t1.Matrix * t2.Matrix;
        result.ColorOffset = (t1.ColorOffset + t2.ColorOffset);
        return(result);
    }
Пример #23
0
 public Display()
 {
     _removed               = false;
     _hasUserVisible        = false;
     _userVisible           = true;
     _hasUserColorTransform = false;
     _userColorTransform    = ColorTransform.Default;
 }
Пример #24
0
        public ColorTransform Set(ColorTransform c)
        {
            multi.Set(c.multi);
#if LWF_USE_ADDITIONALCOLOR
            add.Set(c.add);
#endif
            return(this);
        }
Пример #25
0
        public ColorTransform(ColorTransform c)
        {
            multi = new Color();
#if LWF_USE_ADDITIONALCOLOR
            add = new Color();
#endif
            Set(c);
        }
Пример #26
0
 public void ConvertColorTransform(
     ref UnityEngine.Color mc, ColorTransform c)
 {
     mc.r = c.multi.red;
     mc.g = c.multi.green;
     mc.b = c.multi.blue;
     mc.a = c.multi.alpha;
 }
Пример #27
0
    public void OnClickHairColorRight()
    {
        hairColorIndex = (hairColorIndex + 1 + HAIRCOLORARRAY.Length) % HAIRCOLORARRAY.Length;
        ColorTransform color = new ColorTransform();

        color.redMultiplier = HAIRCOLORARRAY[hairColorIndex];
        armature.GetSlot("hair11")._setColor(color);
    }
Пример #28
0
 public override void Update(Matrix m, ColorTransform c)
 {
     base.Update(m, c);
     if (m_renderer != null)
     {
         m_renderer.Update(m_matrix, m_colorTransform);
     }
 }
Пример #29
0
            public override void Render(Matrix matrix, ColorTransform colorTransform,
                                        int renderingIndex, int renderingCount, bool visible)
            {
                // Ignore null texture
#if UNITY_EDITOR
                m_visible = visible;
#endif
                if (m_context == null || !visible)
                {
                    return;
                }

                Factory factory = m_context.factory;
                factory.ConvertColorTransform(
                    ref m_colorMult, ref m_colorAdd, colorTransform);
                if (m_colorMult.a <= 0)
                {
                    return;
                }
                if (m_context.premultipliedAlpha)
                {
                    m_colorMult.r *= m_colorMult.a;
                    m_colorMult.g *= m_colorMult.a;
                    m_colorMult.b *= m_colorMult.a;
                }

                factory.ConvertMatrix(ref m_matrix, matrix, 1,
                                      renderingCount - renderingIndex, m_context.height);
                Factory.MultiplyMatrix(ref m_renderMatrix,
                                       factory.gameObject.transform.localToWorldMatrix, m_matrix);

                m_property.Clear();
                m_property.AddColor("_Color", m_colorMult);
                if (factory.useAdditionalColor)
                {
                    m_property.AddColor("_AdditionalColor", m_colorAdd);
                }

                if (factory.blendMode == (int)Format.Constant.BLEND_MODE_ADD)
                {
                    if (m_additiveMaterial == null)
                    {
                        m_additiveMaterial        = new Material(m_context.material);
                        m_additiveMaterial.shader =
                            ResourceCache.SharedInstance().GetAdditiveShader(
                                m_context.material.shader);
                    }
                    Graphics.DrawMesh(m_context.mesh, m_renderMatrix,
                                      m_additiveMaterial, factory.gameObject.layer, factory.camera, 0,
                                      m_property);
                }
                else
                {
                    Graphics.DrawMesh(m_context.mesh, m_renderMatrix,
                                      m_context.material, factory.gameObject.layer, factory.camera, 0,
                                      m_property);
                }
            }
 override public void Dispose()
 {
     base.Dispose();
     Global    = null;
     Transform = null;
     //SkeletonData pivots
     Pivot = null;
     Color = null;
 }
Пример #31
0
 public override void updateDisplayedColor(ColorTransform parentColor)
 {
     if ((parentColor.add.r + parentColor.add.g + parentColor.add.b != 0) ||
         (parentColor.tint.r + parentColor.tint.g + parentColor.tint.b != 765))
     {
         this.cascadeColorEnabled = true;
     }
     base.updateDisplayedColor(parentColor);
 }
Пример #32
0
        public bool Equals(ColorTransform c)
        {
            bool equals = multi.Equals(c.multi);

#if LWF_USE_ADDITIONALCOLOR
            equals&& = add.Equals(c.add);
#endif
            return(equals);
        }
Пример #33
0
 public DrawParameters(ColorTransform colorTransform, bool blur = false)
 {
     Transform   = colorTransform;
     Blur        = blur;
     IsDebugDraw = false;
     AlphaBlend  = true;
     Scale       = Vector2.one;
     Rotation    = 0;
 }
Пример #34
0
        public PlaceObjectTag(SwfReader r, uint tagEnd)
        {
            Character = r.GetUI16();
            Depth = r.GetUI16();
            Matrix = new Matrix(r);

            if (tagEnd != r.Position)
            {
                HasColorTransform = true;
                ColorTransform = new ColorTransform(r, false);
            }
        }
Пример #35
0
	public override void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
	{
#if UNITY_EDITOR
		m_visible = visible;
#endif
		if (m_context == null || !visible)
			return;

		float scale = 1;
		if (m_context.systemFontRenderer != null)
			scale /= m_lwf.scaleByStage;

		Factory factory = m_context.factory;
		factory.ConvertMatrix(ref m_matrix, matrix, scale,
			m_shouldBeOnTop ? m_zOffset : renderingCount - renderingIndex);
		Factory.MultiplyMatrix(ref m_renderMatrix,
			m_context.parent.transform.localToWorldMatrix, m_matrix);

		factory.ConvertColorTransform(
			ref m_colorMult, ref m_colorAdd, colorTransform);
		m_context.Render(m_renderMatrix, m_colorMult, m_colorAdd,
			m_context.parent.layer, factory.camera);
	}
Пример #36
0
 private static extern void nvttSetInputOptionsColorTransform(IntPtr inputOptions, ColorTransform t);
	public override void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
	{
		// Ignore null texture
		if (m_context == null)
			return;

		Factory factory = m_context.factory;
		CombinedMeshBuffer buffer = factory.buffer;
		int bufferIndex = buffer.index++;

		if (!factory.updated)
			return;

		if (!visible)
			goto invisible;

		factory.ConvertColorTransform(
			ref m_colorMult, ref m_colorAdd, colorTransform);
		if (m_colorMult.a <= 0)
			goto invisible;
		if (factory.premultipliedAlpha) {
			m_colorMult.r *= m_colorMult.a;
			m_colorMult.g *= m_colorMult.a;
			m_colorMult.b *= m_colorMult.a;
		}
		Color32 color32 = m_colorMult;

		factory.ConvertMatrix(ref m_matrix, matrix, 1,
			renderingCount - renderingIndex, m_context.height);

		int index = bufferIndex * 4;
		Color32 bc = buffer.colors32[index];
		if (bc.r != color32.r ||
				bc.g != color32.g ||
				bc.b != color32.b ||
				bc.a != color32.a) {
			for (int i = 0; i < 4; ++i)
				buffer.colors32[index + i] = color32;
		}

		if (factory.useAdditionalColor) {
			Vector3 bac = buffer.additionalColors[index];
			if (bac.x != m_colorAdd.r ||
					bac.y != m_colorAdd.g ||
					bac.z != m_colorAdd.b) {
				for (int i = 0; i < 4; ++i)
					buffer.additionalColors[index + i] =
						new Vector3(m_colorAdd.r, m_colorAdd.g, m_colorAdd.b);
			}
		}

		if (!buffer.clean && m_available &&
				buffer.objects[bufferIndex] == m_context.objectId) {
			index = bufferIndex * 4;
			for (int i = 0; i < 4; ++i) {
				buffer.vertices[index + i] =
					m_matrix.MultiplyPoint3x4(m_context.vertices[i]);
			}
			return;
		}

		buffer.objects[bufferIndex] = m_context.objectId;

		index = bufferIndex * 4;
		for (int i = 0; i < 4; ++i) {
			buffer.vertices[index + i] =
				m_matrix.MultiplyPoint3x4(m_context.vertices[i]);
			buffer.uv[index + i] = m_context.uv[i];
		}

		int offset = bufferIndex * 4;
		index = bufferIndex * 6;
		for (int i = 0; i < 6; ++i)
			buffer.triangles[index + i] = m_context.triangles[i] + offset;

		buffer.changed = true;
		m_available = true;
		return;

invisible:
		factory.ConvertMatrix(ref m_matrix, matrix, 1,
							  renderingCount - renderingIndex, m_context.height);
		Vector3 v = m_matrix.MultiplyPoint3x4(m_context.vertices[0]);
		index = bufferIndex * 4;
		for (int i = 0; i < 4; ++i) {
			buffer.vertices[index + i] = v;
			buffer.colors32[index + i] = s_clearColor;
		}
		m_available = false;
	}
Пример #38
0
 public void colorTransform(Rectangle rectangle, ColorTransform colorTransform)
 {
     return;
 }
        public ColorizeViewer()
        {
            InitializeComponent();
            colorizePixel = new ColorTransform(ColorizePixelExpandMult);
            colorizeModeCombobox.SelectedIndex = 1;

            refColorModeComboBox.SelectedIndex = 0;

            InitRefColorMenu();

            library = new ColorLibrary();

            // initialize color array
            baseColors = new HSVColor[4];
            baseColors[0] = HSVColor.FromRGB(255, 0, 0);
            baseColors[1] = HSVColor.FromRGB(0, 255, 0);
            baseColors[2] = HSVColor.FromRGB(0, 0, 255);
            baseColors[3] = HSVColor.FromRGB(255, 255, 255);

            fileColors = new HSVColor[4];

            // save buttons in an array for easy lookup
            colorButtons = new Button[4];
            colorButtons[0] = color0Button;
            colorButtons[1] = color1Button;
            colorButtons[2] = color2Button;
            colorButtons[3] = color3Button;

            // init button background colors
            UpdateButtons();
        }
Пример #40
0
	public bool SetWithComparing(ColorTransform c)
	{
		if (c == null)
			return false;

		Color cm = c.multi;
		float red = cm.red;
		float green = cm.green;
		float blue = cm.blue;
		float alpha = cm.alpha;
		bool changed = false;
		Color m = multi;
		if (m.red != red) {
			m.red = red;
			changed = true;
		}
		if (m.green != green) {
			m.green = green;
			changed = true;
		}
		if (m.blue != blue) {
			m.blue = blue;
			changed = true;
		}
		if (m.alpha != alpha) {
			m.alpha = alpha;
			changed = true;
		}

		Color ca = c.add;
		red = ca.red;
		green = ca.green;
		blue = ca.blue;
		alpha = ca.alpha;
		Color a = add;
		if (a.red != red) {
			a.red = red;
			changed = true;
		}
		if (a.green != green) {
			a.green = green;
			changed = true;
		}
		if (a.blue != blue) {
			a.blue = blue;
			changed = true;
		}
		if (a.alpha != alpha) {
			a.alpha = alpha;
			changed = true;
		}
		return changed;
	}
Пример #41
0
	public ColorTransform Set(ColorTransform c)
	{
		multi.Set(c.multi);
		add.Set(c.add);
		return this;
	}
Пример #42
0
	public ColorTransform(ColorTransform c)
	{
		multi = new Color();
		add = new Color();
		Set(c);
	}
Пример #43
0
	public override void Update(Matrix m, ColorTransform c)
	{
		base.Update(m, c);
		if (m_renderer != null)
			m_renderer.Update(m_matrix, m_colorTransform);
	}
Пример #44
0
 public void draw(IBitmapDrawable source, Matrix matrix, ColorTransform colorTransform, string blendMode)
 {
     return;
 }
Пример #45
0
 public void draw(IBitmapDrawable source, Matrix matrix, ColorTransform colorTransform)
 {
     return;
 }
	public override void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
	{
		// Ignore null texture
#if UNITY_EDITOR
		m_visible = visible;
#endif
		if (m_context == null || !visible)
			return;

		Factory factory = m_context.factory;
		factory.ConvertColorTransform(
			ref m_colorMult, ref m_colorAdd, colorTransform);
		if (m_colorMult.a <= 0)
			return;
		if (m_context.premultipliedAlpha) {
			m_colorMult.r *= m_colorMult.a;
			m_colorMult.g *= m_colorMult.a;
			m_colorMult.b *= m_colorMult.a;
		}

		factory.ConvertMatrix(ref m_matrix, matrix, 1,
			renderingCount - renderingIndex, m_context.height);
		Factory.MultiplyMatrix(ref m_renderMatrix,
			factory.gameObject.transform.localToWorldMatrix, m_matrix);

		m_property.Clear();
		m_property.AddColor("_Color", m_colorMult);
		if (factory.useAdditionalColor)
			m_property.AddColor("_AdditionalColor", m_colorAdd);

		if (factory.blendMode == (int)Format.Constant.BLEND_MODE_ADD) {
			if (m_additiveMaterial == null) {
				m_additiveMaterial = new Material(m_context.material);
				m_additiveMaterial.shader =
					ResourceCache.SharedInstance().GetAdditiveShader(
						m_context.material.shader);
			}
			Graphics.DrawMesh(m_context.mesh, m_renderMatrix,
				m_additiveMaterial, factory.gameObject.layer, factory.camera, 0,
				m_property);
		} else {
			Graphics.DrawMesh(m_context.mesh, m_renderMatrix,
				m_context.material, factory.gameObject.layer, factory.camera, 0,
				m_property);
		}
	}
Пример #47
0
 public void draw(IBitmapDrawable source, Matrix matrix, ColorTransform colorTransform, string blendMode,
     Rectangle clipRect, bool smoothing)
 {
     return;
 }
        private void colorizeModeCombobox_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (colorizeModeCombobox.SelectedIndex)
            {
                case 0:
                default:
                    colorizePixel = new ColorTransform(ColorizePixelMult);
                    break;
                case 1:
                    colorizePixel = new ColorTransform(ColorizePixelExpandMult);
                    break;

            }
            ColorizeTile();
        }
Пример #49
0
            public override void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
            {
                // Ignore null texture
                if (m_context == null)
                return;

                Factory factory = m_context.factory;
                CombinedMeshBuffer buffer = factory.buffer;
                int bufferIndex = buffer.index++;

                if (!factory.updated)
                return;

                if (!visible)
                goto invisible;

                #if LWF_USE_ADDITIONALCOLOR
                factory.ConvertColorTransform(
                ref m_colorMult, ref m_colorAdd, colorTransform);
                #else
                factory.ConvertColorTransform(ref m_colorMult, colorTransform);
                #endif
                if (m_colorMult.a <= 0)
                goto invisible;
                if (factory.premultipliedAlpha) {
                m_colorMult.r *= m_colorMult.a;
                m_colorMult.g *= m_colorMult.a;
                m_colorMult.b *= m_colorMult.a;
                }
                Color32 color32 = m_colorMult;

                factory.ConvertMatrix(ref m_matrix, matrix, 1,
                renderingCount - renderingIndex, m_context.height);

                int index = bufferIndex * 4;
                Color32 bc = buffer.colors32[index];
                if (bc.r != color32.r ||
                bc.g != color32.g ||
                bc.b != color32.b ||
                bc.a != color32.a) {
                for (int i = 0; i < 4; ++i)
                buffer.colors32[index + i] = color32;
                }

                if (!buffer.clean &&
                buffer.objects[bufferIndex] == m_context.objectId)
                {
                index = bufferIndex * 4;
                for (int i = 0; i < 4; ++i) {
                buffer.vertices[index + i] =
                    m_matrix.MultiplyPoint3x4(m_context.vertices[i]);
                }
                return;
                }

                buffer.objects[bufferIndex] = m_context.objectId;

                index = bufferIndex * 4;
                for (int i = 0; i < 4; ++i) {
                buffer.vertices[index + i] =
                m_matrix.MultiplyPoint3x4(m_context.vertices[i]);
                buffer.uv[index + i] = m_context.uv[i];
                }

                int offset = bufferIndex * 4;
                index = bufferIndex * 6;
                for (int i = 0; i < 6; ++i)
                buffer.triangles[index + i] = m_context.triangles[i] + offset;

                buffer.changed = true;
                return;

                invisible:
                index = bufferIndex * 4;
                for (int i = 0; i < 4; ++i) {
                buffer.vertices[index + i] = Vector3.zero;
                buffer.colors32[index + i] = s_clearColor;
                }
            }
Пример #50
0
            public override void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
            {
                // Ignore null texture
                #if UNITY_EDITOR
                m_visible = visible;
                #endif
                if (m_context == null || !visible)
                return;

                Factory factory = m_context.factory;
                factory.ConvertColorTransform(
                ref m_colorMult, ref m_colorAdd, colorTransform);
                if (m_colorMult.a <= 0)
                return;
                if (m_context.premultipliedAlpha) {
                m_colorMult.r *= m_colorMult.a;
                m_colorMult.g *= m_colorMult.a;
                m_colorMult.b *= m_colorMult.a;
                }

                factory.ConvertMatrix(ref m_matrix, matrix, 1,
                renderingCount - renderingIndex, m_context.height);
                Factory.MultiplyMatrix(ref m_renderMatrix,
                factory.gameObject.transform.localToWorldMatrix, m_matrix);

                m_property.Clear();
                m_property.AddColor(m_colorId, m_colorMult);
                if (factory.useAdditionalColor)
                m_property.AddColor(m_additionalColorId, m_colorAdd);

                if (m_blendMode != factory.blendMode) {
                m_blendMode = factory.blendMode;
                if (m_material != null) {
                Material.Destroy(m_material);
                m_material = null;
                }

                m_material = ResourceCache.CreateBlendMaterial(
                m_context.material, m_context.premultipliedAlpha, m_blendMode);
                }

                Material material =
                m_material == null ? m_context.material : m_material;
                Graphics.DrawMesh(m_context.mesh, m_renderMatrix, material,
                factory.gameObject.layer, factory.renderCamera, 0, m_property);
            }
Пример #51
0
            public override void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
            {
                // Ignore null texture
                #if UNITY_EDITOR
                m_visible = visible;
                #endif
                if (m_context == null || !visible)
                return;

                Factory factory = m_context.factory;
                #if LWF_USE_ADDITIONALCOLOR
                factory.ConvertColorTransform(
                ref m_colorMult, ref m_colorAdd, colorTransform);
                #else
                factory.ConvertColorTransform(ref m_colorMult, colorTransform);
                #endif
                if (m_colorMult.a <= 0)
                return;
                if (m_context.premultipliedAlpha) {
                m_colorMult.r *= m_colorMult.a;
                m_colorMult.g *= m_colorMult.a;
                m_colorMult.b *= m_colorMult.a;
                }

                factory.ConvertMatrix(ref m_matrix, matrix, 1,
                renderingCount - renderingIndex, m_context.height);
                Factory.MultiplyMatrix(ref m_renderMatrix,
                factory.gameObject.transform.localToWorldMatrix, m_matrix);

                m_property.Clear();
                m_property.AddColor("_Color", m_colorMult);
                #if LWF_USE_ADDITIONALCOLOR
                m_property.AddColor("_AdditionalColor", m_colorAdd);
                #endif

                Graphics.DrawMesh(m_context.mesh, m_renderMatrix, m_context.material,
                factory.gameObject.layer, factory.camera, 0, m_property);
            }
Пример #52
0
            public override void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
            {
                // Ignore null texture
                if (m_context == null)
                return;

                if (!visible)
                return;

                Factory factory = m_context.factory;
                factory.ConvertColorTransform(
                ref m_colorMult, ref m_colorAdd, colorTransform);
                if (m_colorMult.a <= 0)
                return;

                if (m_context.premultipliedAlpha) {
                m_colorMult.r *= m_colorMult.a;
                m_colorMult.g *= m_colorMult.a;
                m_colorMult.b *= m_colorMult.a;
                }

                int z = renderingCount - renderingIndex;
                if (m_z != z || m_matrix.SetWithComparing(matrix)) {
                m_updated = true;
                m_z = z;
                factory.ConvertMatrix(
                ref m_matrixForRender, matrix, 1, z, m_context.height);
                } else {
                m_updated = false;
                }

                Material material = null;
                if (factory.blendMode == (int)Format.Constant.BLEND_MODE_ADD) {
                if (m_context.additiveMaterial == null)
                m_context.GetAdditiveMaterial();
                material = m_context.additiveMaterial;
                } else {
                material = m_context.material;
                }

                factory.Render(this, 1, material);
            }
Пример #53
0
        public virtual void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
        {
        }
Пример #54
0
 public UnityEngine.Color ConvertColor(Color c, ColorTransform t)
 {
     Color nc = new Color();
     Utility.CalcColor(nc, c, t);
     return new UnityEngine.Color(nc.red, nc.green, nc.blue, nc.alpha);
 }
Пример #55
0
 public void SetColorTransform(ColorTransform t)
 {
     nvttSetInputOptionsColorTransform(options, t);
 }
Пример #56
0
 public virtual void Update(Matrix matrix, ColorTransform colorTransform)
 {
 }
Пример #57
0
            public void ConvertColorTransform(
		ref UnityEngine.Color mc, ref UnityEngine.Color ac, ColorTransform c)
            {
                mc.r = c.multi.red;
                mc.g = c.multi.green;
                mc.b = c.multi.blue;
                mc.a = c.multi.alpha + c.add.alpha;

                ac.r = c.add.red;
                ac.g = c.add.green;
                ac.b = c.add.blue;
                ac.a = 0;
            }
Пример #58
0
 public ColorTransform(ColorTransform c)
 {
     multi = new Color();
     #if LWF_USE_ADDITIONALCOLOR
     add = new Color();
     #endif
     Set(c);
 }
Пример #59
0
            public override void Render(Matrix matrix, ColorTransform colorTransform,
		int renderingIndex, int renderingCount, bool visible)
            {
                if (m_context == null || !visible)
                return;

                float scale = 1;
                if (m_context.systemFontRenderer != null)
                scale /= m_lwf.scaleByStage;

                Factory factory = m_context.factory;
                factory.ConvertMatrix(ref m_matrix,
                matrix, scale, renderingCount - renderingIndex);
                Factory.MultiplyMatrix(ref m_renderMatrix,
                m_context.parent.transform.localToWorldMatrix, m_matrix);

                #if LWF_USE_ADDITIONALCOLOR
                factory.ConvertColorTransform(
                ref m_colorMult, ref m_colorAdd, colorTransform);
                if (m_context.bitmapFontRenderer != null) {
                m_context.bitmapFontRenderer.Render(
                m_renderMatrix, m_colorMult, m_colorAdd,
                m_context.parent.layer, factory.camera);
                }
                if (m_context.systemFontRenderer != null) {
                m_context.systemFontRenderer.Render(
                m_renderMatrix, m_colorMult, m_colorAdd,
                m_context.parent.layer, factory.camera);
                }
                #else
                factory.ConvertColorTransform(ref m_colorMult, colorTransform);
                if (m_context.bitmapFontRenderer != null) {
                m_context.bitmapFontRenderer.Render(m_renderMatrix, m_colorMult,
                m_context.parent.layer, factory.camera);
                }
                if (m_context.systemFontRenderer != null) {
                m_context.systemFontRenderer.Render(m_renderMatrix, m_colorMult,
                m_context.parent.layer, factory.camera);
                }
                #endif
            }
Пример #60
0
 public ColorTransform Set(ColorTransform c)
 {
     multi.Set(c.multi);
     #if LWF_USE_ADDITIONALCOLOR
     add.Set(c.add);
     #endif
     return this;
 }