Skip to content

Commit

Permalink
fix(text): layer
Browse files Browse the repository at this point in the history
  • Loading branch information
lzxue committed Mar 25, 2019
1 parent 35c4f90 commit 725c0cf
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion demos/06_text.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
.source(data)
.shape('name', 'text')
.active(true)
.size(48) // default 1
.size(12) // default 1
.color('name')
.style({
stroke: '#999',
Expand Down
2 changes: 1 addition & 1 deletion src/geom/buffer/point/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function generateTextBuffer(layerData, fontAtlasManager) {
const size = element.size;
const pos = element.coordinates;
let text = element.shape || '';
const pen = { x: -text.length * size / 2, y: 0 };
const pen = { x: -text.length * size / 2 + size / 2, y: 0 };
text = text.toString();
for (let i = 0; i < text.length; i++) {
const metric = mapping[text[i]];
Expand Down
1 change: 0 additions & 1 deletion src/geom/shader/point_frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ void main() {
return;
}else if(dis2center>ri){
gl_FragColor= u_stroke;
gl_FragColor.a = * u_stroke;
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/geom/shader/text_vert2.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ varying vec4 v_color;
void main(){
mat4 matModelViewProjection=projectionMatrix*modelViewMatrix;
vec4 cur_position=matModelViewProjection*vec4(a_position.xy,0,1);
gl_Position=cur_position/cur_position.w+vec4(a_textSize*position.xy/u_glSize/2.,0.,0.)+vec4(a_textOffset/u_glSize,0,0);
gl_Position=cur_position / cur_position.w+ vec4(a_textSize*position.xy/u_glSize, 0., 0.)+vec4(a_textOffset/u_glSize * 2.0,0,0);
v_color=vec4(a_color.rgb,a_color.a*u_opacity);
if(pickingId == u_activeId) {
v_color = u_activeColor;
}
v_texcoord=(textUv.xy+vec2(uv.x,1.-uv.y)*textUv.zw)/u_textTextureSize;
v_texcoord=(textUv.xy + vec2(uv.x,1.-uv.y) * textUv.zw)/u_textTextureSize;
worldId = id_toPickColor(pickingId);

}
4 changes: 2 additions & 2 deletions src/layer/render/point/drawText.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default function DrawText(attributes, style) {
u_strokeWidth: strokeWidth,
u_stroke: stroke,
u_textTextureSize: [ attributes.fontAtlas.width, attributes.fontAtlas.height ],
u_gamma: 0.02,
u_buffer: 0.75,
u_gamma: 0.1,
u_buffer: 0.68,
u_opacity: opacity,
u_glSize: [ width, height ],
u_activeColor: activeColor
Expand Down

0 comments on commit 725c0cf

Please sign in to comment.