// - Add a shadow for a rectangular object, with min-max giving the object extents, and offset shifting the shadow. Rounding parameters refer to the object itself, not the shadow.
// - Add a shadow for a rectangular object, with min-max giving the object extents, and offset shifting the shadow. Rounding parameters refer to the object itself, not the shadow.
// - In the vast majority of cases, filled shadows are unnecessary and wasteful. We still provide the primitives for consistency and flexibility.
// - The filled parameter causes the shadow "under" the object to be drawn as well. In the vast majority of cases, filled shadows are unnecessary and wasteful. We still provide the primitives for consistency and flexibility.
IMGUI_APIvoidAddShadowCircle(constImVec2¢er,floatradius,floatshadow_thickness,constImVec2&offset,ImU32col,intnum_segments=12);// Offset not currently supported
IMGUI_APIvoidAddShadowCircleFilled(constImVec2¢er,floatradius,floatshadow_thickness,constImVec2&offset,ImU32col,intnum_segments=12);// Offset not currently supported
IMGUI_APIvoidAddShadowNGon(constImVec2¢er,floatradius,floatshadow_thickness,constImVec2&offset,ImU32col,intnum_segments);// Offset not currently supported
IMGUI_APIvoidAddShadowNGonFilled(constImVec2¢er,floatradius,floatshadow_thickness,constImVec2&offset,ImU32col,intnum_segments);// Offset not currently supported
IMGUI_APIvoidAddShadowConvexPoly(constImVec2*points,intnum_points,floatshadow_thickness,constImVec2&offset,ImU32col);// Offset not currently supported
IMGUI_APIvoidAddShadowConvexPolyFilled(constImVec2*points,intnum_points,floatshadow_thickness,constImVec2&offset,ImU32col);// Offset not currently supported
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
// - Important: filled shapes must always use clockwise winding order! The anti-aliasing fringe depends on it. Counter-clockwise shapes will have "inward" anti-aliasing.
// - Important: filled shapes must always use clockwise winding order! The anti-aliasing fringe depends on it. Counter-clockwise shapes will have "inward" anti-aliasing.
boolTexBlur;// Do we want to Gaussian blur the shadow texture?
boolTexBlur;// Do we want to Gaussian blur the shadow texture?
IMGUI_APIImFontAtlasShadowTexConfig();
IMGUI_APIImFontAtlasShadowTexConfig();
intGetPadding()const{return2;}// Number of pixels of padding to add to avoid sampling artifacts at the edges.
intGetRectTexPadding()const{return2;}// Number of pixels of padding to add to the rectangular texture to avoid sampling artifacts at the edges.
intCalcTexSize()const{returnTexCornerSize+TexEdgeSize+GetPadding();}// The size of the texture area required for the actual 2x2 shadow texture (after the redundant corners have been removed). Padding is required here to avoid sampling artifacts at the edge adjoining the removed corners.
intCalcRectTexSize()const{returnTexCornerSize+TexEdgeSize+GetRectTexPadding();}// The size of the texture area required for the actual 2x2 rectangle shadow texture (after the redundant corners have been removed). Padding is required here to avoid sampling artifacts at the edge adjoining the removed corners. int CalcConvexTexWidth() const; // The width of the texture area required for the convex shape shadow texture.
intGetConvexTexPadding()const{return8;}// Number of pixels of padding to add to the convex shape texture to avoid sampling artifacts at the edges. This also acts as padding for the expanded corner triangles.
intCalcConvexTexWidth()const;// The width of the texture area required for the convex shape shadow texture.
intCalcConvexTexHeight()const;// The height of the texture area required for the convex shape shadow texture.
};
};
structImFontConfig
structImFontConfig
@ -3153,8 +3162,8 @@ struct ImFontAtlas
intPackIdLines;// Custom texture rectangle ID for baked anti-aliased lines
intPackIdLines;// Custom texture rectangle ID for baked anti-aliased lines
// [Internal] Shadow data
// [Internal] Shadow data
intShadowRectId;// ID of rect for shadow texture
intShadowRectIds[2];// IDs of rect for shadow textures
ImVec4ShadowRectUvs[9];// UV coordinates for shadow texture.
ImVec4ShadowRectUvs[10];// UV coordinates for shadow textures, 9 for the rectangle shadows and the final entry for the convex shape shadows
ImVec2solid_uv=ImVec2(uvs.z,uvs.w);// UV at the inside of an edge
ImVec2edge_uv=ImVec2(uvs.x,uvs.w);// UV at the outside of an edge
ImVec2solid_to_edge_delta_texels=edge_uv-solid_uv;// Delta between the solid/edge points in texel-space (we need this in pixels - or, to be more precise, to be at a 1:1 aspect ratio - for the rotation to work)
solid_to_edge_delta_texels.x*=(float)tex_width;
solid_to_edge_delta_texels.y*=(float)tex_height;
// Our basic algorithm here is that we generate a straight section along each edge, and then either one or two curved corner triangles at the corners,
// which use an appropriate chunk of the texture to generate a smooth curve.
constintmax_vertices=(4+(3*2)+(is_filled?1:0))*num_edges;// 4 vertices per edge plus 3*2 for potentially two corner triangles, plus one per vertex for fill
constintmax_indices=((6+(3*2))*num_edges)+(is_filled?((num_edges-2)*3):0);// 2 tris per edge plus up to two corner triangles, plus fill triangles
// Copy to texture, truncating to the actual required texture size (the bottom/right of the source data is chopped off, as we don't need it - see below). The truncated size is essentially the top 2x2 of our data, plus a little bit of padding for sampling.
// Copy to texture, truncating to the actual required texture size (the bottom/right of the source data is chopped off, as we don't need it - see below). The truncated size is essentially the top 2x2 of our data, plus a little bit of padding for sampling.
alpha=ImPow(alpha,shadow_cfg->TexFalloffPower);// Apply power curve to give a nicer falloff
tex_data[x+(y*size)]=alpha;
}
// Blur
if(shadow_cfg->TexBlur)
GaussianBlur(tex_data,size);
// Copy to texture, truncating to the actual required texture size (the bottom/right of the source data is chopped off, as we don't need it - see below)
// We push the data down and right by the amount we padded the top of the texture (see CalcConvexTexWidth/CalcConvexTexHeight) for details