| 96 | | if (device.tracking) device.new_Object(this); |
|---|
| | 96 | init_(); |
|---|
| | 97 | } |
|---|
| | 98 | |
|---|
| | 99 | /** |
|---|
| | 100 | * Constructs a new Path that is a copy of <code>path</code>. If |
|---|
| | 101 | * <code>flatness</code> is less than or equal to zero, an unflatten |
|---|
| | 102 | * copy of the path is created. Otherwise, it specifies the maximum |
|---|
| | 103 | * error between the path and its flatten copy. Smaller numbers give |
|---|
| | 104 | * better approximation. |
|---|
| | 105 | * <p> |
|---|
| | 106 | * This operation requires the operating system's advanced |
|---|
| | 107 | * graphics subsystem which may not be available on some |
|---|
| | 108 | * platforms. |
|---|
| | 109 | * </p> |
|---|
| | 110 | * |
|---|
| | 111 | * @param device the device on which to allocate the path |
|---|
| | 112 | * @param path the path to make a copy |
|---|
| | 113 | * @param flatness the flatness value |
|---|
| | 114 | * |
|---|
| | 115 | * @exception IllegalArgumentException <ul> |
|---|
| | 116 | * <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device</li> |
|---|
| | 117 | * <li>ERROR_NULL_ARGUMENT - if the path is null</li> |
|---|
| | 118 | * <li>ERROR_INVALID_ARGUMENT - if the path has been disposed</li> |
|---|
| | 119 | * </ul> |
|---|
| | 120 | * @exception DWTException <ul> |
|---|
| | 121 | * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
|---|
| | 122 | * </ul> |
|---|
| | 123 | * @exception DWTError <ul> |
|---|
| | 124 | * <li>ERROR_NO_HANDLES if a handle for the path could not be obtained</li> |
|---|
| | 125 | * </ul> |
|---|
| | 126 | * |
|---|
| | 127 | * @see #dispose() |
|---|
| | 128 | * @since 3.4 |
|---|
| | 129 | */ |
|---|
| | 130 | public this (Device device, Path path, float flatness) { |
|---|
| | 131 | super(device); |
|---|
| | 132 | if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 133 | if (path.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
|---|
| | 134 | flatness = Math.max(0, flatness); |
|---|
| | 135 | handle = Gdip.GraphicsPath_Clone(path.handle); |
|---|
| | 136 | if (flatness !is 0) Gdip.GraphicsPath_Flatten(handle, null, flatness); |
|---|
| | 137 | if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); |
|---|
| | 138 | init_(); |
|---|
| | 139 | } |
|---|
| | 140 | |
|---|
| | 141 | /** |
|---|
| | 142 | * Constructs a new with the specifed PathData. |
|---|
| | 143 | * <p> |
|---|
| | 144 | * This operation requires the operating system's advanced |
|---|
| | 145 | * graphics subsystem which may not be available on some |
|---|
| | 146 | * platforms. |
|---|
| | 147 | * </p> |
|---|
| | 148 | * |
|---|
| | 149 | * @param device the device on which to allocate the path |
|---|
| | 150 | * @param data the data for the path |
|---|
| | 151 | * |
|---|
| | 152 | * @exception IllegalArgumentException <ul> |
|---|
| | 153 | * <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device</li> |
|---|
| | 154 | * <li>ERROR_NULL_ARGUMENT - if the data is null</li> |
|---|
| | 155 | * </ul> |
|---|
| | 156 | * @exception DWTException <ul> |
|---|
| | 157 | * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
|---|
| | 158 | * </ul> |
|---|
| | 159 | * @exception DWTError <ul> |
|---|
| | 160 | * <li>ERROR_NO_HANDLES if a handle for the path could not be obtained</li> |
|---|
| | 161 | * </ul> |
|---|
| | 162 | * |
|---|
| | 163 | * @see #dispose() |
|---|
| | 164 | * @since 3.4 |
|---|
| | 165 | */ |
|---|
| | 166 | public this (Device device, PathData data) { |
|---|
| | 167 | this(device); |
|---|
| | 168 | if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 169 | init_(data); |
|---|
| | 525 | void init_(PathData data) { |
|---|
| | 526 | byte[] types = data.types; |
|---|
| | 527 | float[] points = data.points; |
|---|
| | 528 | for (int i = 0, j = 0; i < types.length; i++) { |
|---|
| | 529 | switch (types[i]) { |
|---|
| | 530 | case DWT.PATH_MOVE_TO: |
|---|
| | 531 | moveTo(points[j++], points[j++]); |
|---|
| | 532 | break; |
|---|
| | 533 | case DWT.PATH_LINE_TO: |
|---|
| | 534 | lineTo(points[j++], points[j++]); |
|---|
| | 535 | break; |
|---|
| | 536 | case DWT.PATH_CUBIC_TO: |
|---|
| | 537 | cubicTo(points[j++], points[j++], points[j++], points[j++], points[j++], points[j++]); |
|---|
| | 538 | break; |
|---|
| | 539 | case DWT.PATH_QUAD_TO: |
|---|
| | 540 | quadTo(points[j++], points[j++], points[j++], points[j++]); |
|---|
| | 541 | break; |
|---|
| | 542 | case DWT.PATH_CLOSE: |
|---|
| | 543 | close(); |
|---|
| | 544 | break; |
|---|
| | 545 | default: |
|---|
| | 546 | dispose(); |
|---|
| | 547 | DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
|---|
| | 548 | } |
|---|
| | 549 | } |
|---|
| | 550 | } |
|---|
| | 551 | |
|---|