Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions docs/dev/analysis/shp-freeform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ Use Case 2 - Specify points in custom coordinates
The next step up in complexity is where a custom coordinate system is to be
used to specify vertices for a single shape.

In this alternative, all the verticies are specified in custom coordinates
and a scaling factor is provided::
Here, 1000 local coordinate units represent one inch. The scale is the
length of one local unit in EMUs::

>>> freeform_builder = shapes.build_freeform(
... 1500, 1000, scale=1000/Inches(1)
... 1500, 1000, scale=Inches(1)/1000
... )
>>> freeform_builder.add_line_segments((
... (2000, 2000),
Expand Down Expand Up @@ -151,30 +151,27 @@ represent their position relative to this origin in the custom coordinates
provided. It is also up to the client to get the scaling factor right such
that the entire map fits in the intended area of the slide.

In this scenario, `top` and `left` arguments are added to the
`.build_freeform()` call. These arguments should be given the same values for
each of the "interlocking" shapes. These two arguments each independently
take on the value of zero when omitted, which produces the behavior of the
prior use case::
Pass the same `origin_x` and `origin_y` to `.convert_to_shape()` for each of
the interlocking shapes. Both offsets default to zero::

>>> freeform_builder = shapes.build_freeform(
... start_x=1500, start_y=1000, scale=1000/Inches(1),
... top=Inches(1), left=Inches(2)
... start_x=1500, start_y=1000, scale=Inches(1)/1000
... )
>>> freeform_builder.add_line_segments((
... (2000, 2000),
... (1000, 2000),
... (1500, 1000),
... ))
>>> freeform_shape = freeform_builder.convert_to_shape()
>>> freeform_shape = freeform_builder.convert_to_shape(
... origin_x=Inches(2), origin_y=Inches(1)
... )
>>> freeform_shape.left.inches, freeform_shape.top.inches
3.0, 2.0
>>> freeform_shape.width.inches, freeform_shape.height.inches
1.0, 1.0

As we can see here, the size of the shape is exactly the same, but it has
been translated to be relative to the slide coordinates provided in the
`.build_freeform()` call.
been translated by two inches horizontally and one inch vertically.


Use Case 4 - Specify position on conversion
Expand Down Expand Up @@ -216,7 +213,7 @@ Candidate Protocol

Obtain a FreeformBuilder object::

>>> freeform_builder = shapes.build_freeform(50, 0, scale=100/Inches(1))
>>> freeform_builder = shapes.build_freeform(50, 0, scale=Inches(1)/100)
>>> freeform_builder
<pptx.shapes.freeform.FreeformBuilder objext at 0x...>

Expand Down