Print Library, Svg Library, Utils Library, XYPlots
This commit is contained in:
@@ -1,48 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Volian.Svg.Library
|
||||
{
|
||||
public class SvgScale
|
||||
{
|
||||
private float _XLowerLimit;
|
||||
public float XLowerLimit
|
||||
{
|
||||
get { return _XLowerLimit; }
|
||||
set { _XLowerLimit = value; }
|
||||
}
|
||||
private float _YLowerLimit;
|
||||
public float YLowerLimit
|
||||
{
|
||||
get { return _YLowerLimit; }
|
||||
set { _YLowerLimit = value; }
|
||||
}
|
||||
private float _Scale; // Scale from Logical to Physical
|
||||
public float Scale
|
||||
{ get { return _Scale; } }
|
||||
private float _Width; // Physical Width
|
||||
public float Width
|
||||
{ get { return _Width; } }
|
||||
private float _Height; // Physical Height
|
||||
public float Height
|
||||
{ get { return _Height; } }
|
||||
public float XUpperLimit
|
||||
{ get { return _Width * _Scale + _XLowerLimit; } }
|
||||
public float YUpperLimit
|
||||
{ get { return _Height * _Scale + _YLowerLimit; } }
|
||||
private float _DPI;
|
||||
public float DPI
|
||||
{ get { return _DPI; } }
|
||||
private SvgScale(SvgScale tmp,SvgMeasurement newX, SvgMeasurement newY)
|
||||
public float XLowerLimit { get; set; }
|
||||
public float YLowerLimit { get; set; }
|
||||
private float _Scale; // Scale from Logical to Physical
|
||||
public float Scale => _Scale;
|
||||
private float _Width; // Physical Width
|
||||
public float Width => _Width;
|
||||
private float _Height; // Physical Height
|
||||
public float Height => _Height;
|
||||
public float XUpperLimit => _Width * _Scale + XLowerLimit;
|
||||
public float YUpperLimit => _Height * _Scale + YLowerLimit;
|
||||
private float _DPI;
|
||||
public float DPI => _DPI;
|
||||
private SvgScale(SvgScale tmp,SvgMeasurement newX, SvgMeasurement newY)
|
||||
{
|
||||
_DPI = tmp.DPI;
|
||||
_Scale = tmp.Scale;
|
||||
_Width = tmp.Width;
|
||||
_Height = tmp.Height;
|
||||
_XLowerLimit = tmp.XLowerLimit - newX.GetSizeInPixels(DPI);
|
||||
_YLowerLimit = tmp.YLowerLimit - newY.GetSizeInPixels(DPI);
|
||||
XLowerLimit = tmp.XLowerLimit - newX.GetSizeInPixels(DPI);
|
||||
YLowerLimit = tmp.YLowerLimit - newY.GetSizeInPixels(DPI);
|
||||
}
|
||||
public SvgScale(float myDPI, RectangleF bounds,SvgMeasurement width, SvgMeasurement height, SvgViewBox myViewBox)
|
||||
{
|
||||
@@ -62,28 +43,16 @@ namespace Volian.Svg.Library
|
||||
//Console.WriteLine("'Scale',{0}",_Scale);
|
||||
_Width = outputWidth / _Scale;
|
||||
_Height = outputHeight / _Scale;
|
||||
_XLowerLimit = myViewBox.X + (inputWidth - _Width) / 2;
|
||||
_YLowerLimit = myViewBox.Y + (inputHeight - _Height) / 2;
|
||||
XLowerLimit = myViewBox.X + (inputWidth - _Width) / 2;
|
||||
YLowerLimit = myViewBox.Y + (inputHeight - _Height) / 2;
|
||||
//if (myDPI != 96) Console.WriteLine("DPI {0}", myDPI);
|
||||
//Console.WriteLine("Scale,{0},{1},{2},{3},{4},{5},{6}", Scale, Width, Height, XLowerLimit, XUpperLimit, YLowerLimit, YUpperLimit);
|
||||
}
|
||||
public SvgScale AdjustOrigin(SvgMeasurement newX, SvgMeasurement newY)
|
||||
{
|
||||
return new SvgScale(this, newX, newY);
|
||||
}
|
||||
public float X(float x)
|
||||
{
|
||||
return _Scale * (x - XLowerLimit);
|
||||
}
|
||||
public float Y(float y)
|
||||
{
|
||||
return _Scale * (y - YLowerLimit);
|
||||
}
|
||||
public float AbsX(SvgMeasurement x)
|
||||
{
|
||||
return x.GetSizeInPixels(DPI) + Svg.AbsoluteOffset.X;
|
||||
}
|
||||
public float AbsY(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y)
|
||||
public SvgScale AdjustOrigin(SvgMeasurement newX, SvgMeasurement newY) => new SvgScale(this, newX, newY);
|
||||
public float X(float x) => _Scale * (x - XLowerLimit);
|
||||
public float Y(float y) => _Scale * (y - YLowerLimit);
|
||||
public float AbsX(SvgMeasurement x) => x.GetSizeInPixels(DPI) + Svg.AbsoluteOffset.X;
|
||||
public float AbsY(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y)
|
||||
{
|
||||
// the following line of code is 'taken' from the 16bit code: \promsnt\exe\wined\togdi.cpp
|
||||
// whenever doing an 'Absolute' macro.
|
||||
@@ -91,36 +60,21 @@ namespace Volian.Svg.Library
|
||||
yOffset = yOffset / 20; // convert from twips to points (point = 1/72 inch)
|
||||
return cb.PdfDocument.PageSize.Height - y.GetSizeInPixels(DPI) + yOffset + Svg.AbsoluteOffset.Y;
|
||||
}
|
||||
public float Y(iTextSharp.text.pdf.PdfContentByte cb, float y)
|
||||
{
|
||||
return cb.PdfDocument.PageSize.Height - _Scale * (y - YLowerLimit);
|
||||
}
|
||||
public float M(float m)
|
||||
{
|
||||
return _Scale * m;
|
||||
}
|
||||
public float X(SvgMeasurement x)
|
||||
public float Y(iTextSharp.text.pdf.PdfContentByte cb, float y) => cb.PdfDocument.PageSize.Height - _Scale * (y - YLowerLimit);
|
||||
public float M(float m) => _Scale * m;
|
||||
public float X(SvgMeasurement x)
|
||||
{
|
||||
float retval = _Scale * (x.GetSizeInPixels(DPI) - XLowerLimit);
|
||||
return retval;
|
||||
}
|
||||
public float Y(SvgMeasurement y)
|
||||
{
|
||||
return _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit);
|
||||
}
|
||||
public float Y(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y)
|
||||
public float Y(SvgMeasurement y) => _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit);
|
||||
public float Y(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y)
|
||||
{
|
||||
float yOffset = 0; // = (cb.PdfWriter.CurrentPageNumber -1) * .8F * cb.PdfDocument.PageSize.Height;
|
||||
float myY = yOffset + cb.PdfDocument.PageSize.Height - _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit);
|
||||
return myY;
|
||||
}
|
||||
public float YY(SvgMeasurement y)
|
||||
{
|
||||
return -_Scale * y.GetSizeInPixels(DPI);
|
||||
}
|
||||
public float M(SvgMeasurement m)
|
||||
{
|
||||
return _Scale * m.GetSizeInPixels(DPI);
|
||||
}
|
||||
}
|
||||
public float YY(SvgMeasurement y) => -_Scale * y.GetSizeInPixels(DPI);
|
||||
public float M(SvgMeasurement m) => _Scale * m.GetSizeInPixels(DPI);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user