public void plotAntialiasedLED(float x, float y, float bias) { int x1 = (int)Math.Floor(x) - 1; int y1 = (int)Math.Floor(y) - 1; int x2 = (int)Math.Ceiling(x) + 1; int y2 = (int)Math.Ceiling(y) + 1; if (x2 > EdgeLEDCount) { x2 = EdgeLEDCount; } if (y2 > EdgeLEDCount) { y2 = EdgeLEDCount; } if (x1 < 0) { x1 = 0; } if (y1 < 0) { y1 = 0; } float d1; if (bias > 3.0f) { bias = 3.0f; } if (bias < 0.0f) { bias = 0.0f; } for (int _y = y1; _y < y2; _y++) { for (int _x = x1; _x < x2; _x++) { d1 = 3.0f - (FrameTools.DistanceBetween((float)_x, (float)_y, x, y) * (3.0f - bias)); if (d1 > 0) { Byte r, g, n = (Byte)d1; getLED(_x, _y, out r, out g); setLEDDiscard(_x, _y, (Byte)(r + n), (Byte)(g + n)); } } } }
public void load(string file, LoadMode LM) { Stream stream = null; try { stream = File.Open(file, FileMode.Open); Type[] extraTypes = new Type[2] { typeof(Frame), typeof(List <Frame>) }; XmlSerializer serializer = new XmlSerializer(typeof(FrameStripData), extraTypes); FrameStripData incomingData = (FrameStripData)serializer.Deserialize(stream); m_data.m_fps = incomingData.m_fps; if (LM == LoadMode.Replace) { deleteAll(); } Int32 selIndex = m_data.m_frames.Count; if (LM == LoadMode.Append || LM == LoadMode.Replace) { foreach (Frame f in incomingData.m_frames) { addFrame(f, false); } } else if (LM == LoadMode.Overlay || LM == LoadMode.OverlayAdditive || LM == LoadMode.OverlayCutoutFG || LM == LoadMode.OverlayCutoutBG) { Int32 curSelIndex = getIndexForFrame(SelectedFrame); Int32 maxIndex = Math.Min(incomingData.m_frames.Count, m_data.m_frames.Count - curSelIndex); maxIndex = Math.Max(maxIndex, 0); for (Int32 i = 0; i < maxIndex; i++) { if (i >= m_data.m_frames.Count) { break; } Frame blendOut = new Frame(); if (LM == LoadMode.OverlayCutoutFG || LM == LoadMode.OverlayCutoutBG) { FrameTools.OverlayCutout(m_data.m_frames[curSelIndex + i], incomingData.m_frames[i], blendOut, (LM == LoadMode.OverlayCutoutFG)); } else { FrameTools.Overlay(m_data.m_frames[curSelIndex + i], incomingData.m_frames[i], blendOut, (LM == LoadMode.OverlayAdditive)); } blendOut.copyTo(m_data.m_frames[curSelIndex + i]); } } if (m_data.m_frames.Count > selIndex) { SelectedFrame = m_data.m_frames[selIndex]; } } catch (Exception e) { MessageBox.Show(e.Message, "Load Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (stream != null) { stream.Close(); } } }