html5 绘制空心 三角形

.border-up{width: 0;height: 0;border-left: 100px solid transparent;border-right: 100px solid transparent;border-bottom: 100px solid #333;position: relative;margin: 0px auto;}
        .border-up span{display: block; width: 0;height: 0;border-left: 96px solid transparent;border-right: 96px solid transparent;border-bottom: 96px solid #FFFFFF;position: absolute;left: -96px;top: 2px;}
        .border-down{width: 0;height: 0;border-left: 100px solid transparent;border-right: 100px solid transparent;border-top: 100px solid #333;position: relative;margin: 0px auto;}
        
        .border-down span{display: block;width: 0;height: 0;border-left: 96px solid transparent;border-right: 96px solid transparent;border-top: 96px solid #FFFFFF;position: absolute;left: -96px;top: -98px;}
 .rectangle {
       
        width:100px;
        height:330px;
        border:solid 2px;
        margin:0px auto;
        border-top:none;<

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是Java实现绘制空心封闭半圆、空心圆形、空心矩形、空心三角形空心梯形的示例代码: 1. 绘制空心封闭半圆 ``` import java.awt.Graphics; import javax.swing.JPanel; public class HalfCirclePanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); int centerX = getWidth() / 2; int centerY = getHeight() / 2; int radius = Math.min(getWidth(), getHeight()) / 2 - 10; g.drawArc(centerX - radius, centerY - radius, radius * 2, radius * 2, 0, 180); } } ``` 2. 绘制空心圆形 ``` import java.awt.Graphics; import javax.swing.JPanel; public class CirclePanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); int centerX = getWidth() / 2; int centerY = getHeight() / 2; int radius = Math.min(getWidth(), getHeight()) / 2 - 10; g.drawOval(centerX - radius, centerY - radius, radius * 2, radius * 2); } } ``` 3. 绘制空心矩形 ``` import java.awt.Graphics; import javax.swing.JPanel; public class RectanglePanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); int x = 10; int y = 10; int width = getWidth() - 20; int height = getHeight() - 20; g.drawRect(x, y, width, height); } } ``` 4. 绘制空心三角形 ``` import java.awt.Graphics; import javax.swing.JPanel; public class TrianglePanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); int[] xPoints = {getWidth() / 2, 10, getWidth() - 10}; int[] yPoints = {10, getHeight() - 10, getHeight() - 10}; g.drawPolygon(xPoints, yPoints, 3); } } ``` 5. 绘制空心梯形 ``` import java.awt.Graphics; import javax.swing.JPanel; public class TrapezoidPanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); int x1 = getWidth() / 4; int x2 = getWidth() * 3 / 4; int y1 = 10; int y2 = getHeight() - 10; int width1 = getWidth() / 2 - 20; int width2 = getWidth() / 2 + 20; int height = getHeight() - 20; int[] xPoints = {x1, x2, x2 - width2 / 2, x1 + width1 / 2}; int[] yPoints = {y1, y1, y2, y2}; g.drawPolygon(xPoints, yPoints, 4); } } ``` 以上示例代码均用Java Swing编写,可以在Java图形界面中运行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值