PageRenderTime 33ms CodeModel.GetById 1ms app.highlight 27ms RepoModel.GetById 1ms app.codeStats 0ms

/dmagick/c/draw.d

http://github.com/MikeWey/DMagick
D | 558 lines | 333 code | 105 blank | 120 comment | 9 complexity | 2ab75ab97b90be7161e010503d31aca3 MD5 | raw file
  1module dmagick.c.draw;
  2
  3import dmagick.c.color;
  4import dmagick.c.composite;
  5import dmagick.c.geometry;
  6import dmagick.c.image;
  7import dmagick.c.magickType;
  8import dmagick.c.magickVersion;
  9import dmagick.c.pixel;
 10import dmagick.c.type;
 11
 12extern(C)
 13{
 14	/**
 15	 * Specify text alignment.
 16	 */
 17	enum AlignType
 18	{
 19		UndefinedAlign, /// No alignment specified. Equivalent to LeftAlign.
 20		LeftAlign,      /// Align the leftmost part of the text to the starting point.
 21		CenterAlign,    /// Center the text around the starting point.
 22		RightAlign      /// Align the rightmost part of the text to the starting point.
 23	}
 24
 25	/**
 26	 * Defines the coordinate system for the contents of a clip path.
 27	 */
 28	enum ClipPathUnits
 29	{
 30		/** */
 31		UndefinedPathUnits,
 32
 33		/**
 34		 * The contents of the clipPath represent values in the current
 35		 * user coordinate system.
 36		 */
 37		UserSpace,
 38
 39		/**
 40		 * The contents of the clipPath represent values in the current
 41		 * user coordinate system in place at the time when the clipPath
 42		 * element is referenced.
 43		 */
 44		UserSpaceOnUse,
 45
 46		/**
 47		 * The user coordinate system for the contents of the clipPath
 48		 * element is established using the bounding box of the element to
 49		 * which the clipping path is applied.
 50		 */
 51		ObjectBoundingBox
 52	}
 53
 54	/**
 55	 * Specify the text decoration.
 56	 */
 57	enum DecorationType
 58	{
 59		UndefinedDecoration,   ///
 60		NoDecoration,          /// Don't decorate the text.
 61		UnderlineDecoration,   /// Underline the text.
 62		OverlineDecoration,    /// Overline the text.
 63		LineThroughDecoration  /// Draw a horizontal line through the middle of the text.
 64	}
 65
 66	static if (MagickLibVersion >= 0x662)
 67	{
 68		/**
 69		 * Defines the text direction.
 70		 */
 71		enum DirectionType
 72		{
 73			UndefinedDirection,    ///
 74			RightToLeftDirection,  /// ditto
 75			LeftToRightDirection   /// ditto
 76		}
 77	}
 78	else
 79	{
 80		enum DirectionType
 81		{
 82			UndefinedDirection,
 83			LeftToRightDirection,
 84			RightToLeftDirection
 85		}
 86	}
 87
 88	/**
 89	 * FillRule indicates the algorithm which is to be used to determine
 90	 * what parts of the canvas are included inside the shape.
 91	 */
 92	enum FillRule
 93	{
 94		/** */
 95		UndefinedRule,
 96
 97		/**
 98		 * This rule determines the "insideness" of a point on the canvas by
 99		 * drawing a ray from that point to infinity in any direction and
100		 * counting the number of path segments from the given shape that
101		 * the ray crosses. If this number is odd, the point is inside; if
102		 * even, the point is outside.
103		 */
104		EvenOddRule,
105
106		/**
107		 * This rule determines the "insideness" of a point on the canvas by
108		 * drawing a ray from that point to infinity in any direction and
109		 * then examining the places where a segment of the shape crosses
110		 * the ray. Starting with a count of zero, add one each time a path
111		 * segment crosses the ray from left to right and subtract one each
112		 * time a path segment crosses the ray from right to left. After
113		 * counting the crossings, if the result is zero then the point is
114		 * outside the path. Otherwise, it is inside.
115		 */
116		NonZeroRule
117	}
118
119	enum GradientType
120	{
121		UndefinedGradient,
122		LinearGradient,
123		RadialGradient
124	}
125
126	/**
127	 * Specifies the shape to be used at the end of open subpaths when they
128	 * are stroked.
129	 * 
130	 * See_Also: $(LINK2 http://www.w3.org/TR/SVG/painting.html#StrokeLinecapProperty,
131	 *     the 'stroke-linecap' property) in the Scalable Vector Graphics (SVG)
132	 *     1.1 Specification.
133	 */
134	enum LineCap
135	{
136		UndefinedCap, ///
137		ButtCap,      /// ditto
138		RoundCap,     /// ditto
139		SquareCap     /// ditto
140	}
141
142	/**
143	 * Specifies the shape to be used at the corners of paths or basic
144	 * shapes when they are stroked.
145	 * 
146	 * See_Also: $(LINK2 http://www.w3.org/TR/SVG/painting.html#StrokeLinejoinProperty,
147	 *     the 'stroke-linejoin' property) in the Scalable Vector Graphics (SVG)
148	 *     1.1 Specification.
149	 */
150	enum LineJoin
151	{
152		UndefinedJoin, ///
153		MiterJoin,     /// ditto
154		RoundJoin,     /// ditto
155		BevelJoin      /// ditto
156	}
157
158	/**
159	 * Specify how pixel colors are to be replaced in the image.
160	 */
161	enum PaintMethod
162	{
163		/** */
164		UndefinedMethod,
165
166		/**
167		 * Replace pixel color at point.
168		 */
169		PointMethod,
170
171		/**
172		 * Replace color for all image pixels matching color at point.
173		 */
174		ReplaceMethod,
175
176		/**
177		 * Replace color for pixels surrounding point until encountering
178		 * pixel that fails to match color at point.
179		 */
180		FloodfillMethod,
181
182		/**
183		 * Replace color for pixels surrounding point until encountering
184		 * pixels matching border color.
185		 */
186		FillToBorderMethod,
187
188		/**
189		 * Replace colors for all pixels in image with fill color.
190		 */
191		ResetMethod
192	}
193
194	enum PrimitiveType
195	{
196		UndefinedPrimitive,
197		PointPrimitive,
198		LinePrimitive,
199		RectanglePrimitive,
200		RoundRectanglePrimitive,
201		ArcPrimitive,
202		EllipsePrimitive,
203		CirclePrimitive,
204		PolylinePrimitive,
205		PolygonPrimitive,
206		BezierPrimitive,
207		ColorPrimitive,
208		MattePrimitive,
209		TextPrimitive,
210		ImagePrimitive,
211		PathPrimitive
212	}
213
214	enum ReferenceType
215	{
216		UndefinedReference,
217		GradientReference
218	}
219
220	enum SpreadMethod
221	{
222		UndefinedSpread,
223		PadSpread,
224		ReflectSpread,
225		RepeatSpread
226	}
227
228	struct PointInfo
229	{
230		double
231			x,
232			y;
233	}
234
235	struct StopInfo
236	{
237		MagickPixelPacket
238			color;
239
240		MagickRealType
241			offset;
242	}
243
244	struct GradientInfo
245	{
246		GradientType
247			type;
248
249		RectangleInfo
250			bounding_box;
251
252		SegmentInfo
253			gradient_vector;
254
255		StopInfo*
256			stops;
257
258		size_t
259			number_stops;
260
261		SpreadMethod
262			spread;
263
264		MagickBooleanType
265			ddebug;
266
267		size_t
268			signature;
269
270		PointInfo
271			center;
272
273		MagickRealType
274			radius;
275
276		static if ( MagickLibVersion >= 0x693 )
277		{
278			MagickRealType
279				angle;
280
281			PointInfo
282				radii;
283		}
284	}
285
286	struct ElementReference
287	{
288		char*
289			id;
290
291		ReferenceType
292			type;
293
294		GradientInfo
295			gradient;
296
297		size_t
298			signature;
299
300		ElementReference*
301			previous,
302			next;
303	}
304
305	struct DrawInfo
306	{
307		char*
308			primitive,
309			geometry;
310
311		RectangleInfo
312			viewbox;
313
314		AffineMatrix
315			affine;
316
317		GravityType
318			gravity;
319
320		PixelPacket
321			fill,
322			stroke;
323
324		double
325			stroke_width;
326
327		GradientInfo
328			gradient;
329
330		Image*
331			fill_pattern,
332			tile,
333			stroke_pattern;
334
335		MagickBooleanType
336			stroke_antialias,
337			text_antialias;
338
339		FillRule
340			fill_rule;
341
342		LineCap
343			linecap;
344
345		LineJoin
346			linejoin;
347
348		size_t
349			miterlimit;
350
351		double
352			dash_offset;
353
354		DecorationType
355			decorate;
356
357		CompositeOperator
358			compose;
359
360		char*
361			text;
362
363		size_t
364			face;
365
366		char*
367			font,
368			metrics,
369			family;
370
371		StyleType
372			style;
373
374		StretchType
375			stretch;
376
377		size_t
378			weight;
379
380		char*
381			encoding;
382
383		double
384			pointsize;
385
386		char*
387			density;
388
389		AlignType
390			aalign;
391
392		PixelPacket
393			undercolor,
394			border_color;
395
396		char*
397			server_name;
398
399		double*
400			dash_pattern;
401
402		char*
403			clip_mask;
404
405		SegmentInfo
406			bounds;
407
408		ClipPathUnits
409			clip_units;
410
411		Quantum
412			opacity;
413
414		MagickBooleanType
415			render;
416
417		ElementReference
418			element_reference;
419
420		MagickBooleanType
421			ddebug;
422
423		size_t
424			signature;
425
426		double
427			kerning,
428			interword_spacing,
429			interline_spacing;
430
431		static if (MagickLibVersion >= 0x662)
432		{
433			DirectionType
434				direction;
435		}
436		else static if (MagickLibVersion == 0x661)
437		{
438			double
439				direction;
440		}
441
442		static if (MagickLibVersion >= 0x695)
443		{
444			double
445				fill_opacity,
446				stroke_opacity;
447		}
448
449		static if (MagickLibVersion >= 0x699)
450		{
451			MagickBooleanType
452				clip_path;
453
454			Image*
455				clipping_mask;
456
457			ComplianceType
458				compliance;
459
460			Image*
461				composite_mask;
462		}
463	}
464
465	struct PrimitiveInfo
466	{
467		PointInfo
468			point;
469
470		size_t
471			coordinates;
472
473		PrimitiveType
474			primitive;
475
476		PaintMethod
477			method;
478
479		char*
480			text;
481
482		static if (MagickLibVersion >= 0x699)
483		{
484			MagickBooleanType
485				closed_subpath;
486		}
487	}
488
489	/**
490	 * This is used to reprecent text/font mesurements.
491	 */
492	struct TypeMetric
493	{
494		/**
495		 * Horizontal (x) and vertical (y) pixels per em.
496		 */
497		PointInfo pixels_per_em;
498
499		/**
500		 * The distance in pixels from the text baseline to the
501		 * highest/upper grid coordinate used to place an outline point.
502		 * Always a positive value.
503		 */
504		double ascent;
505
506		/**
507		 * The distance in pixels from the baseline to the lowest grid
508		 * coordinate used to place an outline point.
509		 * Always a negative value.
510		 */
511		double descent;
512
513		/**
514		 * Text width in pixels.
515		 */
516		double width;
517
518		/**
519		 * Text height in pixels.
520		 */
521		double height;
522
523		/**
524		 * The maximum horizontal advance (advance from the beginning
525		 * of a character to the beginning of the next character) in
526		 * pixels.
527		 */
528		double max_advance;
529
530		double underline_position;  ///
531		double underline_thickness; ///
532
533		/**
534		 * This is an imaginary box that encloses all glyphs from the font,
535		 * usually as tightly as possible.
536		 */
537		SegmentInfo bounds;
538
539		/**
540		 * A virtual point, located on the baseline, used to locate glyphs.
541		 */
542		PointInfo origin;
543	}
544
545	DrawInfo* AcquireDrawInfo();
546	DrawInfo* CloneDrawInfo(const(ImageInfo)*, const(DrawInfo)*);
547	DrawInfo* DestroyDrawInfo(DrawInfo*);
548
549	MagickBooleanType DrawAffineImage(Image*, const(Image)*, const(AffineMatrix)*);
550	MagickBooleanType DrawClipPath(Image*, const(DrawInfo)*, const(char)*);
551	MagickBooleanType DrawGradientImage(Image*, const(DrawInfo)*);
552	MagickBooleanType DrawImage(Image*, const(DrawInfo)*);
553	MagickBooleanType DrawPatternPath(Image*, const(DrawInfo)*, const(char)*, Image**);
554	MagickBooleanType DrawPrimitive(Image*, const(DrawInfo)*, const(PrimitiveInfo)*);
555
556	void GetAffineMatrix(AffineMatrix*);
557	void GetDrawInfo(const(ImageInfo)*, DrawInfo*);
558}