コード例 #1
0
ファイル: GdiRenderer.cs プロジェクト: lardratboy/it3rate
        private void DrawText(Vex.Text tx, DDW.Vex.Matrix m)
        {
            for (int i = 0; i < tx.TextRuns.Count; i++)
            {
                Vex.TextRun tr    = tx.TextRuns[i];
                string      s     = tr.Text;
                FontStyle   style = tr.isBold ? FontStyle.Bold : FontStyle.Regular;
                if (tr.isItalic)
                {
                    style |= FontStyle.Italic;
                }

                Font font = new Font(tr.FontName, tr.FontSize, style, GraphicsUnit.Pixel);

                System.Drawing.Color col = System.Drawing.Color.FromArgb(tr.Color.A, tr.Color.R, tr.Color.G, tr.Color.B);
                Brush b = new SolidBrush(col);

                g.SmoothingMode      = SmoothingMode.HighQuality;
                g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                g.TextRenderingHint  = TextRenderingHint.AntiAliasGridFit;
                g.CompositingMode    = CompositingMode.SourceOver;
                g.CompositingQuality = CompositingQuality.HighQuality;

                g.DrawString(s, font, b, tx.Matrix.TranslateX + m.TranslateX + tr.Left, tx.Matrix.TranslateY + m.TranslateY + tr.Top);

                b.Dispose();
            }
        }
コード例 #2
0
ファイル: GdiRenderer.cs プロジェクト: lardratboy/it3rate
        public void RenderInto(Vex.IDefinition def, uint frame, Graphics graphics)
        {
            this.g = graphics;

            if (def is Vex.Timeline)
            {
                Vex.Timeline tl          = (Vex.Timeline)def;
                Vex.Timeline namedSymbol = GetNamedSymbol(tl);
                if (namedSymbol != null)// && HasSymbols(namedSymbol))
                {
                    RenderFrame(namedSymbol, frame);
                }
            }
            else if (def is Vex.Symbol)
            {
                Vex.Symbol sy = (Vex.Symbol)def;
                RenderFrame(sy, 0);
            }
            else if (def is Vex.Text)
            {
                Vex.Text tx = (Vex.Text)def;
                if (tx.TextRuns.Count > 0 && !tx.TextRuns[0].isEditable)
                {
                    RenderFrame(tx, 0);
                }
            }
            else if (def is Vex.Image)
            {
                Bitmap sourceBmp = stage.BitmapCache.GetBitmap(def);
                DrawImage(sourceBmp);
            }
        }
コード例 #3
0
ファイル: GdiRenderer.cs プロジェクト: lardratboy/it3rate
        // assumes graphics, matrix are setup
        private void RenderFrame(Vex.IDefinition def, uint frame)
        {
            if (def is Vex.Timeline)
            {
                DrawFilteredTimeline((Vex.Timeline)def, frame);
            }
            else if (def is Vex.Symbol)
            {
                DrawFilteredSymbol((Vex.Symbol)def);
            }
            else if (def is Vex.Text)
            {
                Vex.Text tx = (Vex.Text)def;

                if (tx.TextRuns.Count > 0 && !tx.TextRuns[0].isEditable)
                {
                    DrawText(tx, new DDW.Vex.Matrix(1, 0, 0, 1, -tx.StrokeBounds.Point.X, -tx.StrokeBounds.Point.Y));
                }
            }
            else if (def is Vex.Image)
            {
                DrawImage(stage.BitmapCache.GetBitmap(def));
            }
        }
コード例 #4
0
ファイル: VexTree.cs プロジェクト: Hamsand/Swf2XNA
 private Definition2D GetTextDefinition(Matrix m, Text def)
 {
     Definition2D result = definitions.Find(d => d.DefinitionName == def.Name);
     if (result == null)
     {
         result = CreateTextDefinition(def);
         definitions.Add(result);
     }
     return result;
 }
コード例 #5
0
ファイル: VexTree.cs プロジェクト: Hamsand/Swf2XNA
        private Text2D CreateTextDefinition(Text def)
        {
            Text2D result = new Text2D(def.TextRuns);

            result.Id = def.Id;
            result.DefinitionName = def.Name;
            result.LinkageName = def.Name;
            result.Bounds = def.StrokeBounds;
            AddFonts(def.TextRuns);
            return result;
        }
コード例 #6
0
ファイル: XamlRenderer.cs プロジェクト: nyxojaele/Swf2XNA
		public virtual void WriteTextBlock(Text txt, Instance inst)
		{

			// <Block FontFamily=
			//   FontSize="40"
			//   FontFamily="Georgia"
			//   FontStyle="Italic" FontWeight="Bold"
			//   Canvas.Top="20" Canvas.Left="20"
			//	 Foreground="Red">
			//  test
			// </Block>

			xw.WriteStartElement("Canvas");

			if (inst != null)
			{
				string name = (inst.Name != null && inst.Name != "") ? inst.Name : instancePrefix + instName;
				xw.WriteStartAttribute("x:Name");
				xw.WriteValue(instancePrefix + instName);
				xw.WriteEndAttribute();
			}

			// ***** Can't use spans as that loses centering

			if(txt.TextRuns.Count == 0)
			{
				// todo: need to add edit text box attributes to Text tag, or have EditText tag
				//WriteTextAttributes(tr);
			}
			//else if (txt.TextRuns.Count == 1)
			//{
			//    TextRun tr = txt.TextRuns[0];

			//    xw.WriteStartElement("TextBlock");
			//    xw.WriteAttributeString("Canvas.Left", tr.Left);
			//    xw.WriteAttributeString("Canvas.Top", tr.Top);

			//    WriteTextAttributes(tr);
			//    xw.WriteValue(tr.Text);

			//    xw.WriteEndElement();
			//}
			else // multi text runs
			{
				xw.WriteStartElement("TextBlock");
				for (int i = 0; i < txt.TextRuns.Count; i++)
				{
					TextRun tr = txt.TextRuns[i];

					if (i > 0 && tr.isContinuous)
					{
						xw.WriteStartElement("Span");

						WriteTextAttributes(tr);
						xw.WriteValue(tr.Text);

						xw.WriteEndElement();
					}
					else
					{
						if (i > 0)
						{
							xw.WriteEndElement();
							xw.WriteStartElement("TextBlock");
						}
						xw.WriteAttributeString("Canvas.Left", tr.Left.ToString());
						xw.WriteAttributeString("Canvas.Top", tr.Top.ToString());

						WriteTextAttributes(tr);
						xw.WriteValue(tr.Text);

					}
					//if (tr.isMultiline)
					//{
					//    xw.WriteStartElement("LineBreak");
					//    xw.WriteEndElement();
					//}
				}
				xw.WriteEndElement();
			}


			xw.WriteEndElement(); // Canvas

		}
コード例 #7
0
ファイル: GdiRenderer.cs プロジェクト: nyxojaele/Swf2XNA
        private void DrawText(Text tx, DDW.Vex.Matrix m)
        {
            for (int i = 0; i < tx.TextRuns.Count; i++)
            {
                TextRun tr = tx.TextRuns[i];
                string s = tr.Text;
                FontStyle style = tr.isBold ? FontStyle.Bold : FontStyle.Regular;
                if (tr.isItalic)
                {
                    style |= FontStyle.Italic;
                }

                Font font = new Font(tr.FontName, tr.FontSize, style, GraphicsUnit.Pixel);

                System.Drawing.Color col = System.Drawing.Color.FromArgb(tr.Color.A, tr.Color.R, tr.Color.G, tr.Color.B);
                Brush b = new SolidBrush(col);

                g.SmoothingMode = SmoothingMode.HighQuality;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                g.CompositingMode = CompositingMode.SourceOver;
                g.CompositingQuality = CompositingQuality.HighQuality;

                g.DrawString(s, font, b, tx.Matrix.TranslateX + m.TranslateX + tr.Left, tx.Matrix.TranslateY + m.TranslateY + tr.Top);

                b.Dispose();
            }
        }
コード例 #8
0
ファイル: GdiRenderer.cs プロジェクト: lardratboy/it3rate
        public List <Bitmap> RenderDefinitionFrames(Vex.IDefinition def, uint startFrame, uint endFrame, Matrix m)
        {
            List <Bitmap> bmpFrames = new List <Bitmap>();

            if (def is Vex.Timeline)
            {
                Vex.Timeline tl          = (Vex.Timeline)def;
                Vex.Timeline namedSymbol = GetNamedSymbol(tl);
                if (namedSymbol != null)// && HasSymbols(namedSymbol))
                {
                    for (uint i = startFrame; i < endFrame; i++)
                    {
                        m.Translate(-namedSymbol.StrokeBounds.Point.X, -namedSymbol.StrokeBounds.Point.Y);
                        Bitmap myBitmap = CreateRenderBitmap(namedSymbol.StrokeBounds, m);
                        RenderFrame(namedSymbol, i);
                        bmpFrames.Add(myBitmap);
                    }
                }
            }
            else if (def is Vex.Symbol)
            {
                Vex.Symbol sy = (Vex.Symbol)def;

                m.Translate(-sy.StrokeBounds.Point.X, -sy.StrokeBounds.Point.Y);
                Bitmap myBitmap = CreateRenderBitmap(sy.StrokeBounds, m);

                RenderFrame(sy, 0);
                bmpFrames.Add(myBitmap);
            }
            else if (def is Vex.Text)
            {
                Vex.Text tx = (Vex.Text)def;

                if (tx.TextRuns.Count > 0 && !tx.TextRuns[0].isEditable)
                {
                    Bitmap myBitmap = CreateRenderBitmap(tx.StrokeBounds, m);
                    RenderFrame(tx, 0);
                    bmpFrames.Add(myBitmap);
                }
            }
            else if (def is Vex.Image)
            {
                Bitmap myBitmap;
                m.Translate(-def.StrokeBounds.Point.X, -def.StrokeBounds.Point.Y);
                if (m.IsScaledOrSheared())
                {
                    myBitmap = CreateRenderBitmap(def.StrokeBounds, m);
                    Bitmap sourceBmp = stage.BitmapCache.GetBitmap(def);
                    using (Graphics gr = Graphics.FromImage(myBitmap))
                    {
                        gr.DrawImage(sourceBmp, 0, 0, myBitmap.Width, myBitmap.Height);
                    }
                }
                else
                {
                    myBitmap = stage.BitmapCache.GetBitmap(def);
                }

                bmpFrames.Add(myBitmap);
            }

            if (g != null)
            {
                g.Dispose();
            }

            return(bmpFrames);
        }
コード例 #9
0
        public override void WriteTextBlock(Text txt, Instance inst)
        {
            xw.WriteStartElement("Canvas");

            if (inst != null)
            {
                string name = (inst.Name != null && inst.Name != "") ? inst.Name : instancePrefix + instName;
                string fullName = instancePrefix + instName;
                xw.WriteStartAttribute("x:Name");
                xw.WriteValue(fullName);
                xw.WriteEndAttribute();

                // write transform defs
                WriteTransformsDefs(v.Definitions[inst.DefinitionId], inst, fullName);

                // write Storyboard
                WriteStoryboard(v.Definitions[inst.DefinitionId], inst, fullName);
            }

            // ***** Can't use spans as that loses centering

            if (txt.TextRuns.Count != 0)
            {
                xw.WriteStartElement("TextBlock");
                for (int i = 0; i < txt.TextRuns.Count; i++)
                {
                    TextRun tr = txt.TextRuns[i];

                    if (i > 0 && tr.isContinuous)
                    {
                        xw.WriteStartElement("Span");

                        WriteTextAttributes(tr);
                        xw.WriteValue(tr.Text);

                        xw.WriteEndElement();
                    }
                    else
                    {
                        if (i > 0)
                        {
                            xw.WriteEndElement();
                            xw.WriteStartElement("TextBlock");
                        }
                        xw.WriteAttributeString("Canvas.Left", tr.Left.ToString());
                        xw.WriteAttributeString("Canvas.Top", tr.Top.ToString());

                        WriteTextAttributes(tr);
                        xw.WriteValue(tr.Text);

                    }
                }
                xw.WriteEndElement();
            }
            xw.WriteEndElement(); // Canvas
        }
コード例 #10
0
ファイル: SwfToVex.cs プロジェクト: galaxyyao/TouhouGrave
		private void ParseEditText(DefineEditTextTag tag)
		{
			Text t = new Text(v.NextId());

			t.Id = tag.CharacterID;
			t.StrokeBounds = ParseRect(tag.Bounds);
			t.Matrix = Vex.Matrix.Identity;

			ConvertStringToTextRuns(tag, t.TextRuns);

			v.Definitions.Add(t.Id, t);
		}
コード例 #11
0
ファイル: SwfToVex.cs プロジェクト: galaxyyao/TouhouGrave
		private void ParseDefineText(DefineTextTag tag)
		{
			Text t = new Text(v.NextId());
            
			t.StrokeBounds = ParseRect(tag.TextBounds);
			t.Matrix = ParseMatrix(tag.TextMatrix);
			GetTextFromRecords(tag.TextRecords, t.TextRuns);
			t.Id = tag.CharacterId;

			v.Definitions.Add(t.Id, t);
		}