public void onMouseUp(object sender, MouseEventArgs e) { if (graphics != null) { bMouseDown = false; pNew = e.Location; switch (e.Button) { //TODO: ADD TABLET PRESSURE case MouseButtons.Left: pen.Color = primaryColor; pen.Width = settings.getBrushSize() / 2; graphics.DrawLine(pen, pOld, pNew); break; case MouseButtons.Right: pen.Color = secondaryColor; pen.Width = settings.getBrushSize() / 2; graphics.DrawLine(pen, pOld, pNew); break; default: break; } pOld = pNew; } }
public void onMouseMove(object sender, MouseEventArgs e) { if (graphics != null && bMouseDown) { pNew = e.Location; if (settings.getTabletPressure() > 0) { double pressure = Math.Pow(2.0, SharedSettings.MapDouble(0, SharedSettings.iMaxTabletPressure, 0.0, 6.0, SharedSettings.iTabletPressure)); Console.WriteLine(pressure); if (pressure >= 0) { pen.Width = (float)pressure; } } else { pen.Width = settings.getBrushSize() / 2; } switch (e.Button) { // TODO: Add tablet pressure back in... case MouseButtons.Left: pen.Color = primaryColor; graphics.DrawLine(pen, pOld, pNew); break; case MouseButtons.Right: pen.Color = secondaryColor; graphics.DrawLine(pen, pOld, pNew); break; default: break; } pOld = pNew; } }
public void init(SharedSettings s) { graphics = s.getActiveGraphics(); width = s.getCanvasWidth(); height = s.getCanvasHeight(); settings = s; bInit = true; bMouseDown = false; eraser = new Pen(Color.Transparent); eraser.Width = settings.getBrushSize() / 2; eraser.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round); if (graphics != null) { graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; } }
public BrushSettings(SharedSettings s) { InitializeComponent(); lPrime.Text = SharedSettings.getGlobalString("brushsettings_color_primary"); lSec.Text = SharedSettings.getGlobalString("brushsettings_color_secondary"); lSize.Text = SharedSettings.getGlobalString("brushsettings_brush_size"); lHard.Text = SharedSettings.getGlobalString("brushsettings_brush_hardness"); settings = s; pPrime.BackColor = settings.getPrimaryBrushColor(); pSec.BackColor = settings.getSecondaryBrushColor(); tbSize.Value = (int)settings.getBrushSize(); tbHardness.Value = (int)settings.getBrushHardness(); this.Refresh(); }
public void init(SharedSettings s) { graphics = s.getActiveGraphics(); width = s.getCanvasWidth(); height = s.getCanvasHeight(); settings = s; bInit = true; bMouseDown = false; pOld = pNew = new Point(-1, -1); updateBrush(); pen = new Pen(primaryColor, settings.getBrushSize() / 2); pen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round); if (graphics != null) { graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; } updateBrush(); }
//Update Function private void updateBrush() { int R = settings.getPrimaryBrushColor().R; int G = settings.getPrimaryBrushColor().G; int B = settings.getPrimaryBrushColor().B; pPrime = new Pen(Color.FromArgb(settings.getBrushHardness(), R, G, B), settings.getBrushSize()); pPrime.LineJoin = LineJoin.Round; pPrime.MiterLimit = pPrime.Width; R = settings.getSecondaryBrushColor().R; G = settings.getSecondaryBrushColor().G; B = settings.getSecondaryBrushColor().B; pSec = new Pen(Color.FromArgb(settings.getBrushHardness(), R, G, B), settings.getBrushSize()); pSec.LineJoin = LineJoin.Round; }