Skip to content

Commit

Permalink
#154 Strokeの9sliceをv2に実装(WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
ienaga committed Sep 30, 2024
1 parent a6f0d65 commit 2091af1
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { ShaderManager } from "../../ShaderManager";
import { $gridEnabled } from "../../../Grid";
import {
$gridEnabled,
$gridData
} from "../../../Grid";
import {
$context,
$inverseMatrix,
Expand All @@ -23,6 +26,7 @@ export const execute = (
width: number,
height: number
): void => {

const highp = shader_manager.highp;

// vertex: u_matrix
Expand Down Expand Up @@ -60,7 +64,56 @@ export const execute = (
let index = 20;
const isGridEnabled = $gridEnabled();
if (isGridEnabled) {
index += 52;

// vertex: u_parent_matrix
highp[20] = $gridData[0];
highp[21] = $gridData[1];
highp[22] = 0;

highp[24] = $gridData[2];
highp[25] = $gridData[3];
highp[26] = 0;

highp[28] = $gridData[4];
highp[29] = $gridData[5];
highp[30] = 1;

// vertex: u_ancestor_matrix
highp[32] = $gridData[6];
highp[33] = $gridData[7];
highp[34] = 0;

highp[36] = $gridData[8];
highp[37] = $gridData[9];
highp[38] = 0;

highp[40] = $gridData[10];
highp[41] = $gridData[11];
highp[42] = 1;

// vertex: u_parent_viewport
highp[31] = $gridData[12];
highp[35] = $gridData[13];
highp[39] = $gridData[14];
highp[43] = $gridData[15];

// vertex: u_grid_min
highp[44] = $gridData[16];
highp[45] = $gridData[17];
highp[46] = $gridData[18];
highp[47] = $gridData[19];

// vertex: u_grid_max
highp[48] = $gridData[20];
highp[49] = $gridData[21];
highp[50] = $gridData[22];
highp[51] = $gridData[23];

// vertex: u_offset
highp[52] = $gridData[24];
highp[53] = $gridData[25];

index += 56;
}
let face: number = Math.sign(matrix[0] * matrix[4]);
if (face > 0 && matrix[1] !== 0 && matrix[3] !== 0) {
Expand All @@ -71,9 +124,8 @@ export const execute = (
let scaleX: number;
let scaleY: number;
if (isGridEnabled) {
// todo
scaleX = 1;
scaleY = 1;
scaleX = Math.abs($gridData[6] + $gridData[8]);
scaleY = Math.abs($gridData[7] + $gridData[9]);
} else {
scaleX = Math.abs(matrix[0] + matrix[3]);
scaleY = Math.abs(matrix[1] + matrix[4]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { ShaderManager } from "../../ShaderManager";
import { $gridEnabled } from "../../../Grid";
import {
$gridEnabled,
$gridData
} from "../../../Grid";
import {
$getViewportWidth,
$getViewportHeight,
Expand Down Expand Up @@ -60,7 +63,56 @@ export const execute = (
let index = 20;
const isGridEnabled = $gridEnabled();
if (isGridEnabled) {
index += 52;

// vertex: u_parent_matrix
highp[20] = $gridData[0];
highp[21] = $gridData[1];
highp[22] = 0;

highp[24] = $gridData[2];
highp[25] = $gridData[3];
highp[26] = 0;

highp[28] = $gridData[4];
highp[29] = $gridData[5];
highp[30] = 1;

// vertex: u_ancestor_matrix
highp[32] = $gridData[6];
highp[33] = $gridData[7];
highp[34] = 0;

highp[36] = $gridData[8];
highp[37] = $gridData[9];
highp[38] = 0;

highp[40] = $gridData[10];
highp[41] = $gridData[11];
highp[42] = 1;

// vertex: u_parent_viewport
highp[31] = $gridData[12];
highp[35] = $gridData[13];
highp[39] = $gridData[14];
highp[43] = $gridData[15];

// vertex: u_grid_min
highp[44] = $gridData[16];
highp[45] = $gridData[17];
highp[46] = $gridData[18];
highp[47] = $gridData[19];

// vertex: u_grid_max
highp[48] = $gridData[20];
highp[49] = $gridData[21];
highp[50] = $gridData[22];
highp[51] = $gridData[23];

// vertex: u_offset
highp[52] = $gridData[24];
highp[53] = $gridData[25];

index += 56;
}

let face: number = Math.sign(matrix[0] * matrix[4]);
Expand All @@ -72,9 +124,8 @@ export const execute = (
let scaleX: number;
let scaleY: number;
if (isGridEnabled) {
// todo
scaleX = 1;
scaleY = 1;
scaleX = Math.abs($gridData[6] + $gridData[8]);
scaleY = Math.abs($gridData[7] + $gridData[9]);
} else {
scaleX = Math.abs(matrix[0] + matrix[3]);
scaleY = Math.abs(matrix[1] + matrix[4]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { ShaderManager } from "../../ShaderManager";
import { $gridEnabled } from "../../../Grid";
import {
$gridEnabled,
$gridData
} from "../../../Grid";
import {
$context,
$getViewportWidth,
Expand All @@ -20,6 +23,10 @@ export const execute = (shader_manager: ShaderManager): void =>
const highp = shader_manager.highp;
const matrix = $context.$matrix;

// vertex: u_viewport
highp[3] = $getViewportWidth();
highp[7] = $getViewportHeight();

let index = 0;
const isGridEnabled = $gridEnabled();
if (!isGridEnabled) {
Expand All @@ -36,13 +43,58 @@ export const execute = (shader_manager: ShaderManager): void =>
highp[9] = matrix[7];
highp[10] = matrix[8];

// vertex: u_viewport
highp[3] = $getViewportWidth();
highp[7] = $getViewportHeight();

index = 12;
} else {
index = 32;

// vertex: u_parent_matrix
highp[0] = $gridData[0];
highp[1] = $gridData[1];
highp[2] = 0;

highp[4] = $gridData[2];
highp[5] = $gridData[3];
highp[6] = 0;

highp[8] = $gridData[4];
highp[9] = $gridData[5];
highp[10] = 1;

// vertex: u_ancestor_matrix
highp[12] = $gridData[6];
highp[13] = $gridData[7];
highp[14] = 0;

highp[16] = $gridData[8];
highp[17] = $gridData[9];
highp[18] = 0;

highp[20] = $gridData[10];
highp[21] = $gridData[11];
highp[22] = 1;

// vertex: u_parent_viewport
highp[11] = $gridData[12];
highp[15] = $gridData[13];
highp[19] = $gridData[14];
highp[23] = $gridData[15];

// vertex: u_grid_min
highp[24] = $gridData[16];
highp[25] = $gridData[17];
highp[26] = $gridData[18];
highp[27] = $gridData[19];

// vertex: u_grid_max
highp[28] = $gridData[20];
highp[29] = $gridData[21];
highp[30] = $gridData[22];
highp[31] = $gridData[23];

// vertex: u_offset
highp[32] = $gridData[24];
highp[33] = $gridData[25];

index = 36;
}

let face: number = Math.sign(matrix[0] * matrix[4]);
Expand All @@ -54,9 +106,8 @@ export const execute = (shader_manager: ShaderManager): void =>
let scaleX: number;
let scaleY: number;
if (isGridEnabled) {
// todo
scaleX = 1;
scaleY = 1;
scaleX = Math.abs($gridData[6] + $gridData[8]);
scaleY = Math.abs($gridData[7] + $gridData[9]);
} else {
scaleX = Math.abs(matrix[0] + matrix[3]);
scaleY = Math.abs(matrix[1] + matrix[4]);
Expand Down

0 comments on commit 2091af1

Please sign in to comment.