mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-11 21:48:34 +00:00
+ Refactored Text3D to use StatementBuilder
This commit is contained in:
parent
0e47d85f42
commit
ddb0a319c9
@ -14,8 +14,7 @@ namespace OSCADSharp.ConsoleTests
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
var obj = new Cube(5, 5, 20)
|
||||
.Translate(30, 0, 0).Rotate(0, 90, 0).Resize(2, 2, 2);
|
||||
var obj = new Text3D("Whaat is thissss?");
|
||||
|
||||
var pos = obj.Position();
|
||||
var cyl1 = new Cylinder(1, 100, true).Translate(pos);
|
||||
@ -23,10 +22,10 @@ namespace OSCADSharp.ConsoleTests
|
||||
var cyl3 = new Cylinder(1, 100, true).Rotate(90, 0, 0).Translate(pos);
|
||||
var axisHelper = cyl1.Union(cyl2, cyl3).Color("Red");
|
||||
|
||||
var topCorner = new Sphere().Translate(obj.Bounds().TopRight);
|
||||
var botCorner = new Sphere().Translate(obj.Bounds().BottomLeft);
|
||||
//var topCorner = new Sphere().Translate(obj.Bounds().TopRight);
|
||||
//var botCorner = new Sphere().Translate(obj.Bounds().BottomLeft);
|
||||
|
||||
(obj + topCorner + botCorner + axisHelper).ToFile("test.scad");
|
||||
(obj + axisHelper).ToFile("test.scad");
|
||||
|
||||
//Console.ReadKey();
|
||||
}
|
||||
|
||||
@ -107,22 +107,22 @@ namespace OSCADSharp.Solids
|
||||
/// <returns>Script for this object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StatementBuilder sb = new StatementBuilder();
|
||||
sb.Append("text(");
|
||||
sb.Append("\"");
|
||||
sb.Append(this.Text);
|
||||
sb.Append("\"");
|
||||
|
||||
appendIfValueNotNullOrEmpty("size", this.Size?.ToString(), sb);
|
||||
sb.AppendValuePairIfExists("size", this.Size?.ToString(), true);
|
||||
// Text is always centered in OSCADSharp to ensure correctness of
|
||||
// position interpolation
|
||||
appendIfValueNotNullOrEmpty("halign", "\"center\"", sb);
|
||||
appendIfValueNotNullOrEmpty("valign", "\"center\"", sb);
|
||||
sb.AppendValuePairIfExists("halign", "\"center\"", true);
|
||||
sb.AppendValuePairIfExists("valign", "\"center\"", true);
|
||||
|
||||
appendIfValueNotNullOrEmpty("font", this.Font, sb);
|
||||
appendIfValueNotNullOrEmpty("spacing", this.Spacing?.ToString(), sb);
|
||||
appendIfValueNotNullOrEmpty("direction", this.TextDirection?.ToString(), sb);
|
||||
appendIfValueNotNullOrEmpty("language", this.Language?.ToString(), sb);
|
||||
sb.AppendValuePairIfExists("font", this.Font, true);
|
||||
sb.AppendValuePairIfExists("spacing", this.Spacing?.ToString(), true);
|
||||
sb.AppendValuePairIfExists("direction", this.TextDirection?.ToString(), true);
|
||||
sb.AppendValuePairIfExists("language", this.Language?.ToString(), true);
|
||||
|
||||
sb.Append(");");
|
||||
sb.Append(Environment.NewLine);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user