Пример #1
0
    public override void Visualise(int track, ITimedObject timedMidiEvent)
    {
        if (timedMidiEvent is Note)
        {
            if (lengthOverride != 0)
            {
                transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, lengthOverride);
            }

            Note  note       = timedMidiEvent as Note;
            Color noteColour = ColourUtils.ColourFromNote(note, transposeHue);
            noteColour      = Color.Lerp(PrimaryColour, noteColour, colourMix);
            baseAlpha      *= note.Velocity / 127f;
            noteColour.a    = alphaEnvelope.Evaluate(0f) * baseAlpha;
            line.startColor = line.endColor = noteColour;

            startTime = visualisation.time;
            float noteDuration = durationOverride == 0 ? (note.LengthAs <MetricTimeSpan>(visualisation.MIDITempoMap).TotalMicroseconds / 1000000f) : durationOverride;
            endTime = startTime + noteDuration * durationMult;

            startPos = transform.localPosition;

            line.widthMultiplier = 0f; //This will be updated to correct value next frame.
            line.enabled         = true;
            started = true;
        }
    }
Пример #2
0
        // Private methods

        private static void Control_DrawItem(object sender, DrawItemEventArgs e)
        {
            var selected   = (e.State & DrawItemState.Selected) != 0;
            var text       = "Transparent";
            var background = Color.Transparent;
            var comboBox   = (ComboBox)sender;

            if (e.Index >= 0)
            {
                text       = comboBox.Items[e.Index].ToString();
                background = Color.FromName(text);
            }
            else if (comboBox.Tag is Color colour)
            {
                background = colour;
                text       = $"{background.ToArgb() & 0xffffff:X}";
            }
            var foreground = background.Contrast();

            ColourUtils.DrawText(e, foreground, background, text);
            if (selected)
            {
                var r = e.Bounds;
                using (var pen = new Pen(foreground)
                {
                    DashStyle = DashStyle.Dash
                })
                    e.Graphics.DrawRectangle(pen, r.X + 1, r.Y + 1, r.Width - 2, r.Height - 2);
            }
        }
Пример #3
0
 public override void OnNoteDown(int track, Note note)
 {
     //Buffer colour to skybox based on the note pitch.
     if (overrideColour == Color.clear)
     {
         Color noteColour = ColourUtils.ColourFromNote(note, transposeHue) * intensityMult;
         frameColourBuffer.Add(noteColour);
     }
     else
     {
         frameColourBuffer.Add(overrideColour * intensityMult);
     }
 }
Пример #4
0
        public static Color RampedColourByIntensityRange(Color aMaxIntensity, long aValue, long aMin, long aMax)
        {
            // Calculate the difference between the maximum and minimum. This tells us how many different
            // "intensity" values we have to work with.
            long valueSpan = (aMax - aMin);

            // Get the brightness of the baseline colour and then scale it based upon the number of different
            // value intensities we must cope with.
            float brightness         = aMaxIntensity.GetBrightness();
            float brightnessPerValue = (brightness / (float)valueSpan);

            // Ramp the cell colour based upon the index
            float percentage = brightness - (brightnessPerValue * (aValue - aMin));

            Color ret = ColourUtils.Darken(aMaxIntensity, percentage);

            return(ret);
        }
Пример #5
0
        private void PopupShow()
        {
            //System.Diagnostics.Debug.WriteLine( "PopupBase - POPUP SHOW NOW - Visible: " + Visible + ", iShowPos[ " + iShowPos.X + ", " + iShowPos.Y + " ]" );

            if (!Visible)
            {
                // Should we colourise the form header & footer
                // based upon the mouse co-ordinates at the time of
                // the asynch display?
                if (ColourFromHoverCoordinate)
                {
                    using (Bitmap bmp = new Bitmap(1, 1))
                    {
                        using (Graphics gfx = Graphics.FromImage(bmp))
                        {
                            Color c = SymbianUtils.Graphics.ScreenUtils.ColorAtPixel(iHoverPos);
                            ColourTitle = c;

                            // Make the border slightly darker
                            ColourBorder = ColourUtils.Darken(ColourTitle);
                        }
                    }
                }

                // Get the screen size
                Rectangle rect = Screen.GetWorkingArea(this);

                // Make sure that the popup is displayed within the screen bounds.
                Point pos = iShowPos;
                if (iShowPos.X + this.Width > rect.Right)
                {
                    pos.X = rect.Width - this.Width;
                }
                if (iShowPos.Y + this.Height > rect.Bottom)
                {
                    pos.Y = rect.Bottom - this.Height;
                }

                // Now make the form visible and topmost.
                ShowWindow(this.Handle, SW_SHOWNOACTIVATE);
                SetWindowPos(this.Handle, HWND_TOP_MOST, pos.X, pos.Y, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
                Location = pos;
            }
        }
Пример #6
0
        public void PaintContent(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            // Get the cell colour that is associated with the cell symbol object type
            aMetaData.CellBoxColor = ColourForHeapCell(aCell);

            // Draw actual cell
            SymRect boxRect = new SymRect(aPosition, aBoxSize);

            boxRect.HalfOffset(aPaddingSize);
            using (SolidBrush brush = new SolidBrush(aMetaData.CellBoxColor))
            {
                aGraphics.FillRectangle(brush, boxRect.Rectangle);
            }

            // If first box, we show the number of inwards links to the cell
            HeapCell.TRegion region = aMetaData.Region;
            if (region == HeapCell.TRegion.EHeader && aMetaData.CellBoxIndex == 0)
            {
                boxRect.Inflate(KShrinkSize, KShrinkSize);

                // Draw the fill
                Color lightenColor = ColourUtils.LightenMore(aMetaData.CellBoxColor);
                using (SolidBrush brush = new SolidBrush(lightenColor))
                {
                    aGraphics.FillRectangle(brush, boxRect.Rectangle);
                }
                lightenColor = ColourUtils.Lighten(lightenColor);
                using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth))
                {
                    aGraphics.DrawRectangle(borderPen, boxRect.Rectangle);
                }

                // Draw the count
                int count = aCell.RelationshipManager.ReferencedBy.Count;
                if (count == 0)
                {
                    PaintBoxedText(count.ToString(), aGraphics, Color.Red, boxRect);
                }
                else
                {
                    PaintBoxedTextWithLuminanceHandling(count.ToString(), aGraphics, Color.Black, boxRect);
                }
            }
        }
        public Color CellColour(HeapCell aCell)
        {
            Color fillColour = Color.LightGray;

            //
            if (aCell.Type == HeapCell.TType.EAllocated)
            {
                // Get the cell colour that is associated with the cell symbol object type. This
                // makes oldest cells very light and youngest cells very dark. We really want
                // it the other way around...
                //
                float maxBrightness = KRampBaselineColour.GetBrightness();
                float allocationNumberPercentage = ((float)aCell.AllocationNumber / (float)iHighestCellAllocationNumber);
                float targetBrightness           = allocationNumberPercentage * maxBrightness;
                float amountToDarkenBy           = maxBrightness - targetBrightness;
                fillColour = ColourUtils.Darken(KRampBaselineColour, amountToDarkenBy);
            }
            //
            return(fillColour);
        }
Пример #8
0
        public static Color RampedColourByBoxNumber(Color aBaseline, int aBoxCount, uint aCellBaseAddress, uint aAddress)
        {
            float cellAddressOffset = (float)((aAddress - aCellBaseAddress) / 4);

            Color dark  = ColourUtils.Darken(aBaseline, 0.30f);
            Color light = ColourUtils.Lighten(aBaseline, 0.30f);

            // This is the baseline brightness for the colour
            float brightnessBaseline = light.GetBrightness() - dark.GetBrightness();

            // This is how much brightness we can apply to each box.
            float brightnessPerBox = (brightnessBaseline / aBoxCount);

            // This is the brightness of the target box
            float brightnessPercentage = brightnessPerBox * cellAddressOffset;

            Color ret = ColourUtils.Lighten(aBaseline, brightnessPercentage);

            return(ret);
        }
Пример #9
0
    public override void OnNoteDown(int track, Note note)
    {
        //Rotation
        float noteTime      = note.TimeAs <MetricTimeSpan>(visualisation.MIDITempoMap).TotalMicroseconds / 1000000f;
        float bonusRotation = bonusRotationPerSecond * noteTime;

        if (bonusRotationPerBeat != 0)
        {
            bonusRotation += bonusRotationPerBeat * (float)visualisation.GetTimeInBeats(note.Time);
        }

        float finalTunnelRotation = tunnelRotation + bonusRotation;
        float noteRotation        = 0f;

        switch (RotateBy)
        {
        case RotateType.DONT:
            noteRotation = 0f;
            break;

        case RotateType.NOTE:
            noteRotation = ColourUtils.HueFromNote(note, 0) * 360f;
            break;

        case RotateType.RANDOM:
            noteRotation = UnityEngine.Random.Range(0f, 360f);
            break;

        default:
            break;
        }

        //Position
        Vector3 notePos = Vector3.right * tunnelRadius;

        notePos  = Quaternion.Euler(0, 0, (noteRotation + finalTunnelRotation) * rotateDir) * notePos; //Rotate position around forward axis based on tunnel rotation and note rotation.
        notePos += tunnelOffset;
        if (tunnelOffsetVariation != Vector3.zero)
        {
            notePos.x += UnityEngine.Random.Range(-tunnelOffsetVariation.x, tunnelOffsetVariation.x);
            notePos.y += UnityEngine.Random.Range(-tunnelOffsetVariation.y, tunnelOffsetVariation.y);
            notePos.z += UnityEngine.Random.Range(-tunnelOffsetVariation.z, tunnelOffsetVariation.z);
        }

        //Prefab
        Transform noteLine = Instantiate(LinePrefab, LinesParent).transform;

        noteLine.localPosition = notePos;

        //Line Component
        Vis_LineByNote noteLineComponent = noteLine.GetComponent <Vis_LineByNote>();

        if (lineDurationOverride != -1)
        {
            noteLineComponent.durationOverride = lineDurationOverride;
        }
        if (lineDurationMult != -1)
        {
            noteLineComponent.durationMult = lineDurationMult;
        }

        noteLineComponent.lengthOverride = lineLengthOverride;
        if (lineWidthMult != -1)
        {
            noteLineComponent.widthMult = lineWidthMult;
        }
        if (lineAlpha != -1)
        {
            noteLineComponent.baseAlpha = lineAlpha;
        }

        noteLineComponent.PrimaryColour = PrimaryColour;
        noteLineComponent.colourMix     = colourMix;

        if (positionEnvelopeMult != -1)
        {
            noteLineComponent.positionEnvMult = positionEnvelopeMult;
        }

        if (lineShapeOverride.keys.Length > 1)
        {
            noteLineComponent.line.widthCurve = lineShapeOverride;
        }

        noteLineComponent.Initialise();
        noteLineComponent.Visualise(track, note);

        //Add parent's velocity to position envelope.
        if (inheritVelocity)
        {
            for (int i = 0; i < noteLineComponent.positionEnvelope.keys.Length; i++)
            {
                Keyframe k = noteLineComponent.positionEnvelope.keys[i];
                k.value += parentMover.currentVelocity * k.time / noteLineComponent.GetTotalDuration();
                noteLineComponent.positionEnvelope.keys[i] = k;
            }
        }

        //Parenting
        if (unparentAfterSetup)
        {
            noteLine.SetParent(visualisation.transform); //"Unparent" meaning set parent to visualisation, which is static so effectively same thing anyway. This is just more organised to look at.
            noteLineComponent.startPos = noteLine.position;
        }
    }
Пример #10
0
        public void PaintContent(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            // Get the cell colour that is associated with the cell symbol object type
            aMetaData.CellBoxColor = ColourForHeapCell(aCell);
            SymRect boxRect = new SymRect(aPosition, aBoxSize);

            boxRect.HalfOffset(aPaddingSize);

            // Draw actual cell
            using (SolidBrush brush = new SolidBrush(aMetaData.CellBoxColor))
            {
                aGraphics.FillRectangle(brush, boxRect.Rectangle);
            }

            HeapCell.TRegion region = aMetaData.Region;
            if (region == HeapCell.TRegion.EHeader && aMetaData.CellBoxIndex == 0)
            {
                // If first box, we show the number of inwards links to the cell
                boxRect.Inflate(KShrinkSize, KShrinkSize);

                // Draw the fill
                Color lightenColor = ColourUtils.Lighten(aMetaData.CellBoxColor);
                using (SolidBrush brush = new SolidBrush(lightenColor))
                {
                    aGraphics.FillRectangle(brush, boxRect.Rectangle);
                }
                lightenColor = ColourUtils.Lighten(lightenColor);
                using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth))
                {
                    aGraphics.DrawRectangle(borderPen, boxRect.Rectangle);
                }

                // Draw the count
                PaintBoxedTextWithLuminanceHandling(aCell.RelationshipManager.EmbeddedReferencesTo.Count.ToString(), aGraphics, Color.Black, boxRect);
            }
            else
            {
                // If we're in the payload section, then get the raw item corresponding to the address we are drawing
                RawItem rawItem = aMetaData.RawItem;
                if (rawItem != null && rawItem.Tag != null && rawItem.Tag is HeapLib.Relationships.RelationshipInfo)
                {
                    RelationshipInfo relInfo = (RelationshipInfo)rawItem.Tag;

                    // Make the box a bit smaller
                    boxRect.Inflate(KShrinkSize, KShrinkSize);

                    // Draw the fill
                    Color lightenColor = ColourUtils.Lighten(aMetaData.CellBoxColor);
                    using (SolidBrush brush = new SolidBrush(lightenColor))
                    {
                        aGraphics.FillRectangle(brush, boxRect.Rectangle);
                    }
                    lightenColor = ColourUtils.Lighten(lightenColor);
                    using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth))
                    {
                        aGraphics.DrawRectangle(borderPen, boxRect.Rectangle);

                        // If it's a clean reference, then draw a diagonal line to decorate the box reference
                        if (relInfo.IsCleanLink)
                        {
                            Point linePosStart = boxRect.TopLeft;
                            linePosStart.X += KHeaderBoxLineCornerOffset;
                            Point linePosEnd = boxRect.TopLeft;
                            linePosEnd.Y += KHeaderBoxLineCornerOffset;
                            //
                            aGraphics.DrawLine(borderPen, linePosStart, linePosEnd);
                        }
                    }
                }
            }
        }
Пример #11
0
        public virtual void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats)
        {
            // Set title and border colour
            HeapCell firstCell = aCells[0];

            ColourTitle  = HeapCtrlLib.Renderers.Utilities.HeapCellRendererColour.ColourByCellType(firstCell);
            ColourBorder = ColourUtils.Darken(ColourTitle);

            // Get stats
            long  lengthPayload           = aCells.Statistics.SizeTotalPayload;
            long  lengthHeader            = aCells.Statistics.SizeTotalHeader;
            float lengthsAsHeapPercentage = aStats.CellLengthAsHeapPercentage(lengthHeader + lengthPayload);

            // Header length
            iLbl_Title_Length_Header.Text = "H: [" + lengthHeader.ToString("d6") + "]";

            // Payload length
            iLbl_Title_Length_Payload.Text = "P: [" + lengthPayload.ToString("d8") + "]";

            // Set cell allocation number (for allocated cells) or then
            // the cell index for free cells.
            string heapSpecificPrefix = "H: ";

            if (aCells.Count == 1)
            {
                float lengthsAsTypePercentage = aStats.CellLengthAsTypePercentage(firstCell);
                //
                string typeSpecificPrefix = "A: ";
                if (firstCell.Type == HeapCell.TType.EFree)
                {
                    typeSpecificPrefix = "F: ";
                }
                //
                if (HeapCell.IsDebugAllocator)
                {
                    switch (firstCell.Type)
                    {
                    case HeapCell.TType.EAllocated:
                        iLbl_Footer.Text = "Alloc #: [" + firstCell.AllocationNumber.ToString("d6") + " / " + aStats.StatsAllocated.CellAllocationNumberLargest.AllocationNumber.ToString("d6") + "]";
                        break;

                    case HeapCell.TType.EFree:
                        iLbl_Footer.Text = "Free cell #: [" + firstCell.AllocationNumber.ToString("d4") + " / " + aStats.StatsFree.TypeCount.ToString("d4") + "]";
                        break;
                    }
                }
                else
                {
                    iLbl_Footer.Text = "[ " + firstCell.Address.ToString("x8") + " ]";
                }
                //
                iLbl_Footer_Percentage_OfType.Text = typeSpecificPrefix + "[" + lengthsAsTypePercentage.ToString("#00.00") + "%]";
            }
            else
            {
                heapSpecificPrefix = "Of Heap: ";
                iLbl_Footer.Text   = string.Empty;
                iLbl_Footer_Percentage_OfType.Visible = false;
            }
            //
            iLbl_Footer_Percentage_OfTotal.Text = heapSpecificPrefix + "[" + lengthsAsHeapPercentage.ToString("#00.00") + "%]";
        }
Пример #12
0
        public void PaintContentBorder(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            SymRect rect = new SymRect(aPosition, aBoxSize + aPaddingSize);

            // Right and bottom get darker borders
            Color rightAndBottomColour = ColourUtils.Darken(aMetaData.CellBoxColor, 0.15f);

            using (Pen rightAndBottomPen = new Pen(rightAndBottomColour))
            {
                if (aMetaData.Borders[THeapCellBorderType.ERight])     // Draw right-hand outline
                {
                    Point start = rect.TopRight;
                    Point end   = rect.BottomRight;
                    start.Offset(-1, 0);
                    end.Offset(-1, 0);
                    //
                    aGraphics.DrawLine(rightAndBottomPen, start, end);
                }
                if (aMetaData.Borders[THeapCellBorderType.EBottom])     // Draw bottom-side outline
                {
                    Point start = rect.BottomLeft;
                    Point end   = rect.BottomRight;
                    start.Offset(0, -1);
                    end.Offset(0, -1);
                    //
                    aGraphics.DrawLine(rightAndBottomPen, start, end);
                }
            }

            // Left and Top get lighter borders
            Color leftAndTopColour = ColourUtils.Lighten(aMetaData.CellBoxColor, 0.15f);

            using (Pen leftAndTopPen = new Pen(leftAndTopColour))
            {
                if (aMetaData.Borders[THeapCellBorderType.ELeft])     // Draw left-hand outline
                {
                    Point start = rect.TopLeft;
                    Point end   = rect.BottomLeft;
                    start.Offset(1, 0);
                    end.Offset(1, 0);
                    //
                    aGraphics.DrawLine(leftAndTopPen, start, end);
                }
                if (aMetaData.Borders[THeapCellBorderType.ETop])     // Draw top-side outline
                {
                    Point start = rect.TopLeft;
                    Point end   = rect.TopRight;
                    start.Offset(0, 1);
                    end.Offset(0, 1);
                    //
                    aGraphics.DrawLine(leftAndTopPen, start, end);
                }
            }

            // Now draw black border which will cover any over-spill from above.
            if (aMetaData.Borders[THeapCellBorderType.ELeft])     // Draw left-hand outline
            {
                aGraphics.DrawLine(Pens.Black, rect.TopLeft, rect.BottomLeft);
            }
            if (aMetaData.Borders[THeapCellBorderType.ERight])     // Draw right-hand outline
            {
                aGraphics.DrawLine(Pens.Black, rect.TopRight, rect.BottomRight);
            }
            if (aMetaData.Borders[THeapCellBorderType.ETop])     // Draw top-side outline
            {
                aGraphics.DrawLine(Pens.Black, rect.TopLeft, rect.TopRight);
            }
            if (aMetaData.Borders[THeapCellBorderType.EBottom])     // Draw bottom-side outline
            {
                aGraphics.DrawLine(Pens.Black, rect.BottomLeft, rect.BottomRight);
            }
        }