计算机图形学简笔画

DDAL

function img = DDA(x1, y1 ,x2 ,y2, img1)
img = img1;
dx = x2 - x1;
dy = y2 - y1;
d = max(abs(dx), abs(dy));
kx = dx / d;
ky = dy / d;
x = x1;
y = y1;
for i = 1 : d
    img(round(x), round(y)) = 1;
    x = x + kx;
    y = y + kx;
end;
end;

BresenhamCircle

function img = BresenhamCircle(x1, y1, r, img1)
x = 0;
y = r;
img = img1;
d = 3 - 2 * r;
while(x < y):
    img(x1 + x, y1 + y) = 1;
    img(x1 - x, y1 + y) = 1;
    img(x1 + x, y1 - y) = 1;
    img(x1 - x, y1 - y) = 1;
    img(x1 + x, y1 + y) = 1;
    -+
    +-
    -+
    if(d < 0):
        d = d + 4 * x + 6;
    else:
        d = d + 4 * (x - y) + 10;
        y = y + 1;
    end;
    x = x + 1;
end;
end;
img = zeros(100, 100);
DDA(100, 100, 300, 100, img);
DDA(100, 200, 300, 200, img);
DDA(200, 100, 200, 200, img);
figure; imshow(img);

 

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要用Python画出大白的简笔画,可以借助Python中的turtle库,它专门用于绘制图形和动画。 下面是一个用turtle库绘制大白的简笔画的示例代码: ``` import turtle # 设置画笔颜色和大小 turtle.color('white', 'white') turtle.pensize(5) # 绘制大白的头部 turtle.begin_fill() turtle.circle(100) turtle.end_fill() # 绘制大白的眼睛 turtle.penup() turtle.goto(-40, 120) turtle.pendown() turtle.color('black', 'black') turtle.begin_fill() turtle.circle(20) turtle.end_fill() turtle.penup() turtle.goto(40, 120) turtle.pendown() turtle.begin_fill() turtle.circle(20) turtle.end_fill() # 绘制大白的嘴巴 turtle.penup() turtle.goto(-60, 60) turtle.pendown() turtle.color('red', 'red') turtle.begin_fill() turtle.right(90) turtle.circle(60, 180) turtle.end_fill() # 绘制大白的身体 turtle.penup() turtle.goto(-150, -50) turtle.pendown() turtle.color('white', 'white') turtle.begin_fill() turtle.right(90) turtle.forward(200) turtle.right(90) turtle.forward(300) turtle.right(90) turtle.forward(200) turtle.right(90) turtle.forward(300) turtle.end_fill() # 绘制大白的手臂 turtle.penup() turtle.goto(-150, -50) turtle.pendown() turtle.color('black', 'white') turtle.begin_fill() turtle.right(45) turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(45) turtle.end_fill() turtle.penup() turtle.goto(150, -50) turtle.pendown() turtle.color('black', 'white') turtle.begin_fill() turtle.left(45) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(45) turtle.end_fill() # 绘制大白的脚 turtle.penup() turtle.goto(-100, -250) turtle.pendown() turtle.color('black', 'white') turtle.begin_fill() turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(50) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(50) turtle.end_fill() turtle.penup() turtle.goto(100, -250) turtle.pendown() turtle.color('black', 'white') turtle.begin_fill() turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(50) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(50) turtle.end_fill() # 隐藏画笔 turtle.hideturtle() # 显示绘制结果 turtle.done() ``` 运行上述代码,即可在窗口中看到一个用turtle库绘制的大白的简笔画

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值