Skip to content

Commit

Permalink
Merge pull request #39 from woeishi/develop
Browse files Browse the repository at this point in the history
DeleteSlice with Pin.IsChanged & TextEX9Texture bugfix
  • Loading branch information
joreg committed Feb 18, 2012
2 parents 4f5ae06 + 6e19cc3 commit 2ee0132
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 63 deletions.
Expand Up @@ -169,70 +169,80 @@ unsafe protected override void UpdateTexture(int Slice, Texture texture)
GraphicsUnit.Pixel);

string text = FTextInput[Slice];

int renderingMode = FTextRenderingModeInput[Slice].Index;
RectangleF layout = new RectangleF(0,0,0,0);
switch (renderingMode)
{
case 0: text = text.Replace("\n"," ").Replace("\n",string.Empty); break;
case 1: break;
case 2: layout.Size= new SizeF(width,height);break;
}
if (FCharEncoding[Slice] == "UTF8")
{
byte[] utf8bytes = Encoding.Default.GetBytes(text);
text = Encoding.UTF8.GetString(utf8bytes);
}

StringFormat format = new StringFormat();
format.LineAlignment = StringAlignment.Near;
switch (FHorizontalAlignInput[Slice].Index)
{
case 0: format.Alignment = StringAlignment.Near;break;
case 1:
format.Alignment = StringAlignment.Center;
layout.X = width/2;
break;
case 2:
format.Alignment = StringAlignment.Far;
layout.X = width;
break;
}

switch (FVerticalAlignInput[Slice].Index)
{
case 0: format.LineAlignment = StringAlignment.Near;break;
case 1:
format.LineAlignment = StringAlignment.Center;
layout.Y = height/2;
break;
case 2:
format.LineAlignment = StringAlignment.Far;
layout.Y = height;
break;
}

SizeF size = g.MeasureString(text, objFont, layout.Size, format);
FSizeOutput[Slice] = new Vector2D(width/size.Width,height/size.Height);
if (!string.IsNullOrEmpty(text))
{
switch (renderingMode)
{
case 0: text = text.Replace("\n"," ").Replace("\n",string.Empty); break;
case 1: break;
case 2: layout.Size= new SizeF(width,height);break;
}
if (FCharEncoding[Slice] == "UTF8")
{
byte[] utf8bytes = Encoding.Default.GetBytes(text);
text = Encoding.UTF8.GetString(utf8bytes);
}


format.LineAlignment = StringAlignment.Near;
switch (FHorizontalAlignInput[Slice].Index)
{
case 0: format.Alignment = StringAlignment.Near;break;
case 1:
format.Alignment = StringAlignment.Center;
layout.X = width/2;
break;
case 2:
format.Alignment = StringAlignment.Far;
layout.X = width;
break;
}

switch (FVerticalAlignInput[Slice].Index)
{
case 0: format.LineAlignment = StringAlignment.Near;break;
case 1:
format.LineAlignment = StringAlignment.Center;
layout.Y = height/2;
break;
case 2:
format.LineAlignment = StringAlignment.Far;
layout.Y = height;
break;
}

float scx = 1; float scy = 1;
switch (FNormalizeInput[Slice].Index)
{
case 0: break;
case 1: scx = width/size.Width; break;
case 2: scy = height/size.Height; break;
case 3:
scx = width/size.Width;
scy = height/size.Height;
break;
}
FScaleOutput[Slice]=new Vector2D(scx,scy);
SizeF size = g.MeasureString(text, objFont, layout.Size, format);
FSizeOutput[Slice] = new Vector2D(width/size.Width,height/size.Height);

float scx = 1; float scy = 1;
switch (FNormalizeInput[Slice].Index)
{
case 0: break;
case 1: scx = width/size.Width; break;
case 2: scy = height/size.Height; break;
case 3:
scx = width/size.Width;
scy = height/size.Height;
break;
}
FScaleOutput[Slice]=new Vector2D(scx,scy);

g.TranslateTransform(layout.X,layout.Y);
g.ScaleTransform(scx,scy);
g.TranslateTransform(-layout.X,-layout.Y);


if (renderingMode ==2)
layout.Location = new PointF(0,0);

g.TranslateTransform(layout.X,layout.Y);
g.ScaleTransform(scx,scy);
g.TranslateTransform(-layout.X,-layout.Y);
}
else
FScaleOutput[Slice]=new Vector2D(0,0);

if (renderingMode ==2)
layout.Location = new PointF(0,0);

RGBAColor tmpBrush = FColorInput[Slice];
tmpBrush.A=0;
Expand Down
13 changes: 8 additions & 5 deletions vvvv45/src/nodes/plugins/_SpreadOperations/DeleteSlice.cs
Expand Up @@ -19,10 +19,10 @@ public class DeleteSlice<T> : IPluginEvaluate
{
#region fields & pins
[Input("Input", BinSize = 1, BinName = "Bin Size")]
ISpread<ISpread<T>> FInput;
IDiffSpread<ISpread<T>> FInput;

[Input("Index")]
ISpread<int> FIndex;
IDiffSpread<int> FIndex;

[Output("Output")]
ISpread<ISpread<T>> FOutput;
Expand All @@ -31,9 +31,12 @@ public class DeleteSlice<T> : IPluginEvaluate
//called when data for any output pin is requested
public void Evaluate(int SpreadMax)
{
FOutput.AssignFrom(FInput);
foreach (int i in FIndex.Select(x => x%FInput.SliceCount).Distinct().OrderByDescending(x => x))
FOutput.RemoveAt(i);
if (FInput.IsChanged || FIndex.IsChanged)
{
FOutput.AssignFrom(FInput);
foreach (int i in FIndex.Select(x => x%FInput.SliceCount).Distinct().OrderByDescending(x => x))
FOutput.RemoveAt(i);
}
}
}

Expand Down

0 comments on commit 2ee0132

Please sign in to comment.