# HG changeset patch # User Jordan Miner # Date 1341617985 18000 # Node ID 5c8c1c2e12c045f673963d7b358c547851ace35c # Parent 73060bc3f004e9a9fd1093bf4add6a58afafd917 Change from real to double. double is not dependant on the platform, and it uses less space. diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/core/benchmark.d --- a/dynamin/core/benchmark.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/core/benchmark.d Fri Jul 06 18:39:45 2012 -0500 @@ -18,24 +18,24 @@ * Returns: The average number of milliseconds one call of the specified * delegate took. */ -real benchmark(int repetitions, void delegate() dg) { // use static opCall()? +double benchmark(int repetitions, void delegate() dg) { // use static opCall()? long time = Environment.runningTime; for(int i = 0; i < repetitions; ++i) dg(); - return (Environment.runningTime-time)/cast(real)repetitions; + return (Environment.runningTime-time)/cast(double)repetitions; } -real benchmark(void delegate() dg) { +double benchmark(void delegate() dg) { return benchmark(1, dg); } /** * name can be null */ -real benchmarkAndWrite(string name, int repetitions, void delegate() dg) { - real time = benchmark(repetitions, dg); +double benchmarkAndWrite(string name, int repetitions, void delegate() dg) { + double time = benchmark(repetitions, dg); Stdout.format("{} took {:.2}ms.", name, time).newline; // TODO: verify :.2 return time; } -real benchmarkAndWrite(string name, void delegate() dg) { +double benchmarkAndWrite(string name, void delegate() dg) { return benchmarkAndWrite(name, 1, dg); } diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/core/global.d --- a/dynamin/core/global.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/core/global.d Fri Jul 06 18:39:45 2012 -0500 @@ -69,7 +69,7 @@ * floatsEqual(3.14, 3.151, 0.01) == false * ----- */ -bool floatsEqual(real num1, real num2, real epsilon) { +bool floatsEqual(double num1, double num2, double epsilon) { return abs(num1 - num2) <= epsilon; } unittest { diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/gui/basic_theme.d --- a/dynamin/gui/basic_theme.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/gui/basic_theme.d Fri Jul 06 18:39:45 2012 -0500 @@ -137,7 +137,7 @@ } } - real ScrollBar_size() { + double ScrollBar_size() { // TODO: all themes should get this from SystemGui.ScrollBarSize return 18; } diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/gui/container.d --- a/dynamin/gui/container.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/gui/container.d Fri Jul 06 18:39:45 2012 -0500 @@ -233,12 +233,12 @@ * If there is no child control at the point, null is returned. The returned * control, if any, is a direct child of this container. */ - Control getChildAtPoint(real[] pt) { + Control getChildAtPoint(double[] pt) { assert(pt.length == 2, "pt must be just an x and y"); return getChildAtPoint(Point(pt[0], pt[1])); } /// ditto - Control getChildAtPoint(real x, real y) { + Control getChildAtPoint(double x, double y) { return getChildAtPoint(Point(x, y)); } /// ditto @@ -256,12 +256,12 @@ * Never returns null. If there is no descendant at the specified point, * this container will be returned. */ - Control getDescendantAtPoint(real[] pt) { + Control getDescendantAtPoint(double[] pt) { assert(pt.length == 2, "pt must be just an x and y"); return getDescendantAtPoint(Point(pt[0], pt[1])); } /// ditto - Control getDescendantAtPoint(real x, real y) { + Control getDescendantAtPoint(double x, double y) { return getDescendantAtPoint(Point(x, y)); } /// ditto @@ -296,14 +296,14 @@ minSizeChanged(new EventArgs); } /// ditto - void minSize(real[] size) { + void minSize(double[] size) { assert(size.length == 2, "size must be just a width and height"); minSize = Size(size[0], size[1]); } /// - real minWidth() { return _minSize.width; } + double minWidth() { return _minSize.width; } /// - real minHeight() { return _minSize.height; } + double minHeight() { return _minSize.height; } /** * Gets or sets the maximum size of this window. A maximum width or @@ -319,14 +319,14 @@ minSizeChanged(new EventArgs); } /// ditto - void maxSize(real[] size) { + void maxSize(double[] size) { assert(size.length == 2, "size must be just a width and height"); maxSize = Size(size[0], size[1]); } /// - real maxWidth() { return _maxSize.width; } + double maxWidth() { return _maxSize.width; } /// - real maxHeight() { return _maxSize.height; } + double maxHeight() { return _maxSize.height; } /** * Causes this container to position its child controls. Called on every diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/gui/control.d --- a/dynamin/gui/control.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/gui/control.d Fri Jul 06 18:39:45 2012 -0500 @@ -409,7 +409,7 @@ return pt.x >= 0 && pt.y >= 0 && pt.x < width && pt.y < height; } /// ditto - bool contains(real x, real y) { + bool contains(double x, double y) { return contains(Point(x, y)); } @@ -481,7 +481,7 @@ moved(new EventArgs); } /// ditto - void location(real[] pt) { + void location(double[] pt) { assert(pt.length == 2, "pt must be just an x and y"); location = Point(pt[0], pt[1]); } @@ -511,7 +511,7 @@ resized(new EventArgs); } /// ditto - void size(real[] newSize) { + void size(double[] newSize) { assert(newSize.length == 2, "size must be just a width and height"); size = Size(newSize[0], newSize[1]); } @@ -533,13 +533,13 @@ int baseline() { return 0; } /// Same as location.x - real x() { return location.x; } + double x() { return location.x; } /// Same as location.y - real y() { return location.y; } + double y() { return location.y; } /// Same as size.width - real width() { return size.width; } + double width() { return size.width; } /// Same as size.height - real height() { return size.height; } + double height() { return size.height; } /** * Gets or sets whether this control is elastic horizontally or vertically. @@ -647,7 +647,7 @@ _parent.repaint(rect + location); } /// ditto - void repaint(real x, real y, real width, real height) { + void repaint(double x, double y, double width, double height) { repaint(Rect(x, y, width, height)); } /** diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/gui/events.d --- a/dynamin/gui/events.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/gui/events.d Fri Jul 06 18:39:45 2012 -0500 @@ -45,7 +45,7 @@ MouseButton _button; public: /// - this(real x, real y, MouseButton b) { + this(double x, double y, MouseButton b) { _location = Point(x, y); _button = b; } @@ -54,9 +54,9 @@ /// void location(Point pt) { _location = pt; } /// - real x() { return _location.x; } + double x() { return _location.x; } /// - real y() { return _location.y; } + double y() { return _location.y; } /// MouseButton button() { return _button; } string toString() { diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/gui/layout.d --- a/dynamin/gui/layout.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/gui/layout.d Fri Jul 06 18:39:45 2012 -0500 @@ -181,11 +181,11 @@ TableInfo info; getTableSizes(colsInfo, rowsInfo, info); - real extraWidth = rect.width - bestSize.width; - real extraHeight = rect.height - bestSize.height; + double extraWidth = rect.width - bestSize.width; + double extraHeight = rect.height - bestSize.height; - void distExtra(ref real extra, ref ColRowInfo info, - ref real totalElastic, ref int semis, Elasticity e) { + void distExtra(ref double extra, ref ColRowInfo info, + ref double totalElastic, ref int semis, Elasticity e) { if(info.elastic == Elasticity.No || extra <= 0) return; if(e == Elasticity.Semi && @@ -202,11 +202,11 @@ info.bestSize += thisExtra; } } - real y = 0; + double y = 0; for(int row = 0; row < numRows; ++row) { // go over each row distExtra(extraHeight, rowsInfo[row], info.elasticHeight, info.semiRows, elasticY); - real x = 0; + double x = 0; for(int col = 0; col < numColumns; ++col) { distExtra(extraWidth, colsInfo[col], info.elasticWidth, info.semiColumns, elasticX); @@ -238,16 +238,16 @@ //}}} struct ColRowInfo { - real bestSize = 0; // large enough to hold the largest control + double bestSize = 0; // large enough to hold the largest control Elasticity elastic = Elasticity.No; bool filler = true; // if the entire column/row is filler - real baseline; // only applies to rows: max baseline in row + double baseline; // only applies to rows: max baseline in row } struct TableInfo { // number of semi-elastic columns/rows int semiColumns = 0; int semiRows = 0; // the sum of fully elastic width/height, not including semi - real elasticWidth = 0, elasticHeight = 0; + double elasticWidth = 0, elasticHeight = 0; Size bestSize; } //{{{ getTableSizes() @@ -262,7 +262,7 @@ assert(colsInfo.length == numColumns); assert(rowsInfo.length == numRows); - real max = 0; + double max = 0; LayoutGroup* l; bool prevNonFiller = false; @@ -289,7 +289,7 @@ } prevNonFiller = false; - real maxBl = 0; + double maxBl = 0; sp = 0; for(int row = 0; row < numRows; ++row) { // go over each row for(int col = 0; col < numColumns; ++col) { diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/gui/scroll_bar.d --- a/dynamin/gui/scroll_bar.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/gui/scroll_bar.d Fri Jul 06 18:39:45 2012 -0500 @@ -49,10 +49,10 @@ ScrollBarThumb _thumb; ArrowButton _button1, _button2; int _value = 0, _maxValue = 100; - real _visibleValue = 0.5; - real _thumbDragLoc = -1; + double _visibleValue = 0.5; + double _thumbDragLoc = -1; // stores the location of the thumb as a percentage of the track - real _thumbPos; + double _thumbPos; this() { valueChanged.setUp(&whenValueChanged); @@ -96,15 +96,15 @@ void whenButton2MouseDown(MouseEventArgs e) { value = value + 10; } - void putControl(Control c, real location, real size); - real breadth(); - real length(); + void putControl(Control c, double location, double size); + double breadth(); + double length(); override void whenResized(EventArgs e) { updateControls(); } - void layoutControls(Control[] controls, real[] sizes) { + void layoutControls(Control[] controls, double[] sizes) { assert(controls.length == sizes.length); - real loc = 0; + double loc = 0; for(int i = 0; i < controls.length; ++i) { putControl(controls[i], loc, sizes[i]); loc += sizes[i]; @@ -118,7 +118,7 @@ } // if thumbPos does not represent the current value if(cast(int)(_thumbPos * _maxValue) != _value) - _thumbPos = _value / cast(real)_maxValue; + _thumbPos = _value / cast(double)_maxValue; auto totalSz = length; auto buttonSz = breadth; auto totalTrackSz = totalSz - buttonSz*2; @@ -160,9 +160,9 @@ return Size(100, Theme.current.ScrollBar_size()); } /// - real thumbLocation(); + double thumbLocation(); /// ditto - void thumbLocation(real loc) { + void thumbLocation(double loc) { // TODO: return if no thumb (too small for one) if(loc < trackStart) loc = trackStart; @@ -176,13 +176,13 @@ updateControls(); } /// - real thumbSize(); + double thumbSize(); /// - real trackStart(); + double trackStart(); /// - real trackEnd(); + double trackEnd(); /// - real trackSize() { return trackEnd-trackStart; } + double trackSize() { return trackEnd-trackStart; } /// int value() { return _value; } /// ditto @@ -218,9 +218,9 @@ * minimum size, and a value of 1 makes the thumb take up all of the track. * The default is 0.5. */ - real visibleValue() { return _visibleValue; } + double visibleValue() { return _visibleValue; } /// ditto - void visibleValue(real val) { + void visibleValue(double val) { if(val < 0) val = 0; else if(val > 1) @@ -245,17 +245,17 @@ _thumb.state = ButtonState.Pressed; thumbLocation = e.location.x + _thumb.location.x - _thumbDragLoc; } - void putControl(Control c, real location, real size) { + void putControl(Control c, double location, double size) { c.location = [location, 0.0]; c.size = [size, height]; } - real breadth() { return height; } - real length() { return width; } + double breadth() { return height; } + double length() { return width; } alias ScrollBar.thumbLocation thumbLocation; - real thumbLocation() { return _thumb.x; } - real thumbSize() { return _thumb.width; } - real trackStart() { return _track1.x; } - real trackEnd() { return _track2.x+_track2.width; } + double thumbLocation() { return _thumb.x; } + double thumbSize() { return _thumb.width; } + double trackStart() { return _track1.x; } + double trackEnd() { return _track2.x+_track2.width; } } /// class VScrollBar : ScrollBar { @@ -271,16 +271,16 @@ _thumb.state = ButtonState.Pressed; thumbLocation = e.location.y + _thumb.location.y - _thumbDragLoc; } - void putControl(Control c, real location, real size) { + void putControl(Control c, double location, double size) { c.location = [0.0, location]; c.size = [width, size]; } - real breadth() { return width; } - real length() { return height; } + double breadth() { return width; } + double length() { return height; } alias ScrollBar.thumbLocation thumbLocation; - real thumbLocation() { return _thumb.y; } - real thumbSize() { return _thumb.height; } - real trackStart() { return _track1.y; } - real trackEnd() { return _track2.y+_track2.height; } + double thumbLocation() { return _thumb.y; } + double thumbSize() { return _thumb.height; } + double trackStart() { return _track1.y; } + double trackEnd() { return _track2.y+_track2.height; } } diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/gui/scrollable.d --- a/dynamin/gui/scrollable.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/gui/scrollable.d Fri Jul 06 18:39:45 2012 -0500 @@ -126,8 +126,8 @@ ScrollBar _hScrollBar, _vScrollBar; ScrollableClipper _clipper; - real _sbSize; - real _leftControlsWidth, _topControlsHeight; + double _sbSize; + double _leftControlsWidth, _topControlsHeight; // the area the content could be shown if no scroll bars Rect _availableRect; // the area the content is actually visible, after scroll bars are @@ -273,14 +273,14 @@ * Gets the combined width of all the controls docked on the left side of * this scrollable. */ - real leftControlsWidth() { + double leftControlsWidth() { return _leftControlsWidth; } /** * Gets the combined height of all the controls docked on the top side of * this scrollable. */ - real topControlsHeight() { + double topControlsHeight() { return _topControlsHeight; } diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/gui/silver_theme.d --- a/dynamin/gui/silver_theme.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/gui/silver_theme.d Fri Jul 06 18:39:45 2012 -0500 @@ -47,7 +47,7 @@ private Color _black = Color(0, 0, 0); private Color _white = Color(255, 255, 255); //{{{ common - void drawButtonBack(Graphics g, real x, real y, real width, real height, ButtonState state) { + void drawButtonBack(Graphics g, double x, double y, double width, double height, ButtonState state) { with(g) { if(state == ButtonState.Normal) source = _silver; @@ -157,7 +157,7 @@ } } - real ScrollBar_size() { + double ScrollBar_size() { // TODO: all themes should get this from SystemGui.ScrollBarSize return 18; } diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/gui/theme.d --- a/dynamin/gui/theme.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/gui/theme.d Fri Jul 06 18:39:45 2012 -0500 @@ -21,7 +21,7 @@ * left and top are drawn with the first color, and the right and * bottom are drawn with the second color. */ -void draw3dRectangle(Graphics g, real x, real y, real width, real height, +void draw3dRectangle(Graphics g, double x, double y, double width, double height, Color c1, Color c2) { g.lineWidth = 1; @@ -38,7 +38,7 @@ g.stroke(); } -void drawCheckerboard(Graphics g, real x, real y, real width, real height, +void drawCheckerboard(Graphics g, double x, double y, double width, double height, Color c1, Color c2, int squareSize = 1) { drawCheckerboard(g, Rect(x, y, width, height), c1, c2, squareSize); } @@ -116,7 +116,7 @@ void RadioButton_paint(CheckBox c, Graphics g); void ScrollBarTrack_paint(ScrollBarTrack c, Graphics g); void ScrollBarThumb_paint(ScrollBarThumb c, Graphics g); - real ScrollBar_size(); + double ScrollBar_size(); void ArrowButton_paint(ArrowButton c, Graphics g); BorderSize Scrollable_borderSize(Scrollable c); void Scrollable_paint(Scrollable c, Graphics g); diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/gui/windows_theme.d --- a/dynamin/gui/windows_theme.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/gui/windows_theme.d Fri Jul 06 18:39:45 2012 -0500 @@ -162,7 +162,7 @@ } /// draws a classic check, which is 7 wide and 7 high - void drawCheck(Graphics g, real x, real y) { + void drawCheck(Graphics g, double x, double y) { g.source = getColor(COLOR_WINDOWTEXT); auto checkYs = [2, 3, 4, 3, 2, 1, 0]; foreach(i, cy; checkYs) { @@ -172,7 +172,7 @@ } } /// draws a dotted focus rectangle - void drawFocus(Graphics g, int colorIndex, real x, real y, real w, real h) { + void drawFocus(Graphics g, int colorIndex, double x, double y, double w, double h) { g.lineWidth = 1; g.source = getColor(colorIndex); g.setDash([1, 1], 0.5); @@ -405,7 +405,7 @@ getColor(COLOR_3DHIGHLIGHT), getColor(COLOR_3DSHADOW)); } - real ScrollBar_size() { + double ScrollBar_size() { // TODO: all themes should get this from SystemGui.ScrollBarSize version(Windows) return GetSystemMetrics(SM_CXVSCROLL); diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/painting/color.d --- a/dynamin/painting/color.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/painting/color.d Fri Jul 06 18:39:45 2012 -0500 @@ -40,16 +40,16 @@ this.b = b/255.0; this.a = a/255.0; } - this(real r, real g, real b, real a = 1.0) { + this(double r, double g, double b, double a = 1.0) { this.r = r; this.g = g; this.b = b; this.a = a; } - private real getMin() { + private double getMin() { } - private real getMax() { - real max = r; + private double getMax() { + double max = r; if(g > max) max = g; if(b > max) @@ -59,14 +59,14 @@ /** * From 0 to 360 degrees. */ - real gethue() { - real min = min(); - real max = max(); - real delta = max - min; + double gethue() { + double min = min(); + double max = max(); + double delta = max - min; if(max == 0) // r = g = b = 0 = black return 0; - real hue; + double hue; if(r == max) hue = (g - b) / delta; // between yellow and magenta else if(g == max) @@ -79,9 +79,9 @@ hue += 360; } - real getSaturation() { + double getSaturation() { } - real getValue() { + double getValue() { return getMax(); } +/ diff -r 73060bc3f004 -r 5c8c1c2e12c0 dynamin/painting/graphics.d --- a/dynamin/painting/graphics.d Tue May 15 22:06:02 2012 -0500 +++ b/dynamin/painting/graphics.d Fri Jul 06 18:39:45 2012 -0500 @@ -71,15 +71,15 @@ /// struct FontExtents { /// - real ascent; + double ascent; /// - real descent; + double descent; /// - real leading() { return height - ascent - descent; } + double leading() { return height - ascent - descent; } /// - real height; + double height; /// - real maxAdvance; + double maxAdvance; } //import lodepng = dynamin.lodepng.decode; @@ -230,7 +230,7 @@ assert(0); } /// - void moveTo(real x, real y) { + void moveTo(double x, double y) { cairo_move_to(cr, x, y); } /// ditto @@ -238,7 +238,7 @@ moveTo(pt.x, pt.y); } /// - void lineTo(real x, real y) { + void lineTo(double x, double y) { cairo_line_to(cr, x, y); } /// ditto @@ -250,11 +250,11 @@ curveTo(pt1.x, pt1.y, pt2.x, pt2.y, pt3.x, pt3.y); } /// ditto - void curveTo(real x1, real y1, real x2, real y2, real x3, real y3) { + void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) { cairo_curve_to(cr, x1, y1, x2, y2, x3, y3); } /// - void relMoveTo(real x, real y) { + void relMoveTo(double x, double y) { cairo_rel_move_to(cr, x, y); } /// ditto @@ -262,7 +262,7 @@ relMoveTo(pt.x, pt.y); } /// - void relLineTo(real x, real y) { + void relLineTo(double x, double y) { cairo_rel_line_to(cr, x, y); } /// ditto @@ -274,7 +274,7 @@ relCurveTo(pt1.x, pt1.y, pt2.x, pt2.y, pt3.x, pt3.y); } /// ditto - void relCurveTo(real x1, real y1, real x2, real y2, real x3, real y3) { + void relCurveTo(double x1, double y1, double x2, double y2, double x3, double y3) { cairo_rel_curve_to(cr, x1, y1, x2, y2, x3, y3); } /** @@ -288,15 +288,15 @@ * ----- * $(IMAGE ../web/example_arc.png) */ - void arc(Point ptc, real radius, real angle1, real angle2) { + void arc(Point ptc, double radius, double angle1, double angle2) { arc(ptc.x, ptc.y, radius, angle1, angle2); } /// ditto - void arc(real xc, real yc, real radius, real angle1, real angle2) { + void arc(double xc, double yc, double radius, double angle1, double angle2) { cairo_arc(cr, xc, yc, radius, angle1, angle2); } /// ditto - void arc(real xc, real yc, real xradius, real yradius, real angle1, real angle2) { + void arc(double xc, double yc, double xradius, double yradius, double angle1, double angle2) { cairo_save(cr); cairo_translate(cr, xc, yc); cairo_scale(cr, xradius, yradius); @@ -313,13 +313,13 @@ * ----- * $(IMAGE ../web/example_ellipse.png) */ - void ellipse(real xc, real yc, real radius) { + void ellipse(double xc, double yc, double radius) { cairo_new_sub_path(cr); cairo_arc(cr, xc, yc, radius, 0, Pi * 2); cairo_close_path(cr); } /// ditto - void ellipse(real xc, real yc, real xradius, real yradius) { + void ellipse(double xc, double yc, double xradius, double yradius) { cairo_new_sub_path(cr); arc(xc, yc, xradius, yradius, 0, Pi * 2); cairo_close_path(cr); @@ -338,18 +338,18 @@ rectangle(rect.x, rect.y, rect.width, rect.height); } /// ditto - void rectangle(real x, real y, real width, real height) { + void rectangle(double x, double y, double width, double height) { cairo_rectangle(cr, x, y, width, height); } /** * Adds a rectangle with rounded corners as a sub-path--a line will * not connect it to the current point. */ - void roundedRectangle(Rect rect, real radius) { + void roundedRectangle(Rect rect, double radius) { roundedRectangle(rect.x, rect.y, rect.width, rect.height, radius); } /// ditto - void roundedRectangle(real x, real y, real width, real height, real radius) { + void roundedRectangle(double x, double y, double width, double height, double radius) { alias radius r; cairo_new_sub_path(cr); arc(x+r, y+r, r, Pi, 3*Pi/2); @@ -419,11 +419,11 @@ * ----- * $(IMAGE ../web/example_line_width.png) */ - real lineWidth() { + double lineWidth() { return cairo_get_line_width(cr); } /// ditto - void lineWidth(real width) { + void lineWidth(double width) { cairo_set_line_width(cr, width); } /** @@ -444,7 +444,7 @@ * Sets the font size to the specified size in user space units, not * in points. */ - void fontSize(real size) { + void fontSize(double size) { assert(size != 0); cairo_set_font_size(cr, size); } @@ -457,7 +457,7 @@ cairo_select_font_face(cr, toCharPtr(f.family), f.italic, f.bold); } // TODO: if text is all ascii, do fast path with no uniscribe - void drawText(string text, real x, real y) { + void drawText(string text, double x, double y) { auto extents = getFontExtents; cairo_font_extents_t fextents; cairo_font_extents(cr, &fextents); @@ -508,15 +508,15 @@ translate(pt.x, pt.y); } /// ditto - void translate(real x, real y) { + void translate(double x, double y) { cairo_translate(cr, x, y); } /// - void scale(real x, real y) { + void scale(double x, double y) { cairo_scale(cr, x, y); } /// - void rotate(real angle) { + void rotate(double angle) { cairo_rotate(cr, angle); } /// @@ -530,11 +530,8 @@ /** * Sets the dash pattern to be used when lines are drawn. */ - void setDash(real[] dashes, real offset) { - auto cdashes = new double[dashes.length]; - foreach(int i, real r; dashes) - cdashes[i] = r; - cairo_set_dash(cr, cdashes.ptr, cdashes.length, offset); + void setDash(double[] dashes, double offset) { + cairo_set_dash(cr, dashes.ptr, dashes.length, offset); } /** * Gets or sets the fill rule the current fill rule. @@ -570,14 +567,14 @@ cairo_set_source_rgba(cr, c.R/255.0, c.G/255.0, c.B/255.0, c.A/255.0); } //void source(Pattern s) {} - //void setSource(Surface s, real x = 0, real y = 0) {} + //void setSource(Surface s, double x = 0, double y = 0) {} // TODO: remove this function and have users do: // g.setSource(img, x, y); // g.paint(); // ??? - // paintSource(Image, real, real) ? + // paintSource(Image, double, double) ? /// Draws the specified image unscaled. - void drawImage(Image image, real x, real y) { + void drawImage(Image image, double x, double y) { auto surface= cairo_image_surface_create_for_data(cast(char*)image.data, CAIRO_FORMAT_ARGB32, image.width, image.height, image.width*4); save(); @@ -587,5 +584,5 @@ cairo_surface_destroy(surface); } // Draws the specified image scaled to the specified width and height. - //void drawImage(Image image, real x, real y, real width, real height); + //void drawImage(Image image, double x, double y, double width, double height); } diff -r 73060bc3f004 -r 5c8c1c2e12c0 text.d --- a/text.d Tue May 15 22:06:02 2012 -0500 +++ b/text.d Fri Jul 06 18:39:45 2012 -0500 @@ -94,8 +94,8 @@ uint defaultTabLocations = 0; // no default tabs // newLineSpacing = old * mul + delta // spacing after line, as part of it - real lineSpacingMul = 1.0; // percent - real lineSpacingDelta = 0; // pixels + double lineSpacingMul = 1.0; // percent + double lineSpacingDelta = 0; // pixels Alignment alignment; uint width; @@ -116,7 +116,7 @@ } Format { string family; - real size; + double size; bool bold; bool italic; // spaces are not underlined, overlined, or strikethrough unless @@ -126,8 +126,8 @@ LineStyle overlined; bool superscript; // 2/3 of the height bool subscript; // 2/3 of the height - real letterSpacingMul = 1.0; // after letter, as part of it - real letterSpacingAdd = 0; + double letterSpacingMul = 1.0; // after letter, as part of it + double letterSpacingAdd = 0; // ( ^ useful for Hexplore's column spacing) Color foreColor; Color backColor; @@ -151,10 +151,10 @@ } union Data { string family; - real size; + double size; bool on; // bold and italic LineStyle lineStyle; - real letterSpacing; + double letterSpacing; Color color; } }