Skip to content

Commit

Permalink
fix: layer style storkeColor->stroke
Browse files Browse the repository at this point in the history
  • Loading branch information
lzxue committed Dec 25, 2019
1 parent d657286 commit 27f66a9
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 23 deletions.
3 changes: 2 additions & 1 deletion build/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ module.exports = [
'isFunction',
'cloneDeep',
'isString',
'isNumber'
'isNumber',
'merge'
]
}
}),
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/utils/vertex-compression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface ICircleVertex {
color: number[];
radius: number;
opacity: number;
strokeColor: number[];
stroke: number[];
strokeWidth: number;
strokeOpacity: number;
}
Expand Down Expand Up @@ -68,7 +68,7 @@ export function packCircleVertex(
tileY,
shape,
opacity, // packed buffer1
strokeColor,
stroke,
strokeWidth,
strokeOpacity, // packed buffer2
} = props;
Expand All @@ -81,8 +81,8 @@ export function packCircleVertex(
packUint8ToFloat(color[2], color[3]),
];
const packedStrokeColor: [number, number] = [
packUint8ToFloat(strokeColor[0], strokeColor[1]),
packUint8ToFloat(strokeColor[2], strokeColor[3]),
packUint8ToFloat(stroke[0], stroke[1]),
packUint8ToFloat(stroke[2], stroke[3]),
];

[
Expand Down
2 changes: 1 addition & 1 deletion packages/layers/src/core/BaseLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let layerIdCounter = 0;
export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
implements ILayer {
public id: string = `${layerIdCounter++}`;
public name: string;
public name: string = `${layerIdCounter++}`;
public type: string;
public visible: boolean = true;
public zIndex: number = 0;
Expand Down
7 changes: 1 addition & 6 deletions packages/layers/src/core/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const enum lineStyleType {
export enum lineStyleType {
'solid' = 0.0,
'dash' = 1.0,
}
Expand All @@ -9,8 +9,3 @@ export interface ILineLayerStyleOptions {
dashArray?: [number, number];
segmentNumber: number;
}

export const lineStyleObj: { [key: string]: number } = {
solid: 0.0,
dash: 1.0,
};
4 changes: 2 additions & 2 deletions packages/layers/src/plugins/ConfigSchemaValidationPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export default class ConfigSchemaValidationPlugin implements ILayerPlugin {
public apply(layer: ILayer) {
layer.hooks.init.tap('ConfigSchemaValidationPlugin', () => {
this.configService.registerLayerConfigSchemaValidator(
layer.name,
layer.name as string,
layer.getConfigSchemaForValidation(),
);

const { valid, errorText } = this.configService.validateLayerConfig(
layer.name,
layer.name as string,
layer.getLayerConfig(),
);

Expand Down
2 changes: 1 addition & 1 deletion packages/layers/src/point/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PointModels, { PointType } from './models/index';
interface IPointLayerStyleOptions {
opacity: number;
strokeWidth: number;
strokeColor: string;
stroke: string;
}
export default class PointLayer extends BaseLayer<IPointLayerStyleOptions> {
public type: string = 'PointLayer';
Expand Down
6 changes: 3 additions & 3 deletions packages/layers/src/point/models/fill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ import pointFillVert from '../shaders/fill_vert.glsl';
interface IPointLayerStyleOptions {
opacity: number;
strokeWidth: number;
strokeColor: string;
stroke: string;
}
export default class FillModel extends BaseModel {
public getUninforms(): IModelUniform {
const {
opacity = 1,
strokeColor = 'rgb(0,0,0,0)',
stroke = 'rgb(0,0,0,0)',
strokeWidth = 1,
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
return {
u_opacity: opacity,
u_stroke_width: strokeWidth,
u_stroke_color: rgb2arr(strokeColor),
u_stroke_color: rgb2arr(stroke),
};
}

Expand Down
6 changes: 3 additions & 3 deletions packages/layers/src/point/models/normal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import normalVert from '../shaders/normal_vert.glsl';
interface IPointLayerStyleOptions {
opacity: number;
strokeWidth: number;
strokeColor: string;
stroke: string;
}
export function PointTriangulation(feature: IEncodeFeature) {
const coordinates = feature.coordinates as number[];
Expand All @@ -36,13 +36,13 @@ export default class NormalModel extends BaseModel {
public getUninforms(): IModelUniform {
const {
opacity = 1,
strokeColor = 'rgb(0,0,0,0)',
stroke = 'rgb(0,0,0,0)',
strokeWidth = 1,
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
return {
u_opacity: opacity,
u_stroke_width: strokeWidth,
u_stroke_color: rgb2arr(strokeColor),
u_stroke_color: rgb2arr(stroke),
};
}
public buildModels(): IModel[] {
Expand Down
2 changes: 1 addition & 1 deletion packages/layers/src/point/shaders/fill_vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void main() {
float antialiasblur = 1.0 / (a_Size + u_stroke_width);

// construct point coords
v_data = vec4(extrude, antialiasblur, );
v_data = vec4(extrude, antialiasblur,shape_type);

setPickingColor(a_PickingColor);
}
2 changes: 1 addition & 1 deletion stories/Layers/components/data_update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class DataUpdate extends React.Component {
.active(false)
.color('#2F54EB')
.style({
strokeColor: '#fff',
stroke: '#fff',
strokeWidth: 2,
opacity: 1,
});
Expand Down

0 comments on commit 27f66a9

Please sign in to comment.