Generate importable CSS for the 千星图片编辑器.
If the user wants image fitting, icon tracing, or visual approximation and does not give a maximum element count, ask a short follow-up question for the limit before writing CSS.
Example:
请给我一个图元数量上限,例如 20、50 或 100。
Return CSS only unless the user explicitly asks for explanation.
Target the editor's CSS importer format:
.shaper-container { ... } block for the canvas.
.shaper-element.shaper-e0, .shaper-element.shaper-e1, and so on.
left and top.
.shaper-container as layout only, not as visual background.
For this skill, generate CSS with only the importer-safe building blocks that reconstruct reliably:
border-radius: 50%
left and top
width and height
transform: translate(-50%, -50%) rotate(...)
opacity
Even though the codebase has some internal support for triangle or star shapes, the CSS importer does not reliably infer those complex shapes from arbitrary CSS. Therefore:
clip-path
If the user needs an exact triangle or star instead of a CSS approximation, say so briefly and recommend JSON/GIA export or adding native shapes inside the editor after import.
User request:
请用不超过 3 个图元生成一个 120x120 的 CSS:白色底,中间一个蓝色圆形,底部一个橙色矩形。
Expected output style:
.shaper-container {
position: relative;
width: 120px;
height: 120px;
background: #ffffff;
overflow: hidden;
}
.shaper-element {
position: absolute;
box-sizing: border-box;
}
.shaper-element.shaper-e0 {
left: 60px;
top: 60px;
width: 120px;
height: 120px;
background: #ffffff;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 0;
}
.shaper-element.shaper-e1 {
left: 60px;
top: 50px;
width: 56px;
height: 56px;
background: #335cff;
opacity: 0.96;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
border-radius: 50%;
z-index: 1;
}
.shaper-element.shaper-e2 {
left: 60px;
top: 92px;
width: 52px;
height: 20px;
background: #ff8a00;
opacity: 0.92;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 2;
}
Always include these in .shaper-container:
position: relative;
width: px;
height: px;
background: #ffffff;
overflow: hidden;
The container background is not part of the visual design contract.
If the design needs a dark or colored background, represent it with a full-canvas rectangle element as the first shape.
Every element rule must include:
left: px;
top: px;
width: px;
height: px;
background: ;
opacity: <0-1>;
transform: translate(-50%, -50%) rotate(deg);
transform-origin: 50% 50%;
z-index: ;
Use px units for size and position. Use solid colors only, preferably hex colors such as #aabbcc or simple rgb(r, g, b).
Prefer background for fills. background-color is accepted as a compatibility fallback for elements, but background is the recommended output.
Use only these primitive building blocks for CSS output:
border-radius: 50%;
Represent scaling by changing width and height.
Represent rotation only with rotate(.
Represent transparency only with opacity.
Represent complex silhouettes by combining multiple rectangles and ellipses.
Rotation convention:
rotate(0deg) means no rotation.
rotate(45deg) for a clockwise tilt or rotate(-30deg) for a counterclockwise tilt.
Do not rely on these, because the current CSS importer ignores them, partially parses them, or does not reconstruct them reliably:
linear-gradient(...) or radial-gradient(...)
url(...)
border, outline, box-shadow, filter, mask
clip-path in any form
width: 0, height: 0, border-left, border-right, border-bottom
scale(...), skew(...), matrix(...), translateX(...), translateY(...)
::before and ::after
When fitting an image:
If the requested fidelity is unrealistic for the given limit, say so briefly and either:
All examples below are import-safe and avoid clip-path, pseudo-elements, and border hacks.
Common scaffold:
.shaper-container {
position: relative;
width: 120px;
height: 120px;
background: #ffffff;
overflow: hidden;
}
.shaper-element {
position: absolute;
box-sizing: border-box;
}
Single rectangle:
.shaper-element.shaper-e0 {
left: 60px;
top: 60px;
width: 76px;
height: 44px;
background: #2563eb;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 0;
}
Stepped isosceles triangle built from 5 rectangles:
.shaper-element.shaper-e0 {
left: 60px;
top: 30px;
width: 18px;
height: 10px;
background: #ea580c;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 0;
}
.shaper-element.shaper-e1 {
left: 60px;
top: 42px;
width: 34px;
height: 10px;
background: #ea580c;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 1;
}
.shaper-element.shaper-e2 {
left: 60px;
top: 54px;
width: 50px;
height: 10px;
background: #ea580c;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 2;
}
.shaper-element.shaper-e3 {
left: 60px;
top: 66px;
width: 66px;
height: 10px;
background: #ea580c;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 3;
}
.shaper-element.shaper-e4 {
left: 60px;
top: 78px;
width: 82px;
height: 10px;
background: #ea580c;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 4;
}
Four-point star built from one vertical rectangle, one horizontal rectangle, and one rotated center square:
.shaper-element.shaper-e0 {
left: 60px;
top: 60px;
width: 18px;
height: 84px;
background: #0f4c81;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 0;
}
.shaper-element.shaper-e1 {
left: 60px;
top: 60px;
width: 84px;
height: 18px;
background: #0f4c81;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 1;
}
.shaper-element.shaper-e2 {
left: 60px;
top: 60px;
width: 34px;
height: 34px;
background: #0f4c81;
opacity: 1;
transform: translate(-50%, -50%) rotate(45deg);
transform-origin: 50% 50%;
z-index: 2;
}
Five-point star built from 5 outward spokes plus 1 center ellipse:
.shaper-element.shaper-e0 {
left: 60px;
top: 34px;
width: 16px;
height: 56px;
background: #be123c;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
z-index: 0;
}
.shaper-element.shaper-e1 {
left: 79px;
top: 48px;
width: 16px;
height: 56px;
background: #be123c;
opacity: 1;
transform: translate(-50%, -50%) rotate(72deg);
transform-origin: 50% 50%;
z-index: 1;
}
.shaper-element.shaper-e2 {
left: 72px;
top: 73px;
width: 16px;
height: 56px;
background: #be123c;
opacity: 1;
transform: translate(-50%, -50%) rotate(144deg);
transform-origin: 50% 50%;
z-index: 2;
}
.shaper-element.shaper-e3 {
left: 48px;
top: 73px;
width: 16px;
height: 56px;
background: #be123c;
opacity: 1;
transform: translate(-50%, -50%) rotate(216deg);
transform-origin: 50% 50%;
z-index: 3;
}
.shaper-element.shaper-e4 {
left: 41px;
top: 48px;
width: 16px;
height: 56px;
background: #be123c;
opacity: 1;
transform: translate(-50%, -50%) rotate(288deg);
transform-origin: 50% 50%;
z-index: 4;
}
.shaper-element.shaper-e5 {
left: 60px;
top: 60px;
width: 24px;
height: 24px;
background: #be123c;
opacity: 1;
transform: translate(-50%, -50%) rotate(0deg);
transform-origin: 50% 50%;
border-radius: 50%;
z-index: 5;
}
These examples are intentionally simple. When generating image-fit CSS, use the same principles to compose larger silhouettes from a small number of safe primitives.
共 3 个版本