diff --git a/docs/componentsguide/styles/fill/index.md b/docs/componentsguide/styles/fill/index.md index fa996a4..df7d101 100644 --- a/docs/componentsguide/styles/fill/index.md +++ b/docs/componentsguide/styles/fill/index.md @@ -40,3 +40,36 @@ Styling a feature - **Type**: `Number` The color either in hexadecimal or as RGB array with red, green, and blue values between 0 and 255 and alpha between 0 and 1 inclusive. + +### gradient +- **Type**: `Object` +``` +{ + "type": "linear", // Type of gradient. Here, it's a linear gradient. + "x0": 0, // x-coordinate of the starting point. Indicates the horizontal position where the gradient starts. + "y0": 0, // y-coordinate of the starting point. Indicates the vertical position where the gradient starts. + "x1": 0, // x-coordinate of the ending point. This is the horizontal position where the gradient ends. It’s the same as x0, meaning the gradient is vertical. + "y1": 256, // y-coordinate of the ending point. Indicates the vertical position where the gradient ends, extending the gradient to y = 256. + "colorStops": [ + [0, "red"], // Start color at position 0. The color at the beginning of the gradient is red. + [0.5, "yellow"], // Middle color at position 0.5. The color at the midpoint of the gradient (y = 128) is yellow. + [1, "green"] // End color at position 1. The color at the end of the gradient (y = 256) is green. + ] +} + +{ + "type": "radial", // Type of gradient. Here, it's a radial gradient. + "x0": 128, // x-coordinate of the starting circle's center. Specifies the horizontal position of the starting circle. + "y0": 128, // y-coordinate of the starting circle's center. Specifies the vertical position of the starting circle. + "r0": 0, // Radius of the starting circle. Here, it's 0, meaning the gradient starts at a single point. + "x1": 128, // x-coordinate of the ending circle's center. Same as x0, so the ending circle is centered at the same horizontal position. + "y1": 128, // y-coordinate of the ending circle's center. Same as y0, so the ending circle is centered at the same vertical position. + "r1": 128, // Radius of the ending circle. Specifies the radius of the circle where the gradient ends, extending to a radius of 128 units. + "colorStops": [ + [0, "blue"], // Color at the center of the gradient (r = 0). The color at the very center of the radial gradient is blue. + [0.5, "cyan"], // Color at the midpoint of the gradient. At the midpoint of the radius (r = 64), the color is cyan. + [1, "white"] // Color at the edge of the gradient (r = 128). The color at the outer edge of the radial gradient is white. + ] +} + +``` \ No newline at end of file diff --git a/src/components/styles/OlStyleFill.vue b/src/components/styles/OlStyleFill.vue index 9743096..52314ce 100644 --- a/src/components/styles/OlStyleFill.vue +++ b/src/components/styles/OlStyleFill.vue @@ -1,56 +1,143 @@ + diff --git a/src/demos/MultiPoint.vue b/src/demos/MultiPoint.vue index cf0efb1..352ac0f 100644 --- a/src/demos/MultiPoint.vue +++ b/src/demos/MultiPoint.vue @@ -19,24 +19,7 @@ @@ -48,6 +31,57 @@ + + + + + + + + + + + + + + + + + + + + + @@ -58,9 +92,37 @@ import { ref } from "vue"; const center = ref([116.54875, 40.45064]); const projection = ref("EPSG:4326"); -const zoom = ref(17); +const zoom = ref(15); const radius = ref(10); const strokeWidth = ref(4); const strokeColor = ref("red"); const fillColor = ref("white"); + +const linearGradient = { + type: "linear", + x0: 0, + y0: 0, + x1: 0, + y1: 256, + colorStops: [ + [0, "red"], // Start color + [0.5, "yellow"], // Middle color + [1, "green"], // End color + ], +}; + +const radialGradient = { + type: "radial", + x0: 128, + y0: 128, + r0: 0, + x1: 128, + y1: 128, + r1: 128, + colorStops: [ + [0, "blue"], // Center color + [0.5, "cyan"], // Middle color + [1, "white"], // Edge color + ], +}; diff --git a/src/demos/PolygonDemo.vue b/src/demos/PolygonDemo.vue index cc8ee7d..d9510b5 100644 --- a/src/demos/PolygonDemo.vue +++ b/src/demos/PolygonDemo.vue @@ -41,6 +41,54 @@ + + + + + + + + + + + + + + + + + + @@ -52,4 +100,32 @@ import { ref } from "vue"; const center = ref([-98.8449, 19.6869]); const projection = ref("EPSG:4326"); const zoom = ref(15); + +const linearGradient = { + type: "linear", + x0: 0, + y0: 0, + x1: 0, + y1: 256, + colorStops: [ + [0.1, "red"], // Start color + [0.5, "yellow"], // Middle color + [1, "green"], // End color + ], +}; + +const radialGradient = { + type: "radial", + x0: 128, + y0: 128, + r0: 0, + x1: 128, + y1: 128, + r1: 128, + colorStops: [ + [0, "blue"], // Center color + [0.5, "cyan"], // Middle color + [1, "white"], // Edge color + ], +};