예제 #1
0
 /// <summary>
 /// Gets a rectangle suitable for drawing.
 /// </summary>
 /// <remarks>
 /// Top and left are floored to pixel boundaries.
 /// Width and height are rounded up.
 /// **No border pixels are substracted from width or height!**.
 /// </remarks>
 /// <param name="event">The event to get the border for.</param>
 /// <returns>The rectangle representing the border.</returns>
 public RectangleF GetPixelRectangle(ISpectralEvent @event)
 {
     // todo: optimise
     return(new RectangleF(
                this.GetPoint(@event),
                this.GetSize(@event)));
 }
예제 #2
0
        /// <summary>
        /// Gets the top and left of an event, in a fashion suitable for drawing.
        /// </summary>
        /// <remarks>
        /// Top and left are floored to pixel boundaries.
        /// </remarks>
        /// <param name="event">The event to get the point for.</param>
        /// <returns>The point.</returns>
        public PointF GetPoint(ISpectralEvent @event)
        {
            var raw = new PointF(
                (float)this.TemporalScale.To(@event.EventStartSeconds),
                (float)this.SpectralScale.To(@event.HighFrequencyHertz));

            return(Point.Truncate(raw));
        }
예제 #3
0
        /// <summary>
        /// Gets the width and height of an event.
        /// </summary>
        /// <remarks>
        /// Width and height are rounded up.
        /// </remarks>
        /// <param name="event">The event to get the size for.</param>
        /// <returns>The size.</returns>
        public SizeF GetSize(ISpectralEvent @event)
        {
            var width   = this.TemporalScale.ToMagnitude(@event.EventDurationSeconds);
            var height  = this.SpectralScale.ToMagnitude(@event.BandWidthHertz);
            var raw     = new SizeF((float)width, (float)height);
            var rounded = Size.Round(raw);

            return(rounded);
        }