Forráskód Böngészése

Cleanup and readme

Kevin Lee 11 hónapja
szülő
commit
d70f68e347
4 módosított fájl, 111 hozzáadás és 95 törlés
  1. 84 71
      README.md
  2. 21 21
      samples/config.yml
  3. 2 2
      src/config/mod.rs
  4. 4 1
      src/config/object.rs

+ 84 - 71
README.md

@@ -1,7 +1,7 @@
 # EzCAD Patcher
 
 This tool parses and patches EZCAD files with values specified in a YAML config file.
-The EZCAD format as implemented in this crate was reverse engineered from sample files, so use at your own risk.
+The EZCAD format as implemented in this crate was reverse engineered from sample files, so not all formats or options are supported.
 
 ## Usage
 
@@ -22,7 +22,7 @@ Options:
 
 Operations defined in the configuration file are applied in order of definition.
 
-### Patching Pen
+### Pen Operations
 
 Setting values of specific fields for a given pen:
 
@@ -30,13 +30,14 @@ Setting values of specific fields for a given pen:
 Ops: 
   - !PatchPen
     Pen: 0                  # Target pen
+
     # Specify one or more of the following:
-    # Color: [127, 127, 127]
-    # Enabled: true
-    # LoopCount: 3
-    # Speed: 1.234
-    # Power: 10.5
-    # Frequency: 10000
+    Color: [127, 127, 127]
+    Enabled: true
+    LoopCount: 3
+    Speed: 1.234
+    Power: 10.5
+    Frequency: 10000
 ```
 
 Cloning pen(s) (and optionally override settings):
@@ -46,14 +47,15 @@ Ops:
   - !ClonePen
     From: 0
     To: 1
+
     # Specify one or more of the following:
-    # Inclusive: true
-    # Color: [64, 64, 64]
-    # Enabled: true
-    # LoopCount: 3
-    # Speed: 1.234
-    # Power: 10.5
-    # Frequency: 10000
+    Inclusive: true
+    Color: [64, 64, 64]
+    Enabled: true
+    LoopCount: 3
+    Speed: 1.234
+    Power: 10.5
+    Frequency: 10000
 ```
 
 Incrementing a specific field by some value across a sequence of pens:
@@ -63,15 +65,14 @@ Ops:
   - !PatternPen
     From: 1
     To: 5
+
     # Specify one of the following:
-    # Field: !Loops 1
-    # Field: !Speed 100.0
-    # Field: !Power 10.0
-    # Field: !Frequency 1000
+    Field: !Loops 1
+    Field: !Speed 100.0
+    Field: !Power 10.0
+    Field: !Frequency 1000
 ```
 
-### Importing and Exporting Pens and Objects
-
 Exporting a pen to a file:
 
 ``` yaml
@@ -90,74 +91,86 @@ Ops:
     Path: "exported_pen.bin"
 ```
 
-Exporting an object to a file:
+### Object Operations
+
+Deleting all objects from a layer:
 
 ``` yaml
 Ops:
-  - !ExportObject
+  - !DeleteObjects
     Layer: 0
-    Object: 0
-    Path: "exported_object.bin"
+    Object: 3 # Optional, will delete specific object instead
 ```
 
-Importing an object from a file:
+All other operations:
 
 ``` yaml
 Ops:
-  - !ImportObject
-    Layer: 0
-    Object: 3 # Optional, will replace specified object instead
-    Path: "exported_object.bin"
+  - !Object
+    Input: <InputObject>
+
+    # Specify one or more of the following
+    Z: 0.0
+    Origin: { X: 10.0, Y: 10.0 }
+    Pen: 3
+    Layer: 2
+    Array: <ArrayOptions>
+    Hatch: <HatchOptions>
+    Export: "exported_object.bin"
+    ReplaceObject: 0
 ```
 
-### Deleting and Generating Objects
+`<InputObject>` can be one of the following:
 
-Deleting all objects from a layer:
+``` yaml
+Input: !Rectangle { Width: 3.0, Height: 2.0 }
+Input: !Circle { Radius: 3.0 }
+Input: !Import { Path: "exported_object.bin" }
+Input: !Existing { Layer: 0, Object: 1 }
+```
+
+`<ArrayOptions>` options:
 
 ``` yaml
-Ops:
-  - !DeleteObjects
-    Layer: 0
-    Object: 3 # Optional, will delete specific object instead
+Array:
+  Columns: 3
+  Rows: 2
+  Spacing: 1.0
+  RandomizeOrder: True
+  StartingPen: 1
 ```
 
-Generating a grid of hatched rectangles with incrementing pens:
+`<HatchOptions>` options:
 
 ``` yaml
-Ops:
-  - !HatchArray
-    Layer: 0
-    Width: 10.0
-    Height: 10.0
-    Columns: 3
-    Rows: 5
-    Spacing: 0.5
-    Z: 0.0
-    StartingPen: 0
-    Hatch:
-      LineSpacing: 0.01
-      # The following are optional parameters:
-      # Count: 2
-      # EdgeOffset: 0.0
-      # StartOffset: 0.0
-      # EndOffset: 0.0
-      # Angle: 0.0
-      # RotateAngle: 0.0
-      # LineRedution: 0.0
-      # LoopDistance: 0.0
-      # LoopCount: 0
-      # Pattern: !Bidirectional
-      # FollowEdgeOnce: true
-      # CrossHatch: true
+Hatch:
+  LineSpacing: 0.1
+
+  # Specify one or more of the following
+  Pen: 1
+  Count: 3
+  EdgeOffset: 0.0
+  StartOffset: 0.0
+  EndOffset: 0.0
+  Angle: 3.0
+  RotateAngle: 0.0
+  LineReduction: 0.0
+  LoopDistance: 0.0
+  LoopCount: 0.0
+  Pattern: <Pattern>
+  FollowEdgeOnce: True
+  Crosshatch: True
 ```
 
-Available patterns are:
+`<Pattern>` options:
 
-1. Directional
-2. Bidirectional
-3. Ring
-4. Continuous
-5. Gong
-6. Background (not supported)
-7. Fill
-8. Zigzag
+``` yaml
+Pattern: !Directional
+Pattern: !Bidirectional
+Pattern: !Ring
+Pattern: !Continuous
+Pattern: !Gong
+Pattern: !Background # (not supported)
+Pattern: !Fill
+Pattern: !Zigzag
+```

+ 21 - 21
samples/config.yml

@@ -32,49 +32,49 @@ Ops:
   #   Input: !Existing { Layer: 0, Object: 0 }
   #   Export: 'export.bin'
 
-  # - !ObjectOperation
-  #   Input: !Rectangle { Width: 2, Height: 3 }
+  - !Object
+    Input: !Rectangle { Width: 2, Height: 3 }
+    Z: 1.0
+    Origin: { X: 10.0, Y: 10.0 }
+    Pen: 1
+    Array:
+      Columns: 3
+      Rows: 2
+      Spacing: 6.0
+      RandomizeOrder: False
+      StartingPen: 0
+    Hatch:
+      LineSpacing: 0.01
+    ReplaceObject: 0
+
+  # - !Object
+  #   Input: !Existing { Layer: 0, Object: 0 }
   #   Z: 1.0
   #   Origin: { X: 10.0, Y: 10.0 }
   #   Pen: 1
   #   Array:
   #     Columns: 3
   #     Rows: 2
-  #     Spacing: 6.0
+  #     Spacing: 10.0
   #     RandomizeOrder: False
   #     StartingPen: 0
   #   # Hatch:
   #   #   LineSpacing: 0.01
   #   ReplaceObject: 0
 
-  - !ObjectOperation
-    Input: !Existing { Layer: 0, Object: 0 }
-    Z: 1.0
-    Origin: { X: 10.0, Y: 10.0 }
-    Pen: 1
-    Array:
-      Columns: 3
-      Rows: 2
-      Spacing: 10.0
-      RandomizeOrder: False
-      StartingPen: 0
-    # Hatch:
-    #   LineSpacing: 0.01
-    ReplaceObject: 0
-
-  # - !ObjectOperation
+  # - !Object
   #   Input: !Rectangle { Width: 10, Height: 5}
   #   Z: 0.0
   #   Origin: { X: 10.0, Y: 10.0 }
   #   Pen: 0
   #   ReplaceObject: 0
 
-  # - !ObjectOperation
+  # - !Object
   #   Input: !Existing { Layer: 0, Object: 0 }
   #   Origin: { X: 10.0, Y: 10.0 }
   #   ReplaceObject: 0
 
-  # - !ObjectOperation
+  # - !Object
   #   Input: !Existing { Layer: 0, Object: 1 }
   #   Origin: { X: 10.0, Y: 10.0 }
   #   ReplaceObject: 1

+ 2 - 2
src/config/mod.rs

@@ -17,7 +17,7 @@ pub enum Operation {
     ExportPen(ImportExportPen),
     ImportPen(ImportExportPen),
     DeleteObjects(DeleteObjects),
-    ObjectOperation(ObjectOperation),
+    Object(ObjectOperation),
 }
 
 pub trait Operations {
@@ -34,7 +34,7 @@ impl Operations for Vec<Operation> {
                 Operation::ImportPen(x) => x.import(pens),
                 Operation::ExportPen(x) => x.export(pens),
                 Operation::DeleteObjects(x) => x.delete(layers),
-                Operation::ObjectOperation(x) => x.process(pens, layers),
+                Operation::Object(x) => x.process(pens, layers),
             }
         }
     }

+ 4 - 1
src/config/object.rs

@@ -305,7 +305,10 @@ impl ObjectOperation {
         // Either export the object, replace an existing object, or append if neither
         if let Some(path) = &self.export {
             if new_objects.len() > 1 {
-                warn!("Exporting only the first object in list of objects");
+                warn!(
+                    "Exporting only object #0 from layer #{} in list of objects",
+                    layer_id
+                );
             } else {
                 debug!(
                     "Exporting object {} in layer #{} to '{}'",