当前位置:网站首页>C language drawing example - palette
C language drawing example - palette
2022-07-19 12:08:00 【Presbyopia】
C Language drawing example - palette
16m True color palette Design and manufacture
PhotoShop,AutoCad,3DS,Paint And other graphics and image painting applications have a true color palette , For the user to draw color with the brush .16m Color is all the colors commonly known as true color .
I try to make trademark logo making software , Also make this true color palette , Today I share with you , Hope you enjoy it .
True color palette drawing , Brush color , Application synchronization drawing palette . Big palette 16m Color settings , Minor palette color separation setting , For the brush to color .
For application examples, please refer to my blog post palette settings VB6 Source code .
Step 8 , Step 4 , To improve the display speed of palette drawing , This chroma cannot be distinguished by the naked eye .Step 1 , Full tone mode , Drawing speed is slow , You can draw... When the program starts .
I use it on my Android phone in my spare time myspringc Graphic drawing examples written in language , It can be used as a reference for your favorite friends . The biggest advantage of the example program I have compiled is that the pattern changes at any time , Color changes randomly at any time , It's quite ornamental . Add another key to automatically demonstrate all examples .
MySpringC You can not only write simple C Language program , And it can read the values of various sensors in the mobile phone , Control various multimedia devices , So that ordinary users can use C Language controlled mobile phone , Write unexpected 、 Applications suitable for your own use .
The sample picture :

Here is the source code :
// The simplest C Language programming
// myspringc v2.7 Compile Android native app application
// This sample can be copied and pasted to myspringc compile
// This document is available VB,VC , java rewrite
//***************************************
//**** C Language drawing example - palette *******
//***************************************
Canvas cs ; // canvas
string sBarDes[10];
int nBarId[10];
string sMenu[50];
int nMenu[50];
float src[4]; //ClearDraw (cls) clear screen
string s,ss,ss1,ss2,ss3;
float sx,sy,dx,dy;
float px,py;
int size[2];
int i,j,n,t,k; //t=times,n=number
double sn; //mode number
int r1,g1,b1; //16m Panchromatic palette
main(){
setDisplay(1);
cs.SetBackground(205,205,205);
cs.Active();
sBarDes[0]=" Play in ";
nBarId[0]=100;
sBarDes[1]=" ";
nBarId[1]=101;
sBarDes[2]=" ";
nBarId[2]=102;
sBarDes[3]=" ";
nBarId[3]=103;
sBarDes[4]=" Exit procedure ";
nBarId[4]=104;
sBarDes[5]=" ";
nBarId[5]=105;
setToolBarHeight(6);
setButtonTextSize(14);
setToolBarBackgroundColor(255,192,192,192);
setButtonColor(255,0,0,240);
setButtonTextColor(255,255,255,0);
setToolBar(100,myToolBarProc,sBarDes,nBarId,6);
setTitle(" Palette design ");
sn=0; show_pad(); // When the program starts, draw
while (){}
}//main ()
show_pad (){ // Demonstration sequence
if (sn==0) colorpad1 ();
if (sn==1) colorpad2 ();
}//show_pad ()
colorpad1 (){
cs.SetFillMode (1);//0 No coloring ,1 Colouring
cs.SetColor (255,0,0,0);
cs.DrawRect (0,4,720,600);
cs.SetTextSize (30); //*** (1) ****
cs.SetColor (255,240,240,0);
cs.DrawText (" True color palette ",20,35);
n=(int)(sn);
s=intToString (n);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.Update ();
//**** 16m Full color true color palette
// With 8 Change color for segment , Reduce the display time .
// This is a simulation demonstration , Color palette to draw point by point
// The machine is fast and can draw point by point
// Plot width 255*3 , Picture height 255
// draw Picture frame calibration :sx = 3 * 256 , sy = 256
// canvas.Scale (0, 0)-(768, 255)
// r1 = 0: g1 = 255: b1 = 255
//blue
// for (sx=0;sx<256;sx++){ //blue *******
// r1 = sx
// for (sy=0;sy<256;sy++){
// g1 = 255 - sy
// cs.SetColor (255,r1,g1,b1);
// cs.DrawRect (sx+50,sy+90,sx+50,sy+90);
// cs.Update (); // Show and draw the process
// } }
// r1= 255; g1= 255; b1= 255; //green
// for (sx=256;sx<512;sx++){ // green ********
// r1=512- sx +255; b1=512 - sx;
// for (sy=0;sy<256;sy++){
// g1= 255 - sy;
// cs.SetColor (255,r1,g1,b1);
// cs.DrawRect (sx+50,sy+90,sx+50,sy+90);
// cs.Update (); // Show and draw the process
// } }
// r1= 0; g1= 255; b1= 0; //red
// for (sx=513;sx<769;sx++){ // red ********
// r1=513- sx +255;
// for (sy=0;sy<256;sy++){
// g1= 255 - sy;
// cs.SetColor (255,r1,g1,b1);
// cs.DrawRect (sx+50,sy+90,sx+50,sy+90);
// cs.Update (); // Show and draw the process
// } }
//********
r1= 0; g1= 255; b1= 255; //blue
for (i=0;i<32;i++){ // blue ********
r1=i*8; sx=i*6;
for (j=0;j<32;j++){
g1=255-j*8; sy=j*8;
cs.SetColor (255,r1,g1,b1);
cs.DrawRect (sx+50,sy+90,sx+58,sy+98);
// cs.Update (); // Show and draw the process
} }
r1= 255; g1= 255; b1= 255; //green
for (i=32;i<64;i++){ // green ********
r1=511- i*8 +255; b1=511- i*8; sx=i*6;
for (j=0;j<32;j++){
g1= 255 - j*8; sy=j*8 ;
cs.SetColor (255,r1,g1,b1);
cs.DrawRect (sx+50,sy+90,sx+58,sy+98);
cs.Update (); // Show and draw the process
} }
r1 = 0; g1 = 255; b1 = 0; //red
for (i=64;i<96;i++){ // red ********
r1= i*8-511+255; sx=i*6 ;
for (j=0;j<32;j++){
g1=255 -j*8; sy=j*8 ;
cs.SetColor (255,r1,g1,b1);
cs.DrawRect (sx+50,sy+90,sx+58,sy+98);
// cs.Update (); // Show and draw the process
} }
cs.SetColor (255,240,200,100);
cs.SetTextSize (40);
cs.DrawText (" 16m color True color palette Example ",110,400);
cs.Update ();
}//colorpad1 ()
colorpad2 (){
cs.SetFillMode (1);//0 No coloring ,1 Colouring
cs.SetColor (255,0,0,0);
cs.DrawRect (0,4,720,600);
cs.SetColor (255,200,250,0);
cs.SetTextSize (30); //*** (2) ****
cs.DrawText (" Seven color ribbon palette ",20,35);
n=(int)(sn);
s=intToString (n);
ss="mode = "+s ;
cs.DrawText (ss,550,35);
cs.Update ();
for (i=0;i<256;i++){ // Seven color ribbon (2) palette
cs.SetColor (255,255,i,0);
cs.DrawLine (i/2+50,350,i/2+50,550);
cs.DrawLine (600,i/2+40,710,i/2+40);
cs.SetColor (255,255-i,255,0);
cs.DrawLine (i/2+178,350,i/2+178,550);
cs.DrawLine (600,i/2+168,710,i/2+168);
cs.SetColor (255,0,255-i/2,i);
cs.DrawLine (i/2+306,350,i/2+306,550);
cs.DrawLine (600,i/2+296,710,i/2+296);
// cs.Update (); // Show and draw the process
}
for (i=0;i<256;i++){ // Seven color ribbon palette
cs.SetColor (255,i/2,128-i/2,255);
cs.DrawLine (i/2+434,350,i/2+434,550);
cs.DrawLine (600,i/2+424,710,i/2+424);
cs.Update (); // Show and draw the process
}
cs.SetFillMode (0);//0 No coloring ,1 Colouring
cs.SetColor (255,255,255,255);
cs.DrawRect (50,50,560,300);
cs.DrawRect (50,350,560,550);
cs.SetColor (255,240,200,100);
cs.SetTextSize (40);
cs.DrawText (" Seven color ribbon palette Example ",110,190);
cs.Update ();
}//colorpad2 ()
myToolBarProc(int nBtn,int nContext){
if(nBtn==100){// demonstration
cs.SetBackground(245,245,245);
setDisplay (1);
sn=sn+1;
if (sn>1) sn=0 ;
show_pad ();
}
if(nBtn==101){//mode+
sn=sn+1;
if (sn>9)sn=9;
show_pad ();
}
if(nBtn==102){//mode -
sn=sn-1;
if (sn<1)sn=1;
show_pad ();
}
if(nBtn==103){// Display board
setDisplay (1);
}
if(nBtn==104){// Exit procedure
clearOutput();
cs.ClearDraw (0,src);
setDisplay (0);
exit (0);
}
if(nBtn==105){//
setDisplay (1);
//cover ();
}
}//myToolBar ()
//== End ==
边栏推荐
- RMAN abnormal machine recovery error rman-06026 rman-06023
- MATLAB(4)函数及文件
- Why does the magnetic variable speed gear reverse?
- 2022年了,跨端技术方案应该怎么选?
- [PostgreSQL] PostgreSQL 15 optimizes distinct
- Mysql学习笔记-分页-表的创建-数据类型
- 人大、微软等提出InclusiveFL:异构设备上的包容性联邦学习
- STM32F407 NVIC
- Wi Fi sensing technology and practice based on channel state information
- 聚焦绿色发展新赛道—MapGIS智慧环保解决方案发布
猜你喜欢
随机推荐
3.Golang字符串string类型
Leetcode 150. 逆波兰表达式求值
[wechat applet] use a thousand hand float - rollback
QT learning diary 17 - QT database
rman异机恢复报错RMAN-06026 RMAN-06023
Research and implementation of 5g network Slicing Based on AI intelligent correlation technology
Stc8h development (XIV): I2C drive rx8025t high-precision real-time clock chip
QT -- excellent open source project
qt 实现遍历文件夹
STL string 输入输出重载1
Time consuming test of construction and sorting of set, vector and list
Leetcode 239. 滑动窗口最大值
Ten minutes from pytorch to mxnet
[binomial tree] the power of the button cattle customers must brush questions
数字化转型的两种误区
LeetCode_216_组合总和Ⅲ
TiKV 线程池性能调优
Solution of connecting MySQL instance with public network
微机原理与技术接口 实验四 子程序及中断实验
How to delay loading JS



![[machine learning] evaluation index and code implementation of multi label classification](/img/01/7172841c663b5d9b79756e742bbc2c.png)





