Skip to content

Commit

Permalink
Merge 3172fd7 into 199f024
Browse files Browse the repository at this point in the history
  • Loading branch information
BarbourSmith committed Sep 23, 2019
2 parents 199f024 + 3172fd7 commit 947ff7a
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 28 deletions.
41 changes: 32 additions & 9 deletions src/js/molecules/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,46 @@ export default class Constant extends Atom{
*/
draw() {

//Set colors
if(this.processing){
GlobalVariables.c.fillStyle = 'blue'
}
else if(this.selected){
GlobalVariables.c.fillStyle = this.selectedColor
GlobalVariables.c.strokeStyle = this.defaultColor
/**
* This background color
* @type {string}
*/
this.color = this.selectedColor
/**
* This atoms accent color
* @type {string}
*/
this.strokeColor = this.defaultColor
}
else{
GlobalVariables.c.fillStyle = this.defaultColor
GlobalVariables.c.strokeStyle = this.selectedColor
this.color = this.defaultColor
this.strokeColor = this.selectedColor
}

this.inputs.forEach(input => {
input.draw()
})
if(this.output){
this.output.draw()
}

GlobalVariables.c.beginPath()
GlobalVariables.c.strokeStyle = this.parent.strokeColor
GlobalVariables.c.fillStyle = this.color
GlobalVariables.c.rect(this.x - this.radius, this.y - this.height/2, 2*this.radius, this.height)
GlobalVariables.c.textAlign = 'start'
GlobalVariables.c.fillText(this.name, this.x + this.radius, this.y-this.radius)
GlobalVariables.c.fill()
GlobalVariables.c.lineWidth = 1
GlobalVariables.c.stroke()
GlobalVariables.c.closePath()

this.inputs.forEach(input => {
input.draw()
})
if(this.output){
this.output.draw()
}
}

/**
Expand Down
56 changes: 44 additions & 12 deletions src/js/molecules/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class Input extends Atom {
* This atom's height for drawing
* @type {number}
*/
this.height = 16
this.height = 20
/**
* This atom's radius for drawing
* @type {string}
Expand Down Expand Up @@ -85,27 +85,51 @@ export default class Input extends Atom {
//Check if the name has been updated
if(this.name != this.oldName){this.updateParentName()}

GlobalVariables.c.fillStyle = this.color
GlobalVariables.c.strokeStyle = this.parent.strokeColor
//Set colors
if(this.processing){
GlobalVariables.c.fillStyle = 'blue'
}
else if(this.selected){
GlobalVariables.c.fillStyle = this.selectedColor
GlobalVariables.c.strokeStyle = this.defaultColor
/**
* This background color
* @type {string}
*/
this.color = this.selectedColor
/**
* This atoms accent color
* @type {string}
*/
this.strokeColor = this.defaultColor
}
else{
GlobalVariables.c.fillStyle = this.defaultColor
GlobalVariables.c.strokeStyle = this.selectedColor
this.color = this.defaultColor
this.strokeColor = this.selectedColor
}

this.inputs.forEach(input => {
input.draw()
})
if(this.output){
this.output.draw()
}

GlobalVariables.c.textAlign = 'start'
GlobalVariables.c.fillText(this.name, this.x + this.radius, this.y-this.radius)
GlobalVariables.c.beginPath()
GlobalVariables.c.moveTo(this.x - this.radius, this.y - this.height)
GlobalVariables.c.lineTo(this.x - this.radius + 10, this.y)
GlobalVariables.c.lineTo(this.x - this.radius, this.y + this.height)
GlobalVariables.c.moveTo(this.x - this.radius, this.y + this.height/2)
GlobalVariables.c.lineTo(this.x + this.radius, this.y + this.height/2)
GlobalVariables.c.lineTo(this.x + this.radius + 10, this.y)
GlobalVariables.c.lineTo(this.x + this.radius, this.y - this.height/2)
GlobalVariables.c.lineTo(this.x - this.radius, this.y - this.height/2)
GlobalVariables.c.lineWidth = 1
GlobalVariables.c.fill()
GlobalVariables.c.closePath()
GlobalVariables.c.stroke()

this.inputs.forEach(input => {
input.draw()
})
if(this.output){
this.output.draw()
}
}

/**
Expand Down Expand Up @@ -137,6 +161,14 @@ export default class Input extends Atom {
* Set's the output value and shows the atom output on the 3D view.
*/
updateValue(){

this.parent.inputs.forEach(input => {
if(input.name == this.name){
input.updateDefault(this.findIOValue('default value'))
}
})

this.setOutput(this.findIOValue('default value'))
this.displayAndPropogate()
}

Expand Down
35 changes: 29 additions & 6 deletions src/js/molecules/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,35 @@ export default class Output extends Atom {

this.height= this.radius


//Set colors
if(this.processing){
GlobalVariables.c.fillStyle = 'blue'
}
else if(this.selected){
GlobalVariables.c.fillStyle = this.selectedColor
GlobalVariables.c.strokeStyle = this.defaultColor
/**
* This background color
* @type {string}
*/
this.color = this.selectedColor
/**
* This atoms accent color
* @type {string}
*/
this.strokeColor = this.defaultColor
}
else{
GlobalVariables.c.fillStyle = this.defaultColor
GlobalVariables.c.strokeStyle = this.selectedColor
this.color = this.defaultColor
this.strokeColor = this.selectedColor
}

this.inputs.forEach(child => {
child.draw()
})

GlobalVariables.c.beginPath()
GlobalVariables.c.textAlign = 'end'
GlobalVariables.c.strokeStyle = this.parentMolecule.strokeColor
Expand Down Expand Up @@ -114,10 +142,5 @@ export default class Output extends Atom {
GlobalVariables.c.lineJoin = "round"
GlobalVariables.c.stroke()
GlobalVariables.c.closePath()

this.inputs.forEach(child => {
child.draw()
})

}
}
4 changes: 4 additions & 0 deletions src/js/prototypes/atom.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,14 @@ export default class Atom {
else if(this.selected){
GlobalVariables.c.fillStyle = this.selectedColor
GlobalVariables.c.strokeStyle = this.defaultColor
this.color = this.selectedColor
this.strokeColor = this.defaultColor
}
else{
GlobalVariables.c.fillStyle = this.defaultColor
GlobalVariables.c.strokeStyle = this.selectedColor
this.color = this.defaultColor
this.strokeColor = this.selectedColor
}
GlobalVariables.c.arc(this.x, this.y, this.radius, 0, Math.PI * 2, false)
GlobalVariables.c.textAlign = 'start'
Expand Down
16 changes: 15 additions & 1 deletion src/js/prototypes/attachmentpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,17 @@ export default class AttachmentPoint {
*/
this.type = 'output'
/**
* The attachment point current value. Default is 10.
* The attachment point current value.
* @type {number}
*/
this.value = 10

/**
* The default value to be used by the ap when nothing is attached
* @type {string}
*/
this.defaultValue = 10

/**
* A flag to indicate if the attachment point is currently ready. Used to order initilization when program is loaded.
* @type {string}
Expand Down Expand Up @@ -413,6 +420,13 @@ export default class AttachmentPoint {
this.setValue(this.defaultValue)
}

/**
* Updates the default value for the ap.
*/
updateDefault(newDefault){
this.defaultValue = newDefault
}

/**
* Reads and returns the curent value of the ap.
*/
Expand Down

0 comments on commit 947ff7a

Please sign in to comment.