当前位置:网站首页>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 ==
边栏推荐
- Leetcode 1310. Subarray XOR query
- A simple websocket example
- 延迟加载JS的方式
- Nintendo patent shows that the follow-up products of fitness ring accessories may be under development
- 【嵌入式单元测试】C语言单元测试框架搭建
- C语言绘画示例-进度条
- TCP congestion control details | 7 Surpass TCP
- Leetcode skimming -- find and minimum k-pair number 373 medium
- Leetcode 1304. N different integers with zero and
- 任天堂专利显示健身环配件后续产品或已在开发中
猜你喜欢
![[machine learning] evaluation index and code implementation of multi label classification](/img/01/7172841c663b5d9b79756e742bbc2c.png)
[machine learning] evaluation index and code implementation of multi label classification

LeetCode_ 77_ combination

Leetcode skimming -- find and minimum k-pair number 373 medium

getchar()

Round table record: fireside dialogue -- how to realize innovation in Web3

QT -- excellent open source project

Two misunderstandings of digital transformation

Redis distributed cache redis cluster

【机器学习】多标签分类的评价指标与代码实现

Application of semi supervised learning in malware traffic detection
随机推荐
Solve the problem that QQ mail and Thunderbird cannot log in to outlook
NAT technology and NAT alg
HCIP(4)
Leetcode 1252. Number of odd value cells
Solution of connecting MySQL instance with public network
文件一键备份
HCIP(8)
Overview of the application of air, space and sea Association
Introduction and Simulation Implementation of string class
TiKV 线程池性能调优
Microcomputer principle and technology Interface Experiment four subroutines and interrupt experiment
Send blocking, receive blocking
Nature子刊 | 地下水固碳速率与寡营养海洋系统固碳速率相近
03-2、
STL string输入输出重载2
3.Golang字符串string类型
微机原理与技术接口 实验四 子程序及中断实验
Fundamentals of scala (3): operators and process control
Leetcode 239. 滑动窗口最大值
Chinese garbled code problem in reading binary files