Skip to content

Commit

Permalink
Fix typo TrianglesStrip -> TriangleStrip (#2566)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: William Candillon <wcandillon@gmail.com>
  • Loading branch information
mrEuler and wcandillon authored Aug 22, 2024
1 parent 682b32a commit b9a38f0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/docs/shapes/vertices.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Draws vertices.
| Name | Type | Description |
| :--------- | :----------- | :----------------------- |
| vertices | `Point[]` | Vertices to draw |
| mode? | `VertexMode` | Can be `triangles`, `trianglesStrip` or `triangleFan`. Default is `triangles` |
| mode? | `VertexMode` | Can be `triangles`, `triangleStrip` or `triangleFan`. Default is `triangles` |
| indices? | `number[]` | Indices of the vertices that form the triangles. If not provided, the order of the vertices will be taken. Using this property enables you not to duplicate vertices. |
| textures | `Point[]`. | [Texture mapping](https://en.wikipedia.org/wiki/Texture_mapping). The texture is the shader provided by the paint. |
| colors? | `string[]` | Optional colors to be associated to each vertex |
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions package/src/renderer/__tests__/e2e/Vertices.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";

import { checkImage } from "../../../__tests__/setup";
import { Vertices } from "../../components";
import { surface, importSkia } from "../setup";

describe("Vertices", () => {
it("should draw a single triangle", async () => {
const { vec } = importSkia();
const vertices = [vec(64, 0), vec(128, 256), vec(0, 256)];
const colors = ["#61dafb", "#fb61da", "#dafb61"];
const img = await surface.draw(
<>
<Vertices vertices={vertices} colors={colors} />
</>
);
checkImage(img, "snapshots/vertices/vertices.png");
});
it("should draw a single triangle strip", async () => {
const { vec } = importSkia();
const vertices = [vec(0, 0), vec(128, 0), vec(0, 256), vec(128, 256)];
const colors = ["#61dafb", "#fb61da", "#dafb61", "cyan"];
const img = await surface.draw(
<>
<Vertices vertices={vertices} colors={colors} mode="triangleStrip" />
</>
);
checkImage(img, "snapshots/vertices/strip.png");
});
});
6 changes: 5 additions & 1 deletion package/src/skia/__tests__/Enums.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ describe("Enums", () => {
});
it("Should match VertexMode enums values with CanvasKit", () => {
const { CanvasKit } = setupSkia();
checkEnum(VertexMode, CanvasKit.VertexMode);
expect(VertexMode.TriangleFan).toBe(CanvasKit.VertexMode.TriangleFan.value);
expect(VertexMode.TriangleStrip).toBe(
CanvasKit.VertexMode.TrianglesStrip.value
);
expect(VertexMode.Triangles).toBe(CanvasKit.VertexMode.Triangles.value);
});
it("Should match Canvas enums values with CanvasKit", () => {
const { CanvasKit } = setupSkia();
Expand Down
2 changes: 1 addition & 1 deletion package/src/skia/types/Vertices/Vertices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SkJSIInstance } from "../JsiInstance";

export enum VertexMode {
Triangles,
TrianglesStrip,
TriangleStrip,
TriangleFan,
}

Expand Down

0 comments on commit b9a38f0

Please sign in to comment.