mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-10-30 22:54:21 +00:00 
			
		
		
		
	refactored frames so that it will be easier to add others
This commit is contained in:
		| @@ -23,4 +23,7 @@ OTHER_FILES += \ | ||||
|     $$PWD/qml/images/frame.png \ | ||||
|     qml/cool-old-term/SettingsWindow.qml \ | ||||
|     qml/cool-old-term/SettingComponent.qml \ | ||||
|     qml/cool-old-term/ColorButton.qml | ||||
|     qml/cool-old-term/ColorButton.qml \ | ||||
|     qml/cool-old-term/TerminalFrame.qml \ | ||||
|     qml/cool-old-term/WhiteFrameShader.qml \ | ||||
|     qml/cool-old-term/NoFrameShader.qml | ||||
|   | ||||
							
								
								
									
										23
									
								
								qml/cool-old-term/NoFrameShader.qml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								qml/cool-old-term/NoFrameShader.qml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| import QtQuick 2.1 | ||||
|  | ||||
| ShaderEffect{ | ||||
|     property variant source: framesource | ||||
|     property real screen_distorsion: shadersettings.screen_distortion | ||||
|  | ||||
|     fragmentShader: " | ||||
|         uniform sampler2D source; | ||||
|         uniform highp float screen_distorsion; | ||||
|         varying highp vec2 qt_TexCoord0; | ||||
|  | ||||
|         vec2 distortCoordinates(vec2 coords){ | ||||
|             vec2 cc = coords - vec2(0.5); | ||||
|             float dist = dot(cc, cc) * screen_distorsion; | ||||
|             return (coords + cc * (1.0 + dist) * dist); | ||||
|         } | ||||
|  | ||||
|         void main(){ | ||||
|             vec2 coords = distortCoordinates(qt_TexCoord0); | ||||
|             float inside = texture2D(source, coords).a; | ||||
|             gl_FragColor = vec4(vec3(0.0), inside); | ||||
|         }" | ||||
| } | ||||
							
								
								
									
										58
									
								
								qml/cool-old-term/TerminalFrame.qml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								qml/cool-old-term/TerminalFrame.qml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| import QtQuick 2.1 | ||||
|  | ||||
| Item{ | ||||
|     id: framecontainer | ||||
|     property int addedWidth | ||||
|     property int addedHeight | ||||
|     property int borderLeft | ||||
|     property int borderRight | ||||
|     property int borderTop | ||||
|     property int borderBottom | ||||
|     property string imageSource | ||||
|     property string normalsSource | ||||
|     property Component shader | ||||
|     property string shaderString | ||||
|  | ||||
|     BorderImage{ | ||||
|         id: frameimage | ||||
|         anchors.centerIn: parent | ||||
|         width: parent.width + addedWidth | ||||
|         height: parent.height + addedHeight | ||||
|  | ||||
|         border.bottom: borderBottom | ||||
|         border.top: borderTop | ||||
|         border.left: borderLeft | ||||
|         border.right: borderRight | ||||
|  | ||||
|         source: imageSource | ||||
|         horizontalTileMode: BorderImage.Stretch | ||||
|         verticalTileMode: BorderImage.Stretch | ||||
|     } | ||||
|     BorderImage{ | ||||
|         id: framenormals | ||||
|         anchors.fill: frameimage | ||||
|  | ||||
|         border.bottom: borderBottom | ||||
|         border.top: borderTop | ||||
|         border.left: borderLeft | ||||
|         border.right: borderRight | ||||
|  | ||||
|         source: normalsSource | ||||
|         horizontalTileMode: BorderImage.Stretch | ||||
|         verticalTileMode: BorderImage.Stretch | ||||
|     } | ||||
|     ShaderEffectSource{ | ||||
|         id: framesource | ||||
|         sourceItem: frameimage | ||||
|         hideSource: true | ||||
|     } | ||||
|     ShaderEffectSource{ | ||||
|         id: framesourcenormals | ||||
|         sourceItem: framenormals | ||||
|         hideSource: true | ||||
|     } | ||||
|     Loader{ | ||||
|         anchors.fill: frameimage | ||||
|         source: shaderString | ||||
|     } | ||||
| } | ||||
							
								
								
									
										40
									
								
								qml/cool-old-term/WhiteFrameShader.qml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								qml/cool-old-term/WhiteFrameShader.qml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| import QtQuick 2.1 | ||||
|  | ||||
| ShaderEffect{ | ||||
|     property variant source: framesource | ||||
|     property variant normals: framesourcenormals | ||||
|     property real screen_distorsion: shadersettings.screen_distortion | ||||
|     property real ambient_light: shadersettings.ambient_light | ||||
|     property color font_color: shadersettings.font_color | ||||
|     property color background_color: shadersettings.background_color | ||||
|     property real brightness: shadercontainer.brightness | ||||
|  | ||||
|     fragmentShader: " | ||||
|                             uniform sampler2D source; | ||||
|                             uniform sampler2D normals; | ||||
|                             uniform highp float screen_distorsion; | ||||
|                             uniform highp float ambient_light; | ||||
|  | ||||
|                             uniform highp vec4 font_color; | ||||
|                             uniform highp vec4 background_color; | ||||
|                             uniform highp float brightness; | ||||
|  | ||||
|                             varying highp vec2 qt_TexCoord0; | ||||
|  | ||||
|                             vec2 distortCoordinates(vec2 coords){ | ||||
|                                 vec2 cc = coords - vec2(0.5); | ||||
|                                 float dist = dot(cc, cc) * screen_distorsion; | ||||
|                                 return (coords + cc * (1.0 + dist) * dist); | ||||
|                             } | ||||
|  | ||||
|                             void main(){ | ||||
|                                 vec2 coords = distortCoordinates(qt_TexCoord0); | ||||
|                                 vec4 txt_color = texture2D(source, coords); | ||||
|                                 vec4 normala = texture2D(normals, coords); | ||||
|                                 vec3 normal = normalize(normala.rgb) * txt_color.a; | ||||
|                                 float reflection = dot(normal, vec3(1.0, 1.0, 0.0)) * 0.3 * brightness; | ||||
|                                 vec3 reflection_color = mix(font_color, background_color, 0.7).rgb * reflection; | ||||
|                                 vec3 final_color = mix(txt_color.rgb, reflection_color, 1.0 - ambient_light); | ||||
|                                 gl_FragColor = vec4(final_color, txt_color.a); | ||||
|                             }" | ||||
| } | ||||
| @@ -190,86 +190,20 @@ ApplicationWindow{ | ||||
|                         }" | ||||
|         } | ||||
|  | ||||
|         ShaderEffect{ | ||||
|             z: 2.1 | ||||
|             anchors.centerIn: parent | ||||
|             anchors.fill: frame | ||||
|             clip: true | ||||
|             blending: true | ||||
|  | ||||
|             property variant source: framesource | ||||
|             property variant normals: framesourcenormals | ||||
|             property real screen_distorsion: shadersettings.screen_distortion | ||||
|             property real ambient_light: shadersettings.ambient_light | ||||
|             property color font_color: shadersettings.font_color | ||||
|             property color background_color: shadersettings.background_color | ||||
|             property real brightness: shadercontainer.brightness | ||||
|  | ||||
|             fragmentShader: " | ||||
|             uniform sampler2D source; | ||||
|             uniform sampler2D normals; | ||||
|             uniform highp float screen_distorsion; | ||||
|             uniform highp float ambient_light; | ||||
|  | ||||
|             uniform highp vec4 font_color; | ||||
|             uniform highp vec4 background_color; | ||||
|             uniform highp float brightness; | ||||
|  | ||||
|             varying highp vec2 qt_TexCoord0; | ||||
|  | ||||
|             vec2 distortCoordinates(vec2 coords){ | ||||
|                 vec2 cc = coords - vec2(0.5); | ||||
|                 float dist = dot(cc, cc) * screen_distorsion; | ||||
|                 return (coords + cc * (1.0 + dist) * dist); | ||||
|             } | ||||
|  | ||||
|             void main(){ | ||||
|                 vec2 coords = distortCoordinates(qt_TexCoord0); | ||||
|                 vec4 txt_color = texture2D(source, coords); | ||||
|                 vec4 normala = texture2D(normals, coords); | ||||
|                 vec3 normal = normalize(normala.rgb) * txt_color.a; | ||||
|                 float reflection = dot(normal, vec3(1.0, 1.0, 0.0)) * 0.3 * brightness; | ||||
|                 vec3 reflection_color = mix(font_color, background_color, 0.7).rgb * reflection; | ||||
|                 vec3 final_color = mix(txt_color.rgb, reflection_color, 1.0 - ambient_light); | ||||
|                 gl_FragColor = vec4(final_color, txt_color.a); | ||||
|             }" | ||||
|         } | ||||
|  | ||||
|         ShaderEffectSource{ | ||||
|             id: framesource | ||||
|             sourceItem: frame | ||||
|             hideSource: true | ||||
|         } | ||||
|  | ||||
|         ShaderEffectSource{ | ||||
|             id: framesourcenormals | ||||
|             sourceItem: framenormals | ||||
|             hideSource: true | ||||
|         } | ||||
|  | ||||
|         BorderImage{ | ||||
|         TerminalFrame{ | ||||
|             id: frame | ||||
|             width: parent.width + 140 | ||||
|             height: parent.height + 140 | ||||
|             anchors.centerIn: parent | ||||
|             source: "../images/screen-frame.png" | ||||
|             border {left: 116; right: 116; top: 116; bottom: 116} | ||||
|             horizontalTileMode: BorderImage.Stretch | ||||
|             verticalTileMode: BorderImage.Stretch | ||||
|             visible: false | ||||
|         } | ||||
|             z: 2.1 | ||||
|             anchors.fill: parent | ||||
|             addedWidth: 140 | ||||
|             addedHeight: 140 | ||||
|             borderLeft: 116 | ||||
|             borderRight: 116 | ||||
|             borderTop: 116 | ||||
|             borderBottom: 116 | ||||
|             imageSource: "../images/screen-frame.png" | ||||
|             normalsSource: "../images/screen-frame-normals.png" | ||||
|  | ||||
|         BorderImage{ | ||||
|             id: framenormals | ||||
|             anchors.fill: frame | ||||
|             source: "../images/screen-frame-normals.png" | ||||
|             border.bottom: frame.border.bottom | ||||
|             border.top: frame.border.top | ||||
|             border.left: frame.border.left | ||||
|             border.right: frame.border.right | ||||
|             horizontalTileMode: BorderImage.Stretch | ||||
|             verticalTileMode: BorderImage.Stretch | ||||
|             visible: false | ||||
|             shaderString: "WhiteFrameShader.qml" | ||||
|         } | ||||
|  | ||||
|         TerminalScreen { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user