0% found this document useful (0 votes)
4 views3 pages

Node Class Implementation in C++

The document defines a Node class in C++ that represents a graphical node with properties such as position, diameter, and color. It includes methods for drawing the node, setting and getting its attributes, and handling different node types. The class also manages graphical elements using the JUCE framework for rendering and color gradients.

Uploaded by

Jonny Mcg
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Node Class Implementation in C++

The document defines a Node class in C++ that represents a graphical node with properties such as position, diameter, and color. It includes methods for drawing the node, setting and getting its attributes, and handling different node types. The class also manages graphical elements using the JUCE framework for rendering and color gradients.

Uploaded by

Jonny Mcg
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

/*

==============================================================================

Node.h
Created: 16 Jun 2019 12:44:46pm
Author: jonny

==============================================================================
*/

#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
class Node
{
public:
Node(float xPosition, float yPosition, float nodeDiameter, Colour
colourOfNode, Colour colourOfBackground);
~Node();

void drawNode(Graphics& g);

void setDiameter(float newDiameterValue);


void setXPosition(float newXPos);
void setYPosition(float newYPos);
void setColour(Colour newColour);
float getDiameter();
float getRadius();
float getXPosition();
float getYPosition();

Colour getColour();

bool isDelayNode = false;


bool isSelectedForMovement = false;
bool isPanNode = false;
bool isTimeNode = false;

Rectangle<float> nodeArea;
Rectangle<float> gradientArea;
private:

float diameter = 0;
float xPos = 0;
float yPos = 0;
Colour nodeColour;
Colour backgroundColour;
};
/*
==============================================================================

[Link]
Created: 16 Jun 2019 12:44:46pm
Author: jonny

==============================================================================
*/

#include "Node.h"

Node::Node(float xPosition, float yPosition, float nodeDiameter, Colour


colourOfNode, Colour colourOfBackground)
{
xPos = xPosition;
yPos = yPosition;
diameter = nodeDiameter;
nodeColour = colourOfNode;
backgroundColour = colourOfBackground;
[Link]();
}

Node::~Node()
{

void Node::drawNode(Graphics& g)
{
nodeArea = Rectangle<float>(xPos - (diameter / 2), yPos - (diameter / 2),
diameter, diameter);
gradientArea = Rectangle<float>(xPos - diameter, yPos - diameter, diameter *
2, diameter * 2);
Point<float> endOfGradient = Point<float>([Link]() +
[Link](), [Link]());
ColourGradient gradient = ColourGradient(nodeColour, [Link](),
backgroundColour, endOfGradient, true);

[Link](gradient);
[Link](gradientArea);

if (isDelayNode)
[Link](backgroundColour);

else
[Link](nodeColour);

[Link](nodeArea, 2.0f);

void Node::setDiameter(float newDiameterValue)


{
diameter = newDiameterValue;
}

void Node::setXPosition(float newXPos)


{
xPos = newXPos;
}

void Node::setYPosition(float newYPos)


{
yPos = newYPos;
}

void Node::setColour(Colour newColour)


{
nodeColour = newColour;
}
float Node::getDiameter()
{
return diameter;
}

float Node::getRadius()
{
return diameter * 0.5f;
}
float Node::getXPosition()
{
return xPos;
}

float Node::getYPosition()
{
return yPos;
}

Colour Node::getColour()
{
return nodeColour;
}

You might also like