亲爱的读者,相信很多人对c#半透明效果和C语言 矩形填充算法都不是特别了解,因此今天我来为大家分享一些关于c#半透明效果和C语言 矩形填充算法的知识,希望能够帮助大家解决这些问题。

本文目录一览

c#半透明效果

// 省略之前的绘制代码(俺不可能知道你要画什么)
Rectangle maskRect = new Rectangle(0, 0, 100, 100); // 你要变暗的地方
g.FillRectangle(new SolidBrush(Color.FromArgb(127, Color.Black)), maskRect); // 127 透明度的黑色

返回目录

C语言 矩形填充算法

#include <stdio.h>
#include <graphics.h>

typedef struct {
int xmin, xmax, ymin, ymax;
} Rectangle;

void FillRectangle(Rectangle *rect, int color) {
int x = 0, y = 0;
for (y = rect->ymin; y <= rect->ymax; y++)
for (x = rect->xmin; x <= rect->xmax; x++) //这里有个分号,应该去掉。
putpixel(x, y, color);
}/* end of FillRectangle() */

int main() {

//declare our color
int color = 0;

//declare our rectangle
Rectangle *rect = (Rectangle *) malloc(sizeof(Rectangle));

if(NULL == rect )
{
printf("allocation memory failed!\n");
return 1;
}
//input the scope
printf("Enter the x-min:\n");
scanf("%d", &rect->xmin);

printf("Enter the x-max:\n");
scanf("%d", &rect->xmax);

printf("Enter the y-min:\n");
scanf("%d", &rect->ymin);

printf("Enter the y-max:\n");
scanf("%d", &rect->ymax);

//input the color
printf("Enter your color:\n");
scanf("%d", &color);

//call our paint function
FillRectangle(rect, color);

return 0;
}

返回目录

如果您对本文的解答感到满意,请在文章结尾处点击“顶一下”以表示您的肯定。如果您对本文不满意,也请点击“踩一下”,以便我们改进该篇文章。