1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 06:48:26 +00:00

added Type Jam puzzle app for review (#1554)

* added Type Jam puzzle app for review

* pr round 2 prep

* updated ci scripts for varfont_shader_puzzle

* resolved unused and minor variable naming issues

* rotator tiles row and col are final vars now

* removed unused import and print from production

* made constructors const where needed

* pages_flow export refactored to directly come from that file

* removed old api commented out section from FragmentShaded

* updated pubspec yaml to correct project name

* dart min version updated; removed unnecessary commented out dependencies from pubspec.yaml

* updated pubspec.yaml min flutter version to ensure FragmentShader support

* added/edited comments for explanation, esp on var fonts; removed obsolete comments

* trailing newline added to pubspec.yaml eof
This commit is contained in:
Brian James
2023-01-12 19:40:47 -05:00
committed by GitHub
parent bea2ef6c66
commit 057728c5d2
164 changed files with 8214 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
// Copyright 2023 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#define PI 3.1415926538
layout(location = 0) uniform float uTime;
layout(location = 1) uniform vec2 uSize;
layout(location = 3) uniform float uDampener;
layout(location = 0) out vec4 fragColor;
layout(location = 2) uniform sampler2D uTexture;
void main()
{
float piTime = uTime * PI * 2;
vec2 texCoord = gl_FragCoord.xy / uSize.xy;
float offset = 50;
float opacSum = 0.0;
vec4 thisCol = texture(uTexture, texCoord.xy);
float x = texCoord.x + (offset / uSize.x * pow(sin(piTime), 4)) * uDampener;
if (x >= 0.0 && x <= 1.0) {
opacSum += 0.3 * texture(uTexture, vec2(x, texCoord.y)).a;
}
x = texCoord.x - (offset / uSize.x * pow(sin(piTime + PI), 2)) * uDampener;
if (x >= 0.0 && x <= 1.0) {
opacSum += 0.3 * texture(uTexture, vec2(x, texCoord.y)).a;
}
float y = texCoord.y + (offset / uSize.y * pow(sin(piTime + PI * 0.66), 4)) * uDampener;
if (y >= 0.0 && y <= 1.0) {
opacSum += 0.3 * texture(uTexture, vec2(texCoord.x, y)).a;
}
fragColor = vec4(0.0, 0.0, 0.0, clamp(opacSum, 0.0, 1.0));
}

View File

@@ -0,0 +1,30 @@
// Copyright 2023 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#define PI 3.1415926538
layout(location = 0) uniform float uTime;
layout(location = 1) uniform vec2 uSize;
layout(location = 3) uniform float uDampener;
layout(location = 0) out vec4 fragColor;
layout(location = 2) uniform sampler2D uTexture;
void main()
{
float piTime = uTime * PI * 2;
vec2 texCoord = gl_FragCoord.xy / uSize.xy;
float offset = 15;
vec4 thisCol = texture(uTexture, texCoord.xy);
vec4 rSrc = texture(uTexture, vec2(texCoord.x + offset / uSize.x * sin(piTime), texCoord.y));
float r = rSrc.a;
vec4 gSrc = texture(uTexture, vec2(texCoord.x + offset / uSize.x * sin(piTime + PI), texCoord.y));
float g = gSrc.a;
vec4 bSrc = texture(uTexture, vec2(texCoord.x, texCoord.y + offset / uSize.y * sin(piTime + PI * 0.66)));
float b = bSrc.a;
fragColor = vec4(r, g, b, clamp(r+g+b, 0.0, 1.0));
}

View File

@@ -0,0 +1,19 @@
// Copyright 2023 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#define PI 3.1415926538
layout(location = 0) uniform float uTime;
layout(location = 1) uniform vec2 uSize;
layout(location = 3) uniform float uDampener;
layout(location = 0) out vec4 fragColor;
layout(location = 2) uniform sampler2D uTexture;
void main()
{
float piTime = uTime * PI * 2;
vec2 texCoord = gl_FragCoord.xy / uSize.xy;
fragColor = texture(uTexture, texCoord);
}

View File

@@ -0,0 +1,35 @@
// Copyright 2023 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#define PI 3.1415926538
layout(location = 0) uniform float uTime;
layout(location = 1) uniform vec2 uSize;
layout(location = 3) uniform float uDampener;
layout(location = 0) out vec4 fragColor;
layout(location = 2) uniform sampler2D uTexture;
void main()
{
float piTime = uTime * PI * 2;
vec2 texCoord = gl_FragCoord.xy / uSize.xy;
float levels = 5;
float maxMag = 0.1;
float minMag = 0.02;
float magMod = maxMag / levels;
float row = floor(texCoord.y * uSize.y * 0.25); // resolution/density of rows
float offsetDir = mod(row, 2) == 0 ? -1 : 1;
float sinFn = cos(texCoord.y * 1 * PI + piTime);
float offset = (offsetDir * (minMag + maxMag * sinFn)) * uDampener;
vec2 offsetTexCoord = vec2(texCoord.x + offset, texCoord.y);
vec4 outColor = texture(uTexture, offsetTexCoord);
if (texCoord.x + offset < 0.0 || texCoord.x + offset > 1.0) {
outColor = vec4(0.0, 0.0, 0.0, 0.0);
}
fragColor = outColor;
}

View File

@@ -0,0 +1,30 @@
// Copyright 2023 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#define PI 3.1415926538
layout(location = 0) uniform float uTime;
layout(location = 1) uniform vec2 uSize;
layout(location = 3) uniform float uDampener;
layout(location = 0) out vec4 fragColor;
layout(location = 2) uniform sampler2D uTexture;
void main()
{
float piTime = uTime * PI * 2;
vec2 texCoord = gl_FragCoord.xy / uSize.xy;
int speed;
// wavy
speed = 1;
float xAdj = texCoord.x * 3 * PI;
float waveFnVal = sin((xAdj + piTime * speed));
float hackAdj = 0.0;
float offset = ( ((pow(waveFnVal, 2) * 0.5 - 0.5) * 0.2) + hackAdj ) * uDampener;
vec2 offsetTexCoord = vec2(texCoord.x, texCoord.y + offset);
fragColor = texture(uTexture, offsetTexCoord);
}

View File

@@ -0,0 +1,26 @@
// Copyright 2023 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#define PI 3.1415926538
layout(location = 0) uniform float uTime;
layout(location = 1) uniform vec2 uSize;
layout(location = 3) uniform float uDampener;
layout(location = 0) out vec4 fragColor;
layout(location = 2) uniform sampler2D uTexture;
void main()
{
float piTime = uTime * PI * 2;
vec2 texCoord = gl_FragCoord.xy / uSize.xy;
float maxMag = 0.2;
float thisMag = (sin(texCoord.y * 10 + piTime) + 1) * 0.5 * maxMag * uDampener;
float srcX;
srcX = texCoord.x + (0.5 - texCoord.x) * thisMag;
vec2 srcCoord = vec2(srcX, texCoord.y);
fragColor = texture(uTexture, srcCoord);
}

View File

@@ -0,0 +1,38 @@
// Copyright 2023 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#define PI 3.1415926538
layout(location = 0) uniform float uTime;
layout(location = 1) uniform vec2 uSize;
layout(location = 3) uniform float uDampener;
layout(location = 0) out vec4 fragColor;
layout(location = 2) uniform sampler2D uTexture;
void main()
{
float piTime = uTime * PI * 2;
vec2 texCoord = gl_FragCoord.xy / uSize.xy;
float maxMag = 0.4;
float minMag = 0.3;
float numRings = 6.0;
float ringVel = 4.0;
float numPeakShifts = 8.0;
float peakShiftVel = -3.0;
float unitX = (texCoord.x - 0.5) * 2;
float unitY = (texCoord.y - 0.5) * 2;
float dist = distance(vec2(0, 0), vec2(unitX, unitY));
float theta = atan(unitY, unitX) + PI; // add PI for atan2 values -PI to PI
float thisMag = (sin(theta * numRings - piTime * ringVel) + 1) * 0.5 * (cos(theta * numPeakShifts - piTime * peakShiftVel) + 1) * 0.5 * (maxMag - minMag) + minMag;
float unitSrcDist = dist - dist * thisMag;
float unitSrcX = cos(theta) * unitSrcDist;
float unitSrcY = sin(theta) * unitSrcDist;
float texSrcX = unitSrcX * 0.5 + 0.5;
float texSrcY = unitSrcY * 0.5 + 0.5;
fragColor = texture(uTexture, vec2(texSrcX, texSrcY));
}