Графика и языки и МЫ
XONIX и МЫ kenokeno.ucoz.ru/blog/xonix/2022-10-14-90
Универсальная программа kenokeno.ucoz.ru/blog/universal/2022-10-25-93
Интегральное просвещение kenokeno.ucoz.ru/publ/intpro/1-1-0-20
Многие программы kenokeno.ucoz.ru/publ/prog/1-1-0-11
Компилирует c# bat 3 строки
csc.exe /target:winexe xontime.cs
pause
xontime.exe
Удобно задать в Windows общую переменную
Path
C:\Windows\Microsoft.NET\Framework64\v4.0.30319
Псевдо 3Д рельеф Pseudo 3d Relief
ReliefUp C#
using System; using System.Drawing; // reliefup.cs
using System.Windows.Forms;
class reliefup: Form
{ public static void Main()
{ Application.Run(new reliefup()); }
public reliefup()
{ Text = "RELIEFUP"; Width = 600; Height = 500;
BackColor = System.Drawing.Color.Blue;
ForeColor = System.Drawing.Color.Red;
}
protected override void OnPaint(PaintEventArgs dan)
{ int N=90; int q=11; int[,] a = new int[q+1, N];
Random rand = new Random(); int x,y,t,i,j;
for (x=1; x < q; x++) // All coord before start
for (y=1; y < N-5; y++)
if (rand.Next(100) % 9 == 5)
{ a[x, y] = 5; a[x, y+1] = 10; a[x, y+2] = 20;
a[x, y+3] = 40; a[x, y+4] = 80; y = y+5;
}
Graphics dav = dan.Graphics;
SolidBrush BlueBrush = new SolidBrush(Color.Green);
Pen pred = new Pen(Color.Magenta, 3);
Pen pora = new Pen(Color.Orange, 3);
Pen pblu = new Pen(Color.Blue, 3);
for (t=1; t < N-q; t++) // Lenght N-q
{ for (i=1; i < q-1; i++) // Screen coord
for (j=1; j < q-1; j++)
a[i,j] = a[i, j+t];
for (y=1; y < q-1; y++) // Draw Y
for (x=1; x < q-2; x++)
dav.DrawLine(pred, new Point(30+20*x+20*y, 400-20*y-a[x,y]), new Point(30+20*(x+1)+20*y, 400-20*y-a[x+1, y]));
for (x=1; x < q-1; x++) // Draw X
for (y=1; y < q-2; y++)
dav.DrawLine(pora, new Point(30+20*x+20*y, 400-20*y-a[x, y]), new Point(30+20*(x+1)+20*y, 400-20*(y+1)-a[x, y+1]));
System.Threading.Thread.Sleep(200);
for (y=1; y < q-1; y++) // Blue Y CLEAR
for (x=1; x < q-2; x++)
dav.DrawLine(pblu, new Point(30+20*x+20*y, 400-20*y-a[x,y]), new Point(30+20*(x+1)+20*y, 400-20*y-a[x+1, y]));
for (x=1; x < q-1; x++) // Blue X CLEAR
for (y=1; y < q-2; y++)
dav.DrawLine(pblu, new Point(30+20*x+20*y, 400-20*y-a[x, y]), new Point(30+20*(x+1)+20*y, 400-20*(y+1)-a[x, y+1]));
}}}
// for (int s=1; s<1000000; s++);
//dav.FillRectangle(BlueBrush, 20, 150, 300, 250);
ReliefUp qb64 qbasic
N = 200: q = 15: SCREEN 12: RANDOMIZE TIMER: DIM a(q+1, N)'relup.bas 5d relief up Nov2021
FOR x = 1 TO q: FOR y = 1 TO N-5:
IF INT(RND*100) MOD 7 = 5 THEN
a(x,y) = 5: a(x, y+1) = 10: a(x, y+2) = 20: a(x, y+3) = 40: a(x, y+4) = 80: y = y+5
END IF
NEXT: NEXT
FOR t = 1 TO N-q
FOR i = 1 TO q-1: FOR j = 1 TO q-1: a(i,j) = a(i,j+t): NEXT: NEXT: CLS
FOR y = 1 TO q-1: FOR x = 1 TO q-2
LINE (30+20*x+20*y, 400-20*y-a(x, y))-(30+20*(x+1)+20*y, 400-20*y-a(x+1, y)), (y+t MOD 7)+1
NEXT: NEXT
FOR x = 1 TO q-1: FOR y = 1 TO q-2
LINE (30+20*x+20*y, 400-20*y-a(x, y))-(30+20*(x+1)+20*y, 400-20*(y+1)-a(x, y+1)), 7
NEXT: NEXT: _DELAY 0.2: NEXT
END
Диаграмма C#
using System; using System.Drawing; // diagout.cs
using System.Windows.Forms; class diagout: Form
{ public static void Main()
{ Application.Run(new diagout());}
public diagout()
{ Text = "diagout"; Width = w; Height = h;
BackColor = System.Drawing.Color.Blue;
ForeColor = System.Drawing.Color.Red;
}
int w=300, h=200;
protected override void OnPaint(PaintEventArgs dan)
{ Graphics dav = dan.Graphics; int i,j; int n=13;
Random rand = new Random(); float s=0,u=0;
float[] d = new float[n]; // случайные
float[] a = new float[n]; // углы
float[] r = new float[n+1]; // дуга градусы
Pen pmag = new Pen(Color.Magenta, 3);
Pen pgre = new Pen(Color.Green, 3);
Pen pred = new Pen(Color.Red, 3);
for (i=0; i<n-1; i++)
{ d[i] = (9+rand.Next(88)); s += d[i];
}
for (i=0; i<n; i++)
{ a[i] = d[i]*360/s; u += a[i];
}
r[0]=0;
for (i=1; i < n-1; i++)
r[i] = r[i-1] + a[i-1];
for (i=0; i < n; i++)
for (j=1; j <= 20; j++)
for (int k=1; k<200; k++)
{ if (0== i % 2) dan.Graphics.DrawArc(pmag, 60-2*j,60-2*j, 20+4*j,20+4*j, r[i], a[i]);
if (1== i % 2) dan.Graphics.DrawArc(pgre, 60-2*j,60-2*j, 20+4*j,20+4*j, r[i], a[i]);
// System.Threading.Thread.Sleep(10);
}
for (j=1; j <= 20; j++)
for (i=0; i < n; i++)
{ if (0== i % 2) dan.Graphics.DrawArc(pred, 170-2*j,60-2*j, 20+4*j,20+4*j, r[i], a[i]);
if (1== i % 2) dan.Graphics.DrawArc(pmag, 170-2*(21-j),60-2*(21-j), 20+4*(21-j),20+4*(21-j), r[i], a[i]);
System.Threading.Thread.Sleep(10);
}
}}
Диаграмма qbasic qb64
'diagout.bas Russian Circle Diagram
' http://kenokeno.ucoz.ru/gif/diagout.gif
N=12: s=0: DIM d(N),r(N+1): SCREEN 12: RANDOMIZE TIMER
FOR i=1 TO N: d(i)=INT(RND*90+9): s=s+d(i): PRINT d(i): NEXT: PRINT "SUM= "; s
FOR i=2 TO N: r(i)=r(i-1)+d(i)*2*3.1416/s: NEXT: r(N+1)=r(1)
FOR i=2 TO N+1 STEP 2: FOR j=1 TO 100: CIRCLE (150,100),j,i,r(i-1),r(i)
CIRCLE (149,99),j,i,r(i-1),r(i): CIRCLE (151,99),j,i,r(i-1),r(i)
_DELAY .003: NEXT: NEXT
FOR i=3 TO N+1 STEP 2: FOR j=100 TO 1 STEP -1: CIRCLE (150,100),j,i,r(i-1),r(i)
CIRCLE (149,99),j,i,r(i-1),r(i): CIRCLE (151,99),j,i,r(i-1),r(i)
_DELAY .01: NEXT: NEXT
FOR j=1 TO 100: FOR i=2 TO N+1
IF (i MOD 2)=0 THEN CIRCLE (350,100),j,i,r(i-1),r(i): CIRCLE (349,99),j,i,r(i-1),r(i): CIRCLE (351,99),j,i,r(i-1),r(i)
IF (i MOD 2)=1 THEN CIRCLE (350,100),100-j,i,r(i-1),r(i): CIRCLE (349,99),100-j,i,r(i-1),r(i): CIRCLE (351,99),100-j,i,r(i-1),r(i)
NEXT: _DELAY .02: NEXT: END
Заливка экрана точками
Программа zakraska.bas заполняет экран точками
разделив поле на участки 4х4 или произвольно
и лучше стороны поля кратно малых участков
Строка под меткой 3:
вращающаяся строка проверяет условие и повторяет себя
Точка ставится строго в пустое место и поле заполняется на 100%
и ещё есть счётчики точек не поставленных и счётчик времени
Результаты:
2х2 2 секунды и 27 тыс повторов для 25 тыс точек
4х4 5 секунд и 65 тыс повторов для 25 тыс точек
8х8 15 секунд и 95 тыс повторов для 25 тыс точек
16х16 55 секунд и 135 тыс повторов для 25 тыс точек
32х32 много секунд и много повторов для 25 тыс точек
Поле закрашивается на 100%
Вывод: случайные контролировать реально
В конце чёрные точки распыляются без проверки повторов
в количестве точек произведения длины и ширины
и остаются закрашенные точки
Вариант отмены закраски повысив количество циклов
всё одно оставляет закрашенные точки
Вывод: случайные без контроля неуправляемые
Данный алгоритм Закраска может проявлять гос флаги из полос
Плюс есть идея: exe считывает из начала бэйсик программы параметры
ширина и высота и размер квадрата
и возможно закрашивать знако места текстовые
и закрашиваемые квадранты возможны разноцветные как шахматная доска
ИТОГО: абсолютно случайные быстро заполняют экран на 100%
w = 240: h = 180: p = w * h: Screen 12 ' zakraska.bas
s = 6: a = w / s: b = h / s: Randomize Timer: n = 0: t = Timer
For k = 1 To s ^ 2 '* 2
For i = 0 To a - 1
For j = 0 To b - 1
3 c = Int(Rnd * s) + 1: d = Int(Rnd * s) + 1: If Point(i * s + c, j * s + d) = 4 Then n = n + 1: GoTo 3
PSet (i * s + c, j * s + d), 4 '+ k Mod 3
Next: Locate h / 16 + 2, 1: Print n; "points repetition from"; p
Next: _Delay .205: Next: _Delay 1:
Print Timer - t; "seconds for"; s; "x"; s ': GoTo 5
For k = 1 To 2 ' quick
For i = 0 To w
For j = 0 To h
c = Int(Rnd * w) + 1: d = Int(Rnd * h) + 1
PSet (c, d), 0 '1: '_Delay .00005
Next: Next: Next
End
5 For k = 1 To s ^ 2 * 2 ' variant
For i = 0 To a - 1
For j = 0 To b - 1
c = Int(Rnd * s) + 1: d = Int(Rnd * s) + 1
PSet (i * s + c, j * s + d), 0 '+ k Mod 3
Next: Next: _Delay .205: Next: _Delay 1
End
Zokras C#
using System; using System.Drawing; // zokras.cs
using System.Windows.Forms; class zokras: Form
{ public static void Main()
{ Application.Run(new zokras());}
public zokras()
{ Text = "zokras"; Width = w; Height = h;
BackColor = System.Drawing.Color.Magenta;
ForeColor = System.Drawing.Color.Red;
}
int w=300, h=200, s=6, n=0; int p,a,b,c,d;
protected override void OnPaint(PaintEventArgs dan)
{ Graphics dav = dan.Graphics;
Pen pmag = new Pen(Color.Magenta, 3);
Pen pgre = new Pen(Color.Green, 3);
Pen pred = new Pen(Color.Red, 3);
Random rand = new Random(); int i,j,k;
p = h*w; a = w/s; b = h/s;
for (k=1; k <= s*s; k++)
{ for (i=0; i <= a-1; i++)
for (j=0; j < b-1; j++)
{ c = (1+rand.Next(s)); d = (1+rand.Next(s)); n++;
dan.Graphics.DrawLine(pgre, i*s+c, j*s+d, i*s+c+1, j*s+d+1);
// dan.Graphics.DrawPoint(pgre, i*s+c, j*s+d);
// dan.Graphics.DrawEllipse(pgre, i*s+c, j*s+d, 1,1);
}
// System.Threading.Thread.Sleep(5);
}
}}
Соединяет все точки C#
using System; using System.Drawing; // SOEDIN.cs
using System.Windows.Forms; class SOEDIN
{ Timer timer; Form form;
int[] x = new int[10]; int[] y = new int[10];
static void Main(string[] args)
{ var p = new SOEDIN();
}
public SOEDIN()
{ form = new Form()
{ Text = "SOEDIN", Width = 600, Height = 360 };
timer = new Timer() { Interval = 2000 };
timer.Tick += delegate(object sender, EventArgs e)
{ Random rand = new Random();
for (int i = 1; i <=8; i++)
{ x[i]=50+rand.Next(400);
y[i]=50+rand.Next(200);
}
Graphics f = Graphics.FromHwnd(form.Handle);
f.Clear(Color.Green);
Graphics w = Graphics.FromHwnd(form.Handle);
for (int i = 1; i <=8; i++)
w.DrawEllipse(new Pen(Color.Magenta, i), x[i]-10, y[i]-5, 20, 10);
for (int i = 1; i < 8; i++)
for (int j = 8; j > i; j--)
{ Bitmap dblBuffer = new Bitmap(form.Width, form.Height);
Graphics g = Graphics.FromImage(dblBuffer);
g.DrawLine(new Pen(Color.Red, i), new Point(x[i], y[i]), new Point(x[j], y[j]));//Pens.Red
f.DrawImage(dblBuffer, new Point(0, 0));
System.Threading.Thread.Sleep(200);
}
System.Threading.Thread.Sleep(500);
Array.Clear(x, 0, 10); Array.Clear(y, 0, 10);
};
timer.Start();
Application.Run(form);
}
}
SOEDIN.htm
<!DOCTYPE html> <html> <body>
<canvas id = "image_1" width = "400px" height = "250px"
style = "border:solid 2px black"> </canvas>
<script> var im_1 = image_1.getContext('2d'); // SOEDIN.htm
var i,j; var n=7; var x=[n],y=[n] // Массивы
for (i=0; i<n; i++) // Случайные
{ x[i] = Math.floor(Math.random()*400);
y[i] = Math.floor(Math.random()*200);
}
for (i=0; i<n-1; i++) for (j=i+1; j<n; j++)
{ im_1.moveTo(x[i],y[i]); // Начальная точка
im_1.lineTo(x[j],y[j]); // Линия в точку
im_1.stroke(); // Рисуем в браузере
}
</script> </body></html>
Маятник Pendulum c# Rosettacode чужой алгоритм
using System; using System.Drawing; // pendulum.cs
using System.Windows.Forms;
class CSharpPendulum
{ Form _form; Timer _timer;
double _angle = Math.PI / 2, _dt = 0.1,
_angleAccel, _angleVelocity = 0;
int _length = 50;
[STAThread] static void Main()
{ var p = new CSharpPendulum(); }
public CSharpPendulum()
{ _form = new Form()
{ Text = "Pendulum", Width = 200, Height = 200 };
_timer = new Timer() { Interval = 30 };
_timer.Tick += delegate(object sender, EventArgs e)
{ int anchorX = (_form.Width / 2) - 12,
anchorY = _form.Height / 4,
ballX = anchorX + (int)(Math.Sin(_angle) * _length),
ballY = anchorY + (int)(Math.Cos(_angle) * _length);
_angleAccel = -9.81 / _length * Math.Sin(_angle);
_angleVelocity += _angleAccel * _dt;
_angle += _angleVelocity * _d
Bitmap dblBuffer = new Bitmap(_form.Width, _form.Height);
Graphics g = Graphics.FromImage(dblBuffer);
Graphics f = Graphics.FromHwnd(_form.Handle);
g.DrawLine(Pens.Black, new Point(anchorX, anchorY), new Point(ballX, ballY));
g.FillEllipse(Brushes.Black, anchorX - 3, anchorY - 4, 7, 7);
g.FillEllipse(Brushes.DarkGoldenrod, ballX - 7, ballY - 7, 14, 14);
f.Clear(Color.White);
f.DrawImage(dblBuffer, new Point(0, 0));
};
_timer.Start();
Application.Run(_form);
}}
Шарик летает и масштабируется C# чужой алгоритм 2001
using System; using System.Drawing; // xobow.cs
using System.Windows.Forms;
class Bounce: Form
{ const int iTimerInterval = 25; // милисекунд
const int iBallSize = 16; // клиентская область
const int iMoveSize = 4; // размер мяча
Bitmap bitmap; int xCenter, yCenter;
int cxRadius, cyRadius, cxMove, cyMove, cxTotal, cyTotal;
public static void Main()
{ Application.Run(new Bounce()); }
public Bounce()
{ Text = "Bounce"; ResizeRedraw = true;
BackColor = Color.Green;
Timer timer = new Timer();
timer.Interval = iTimerInterval;
timer.Tick += new EventHandler(TimerOnTick);
timer.Start();
OnResize(EventArgs.Empty);
}
protected override void OnResize(EventArgs ea)
{ Graphics grfx = CreateGraphics();
grfx.Clear(BackColor);
float fRadius = Math.Min(ClientSize.Width / grfx.DpiX,
ClientSize.Height / grfx.DpiY) / iBallSize;
cxRadius = (int) (fRadius * grfx.DpiX);
cyRadius = (int) (fRadius * grfx.DpiY);
grfx.Dispose();
cxMove = Math.Max(1, cxRadius / iMoveSize);
cyMove = Math.Max(1, cyRadius / iMoveSize);
cxTotal = 2 * (cxRadius + cxMove);
cyTotal = 2 * (cyRadius + cyMove);
bitmap = new Bitmap(cxTotal, cyTotal);
grfx = Graphics.FromImage(bitmap);
grfx.Clear(BackColor);
DrawBall(grfx, new Rectangle(cxMove, cyMove,
2 * cxRadius, 2 * cyRadius));
grfx.Dispose();
xCenter = ClientSize.Width / 2;
yCenter = ClientSize.Height / 2;
}
protected virtual void DrawBall(Graphics grfx, Rectangle rect)
{ grfx.FillEllipse(Brushes.Red, rect);
}
void TimerOnTick(object obj, EventArgs ea)
{ Graphics grfx = CreateGraphics();
grfx.DrawImage(bitmap, xCenter - cxTotal / 2,
yCenter - cyTotal / 2,
cxTotal, cyTotal);
grfx.Dispose();
xCenter += cxMove; yCenter += cyMove;
if ((xCenter + cxRadius >= ClientSize.Width) ||
(xCenter - cxRadius <= 0)) cxMove = -cxMove;
if ((yCenter + cyRadius >= ClientSize.Height) ||
(yCenter - cyRadius <= 0)) cyMove = -cyMove;
}
}
Screen Filler
Zakraska.bas program fills screen with dots
by dividing field into a 4x4 section or arbitrarily
and better sides of field of multiples of small sections
Row under label 3:
rotating row checks condition and repeats itself
Dot is placed strictly in an empty place and field is filled in 100%
and there are also counters of points not set and a time counter
Results:
2x2 = 2 seconds & 27ooo repetitions for 25ooo points
4x4 = 5 seconds & 65ooo repetitions for 25ooo points
8x8 = 15 seconds & 95ooo repetitions for 25ooo points
16x16 = 55 seconds & 135ooo repetitions for 25ooo points
32x32 many seconds & many repetitions for 25ooo points
Field is filled in by 100%
Conclusion: random control is real
At end dark dots are sprayed without checking for repetitions
in number of points of product of length and width
shaded points remain
Option of canceling shading by increasing number of cycles
all one leaves shaded points
Conclusion: random without control unmanaged
This shading algorithm can show state flags from stripes
Plus there is an idea: exe reads from beginning of basic program parameters
width and height and size of square
and it is possible to paint text screen sign
and colorable quadrats possibly multicolored like a chessboard
TOTAL: absolutely random quickly fill the screen by 100%
Цветовая гамма c#
using System; using System.Drawing; // colors.cs
using System.Windows.Forms; class colors: Form
{ public static void Main()
{ Application.Run(new colors());}
public colors()
{ Text = "colors"; Width = w; Height = h;
BackColor = System.Drawing.Color.Magenta;
ForeColor = System.Drawing.Color.Red;
}
int w=400, h=630;
protected override void OnPaint(PaintEventArgs dan)
{ Graphics dav = dan.Graphics; int x,y,d;
Random rand = new Random(); int e=50; d = -e;
d += e; for (x=90; x < 256; x++) for (y=d; y < d+e; y++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(x,0,0),1)), x-90,y, 1,1);
d += e; for (x=90; x < 256; x++) for (y=d; y < d+e; y++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(0,x,0),1)), x-90,y, 1,1);
d += e; for (x=90; x < 256; x++) for (y=d; y < d+e; y++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(0,0,x),1)), x-90,y, 1,1);
d += e; for (x=255; x > 90; x--) for (y=d; y < d+e; y++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(0,x,x),1)), x-90,y, 1,1);
d += e; for (x=255; x > 90; x--) for (y=d; y < d+e; y++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(x,0,x),1)), x-90,y, 1,1);
d += e; for (x=255; x > 90; x--) for (y=d; y < d+e; y++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(x,x,0),1)), x-90,y, 1,1);
//////////////
d += e; for (y=d+e; y>d; y--) for (x=40; x < 206; x++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(205-x,x,0),1)), x-40,y, 1,1);
d += e; for (y=d+e; y>d; y--) for (x=40; x < 206; x++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(x,205-x,0),1)), x-40,y, 1,1);
d += e; for (y=d+e; y>d; y--) for (x=40; x < 206; x++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(205-x,0,x),1)), x-40,y, 1,1);
d += e; for (y=d; y < d+e; y++) for (x=205; x > 40; x--)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(0,x,205-x),1)), x-40,y, 1,1);
d += e; for (y=d; y < d+e; y++) for (x=205; x > 40; x--)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(x,0,205-x),1)), x-40,y, 1,1);
d += e; for (y=d; y < d+e; y++) for (x=205; x > 40; x--)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(0,205-x,x),1)), x-40,y, 1,1);
//////////////
e = 206; d = -e;
d += e; for (x=30; x < 256; x++) for (y=50; y < 256; y++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(x,0,y),1)), 136+x,d+y-50, 1,1);
d += e; for (x=255; x > 30; x--) for (y=50; y < 256; y++)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(0,x,y),1)), 136+x,d+y-50, 1,1);
d += e; for (y=255; y > 50; y--) for (x=255; x > 30; x--)
dan.Graphics.DrawEllipse((new Pen(Color.FromArgb(x,y,0),1)), 136+x,d+y-50, 1,1);
}}
e = 50: d = -e: p = .001 ' atomicheart.bas
w = 400: h = 630: Screen _NewImage(w, h, 32)
d = d + e: For x = 90 To 256: For y = d To d + e
PSet (x - 90, y), _RGB32(x, 0, 0):
Next: _Delay p: Next
d = d + e: For x = 90 To 256: For y = d To d + e
PSet (x - 90, y), _RGB32(0, x, 0):
Next: _Delay p: Next
d = d + e: For x = 90 To 256: For y = d To d + e
PSet (x - 90, y), _RGB32(0, 0, x):
Next: _Delay p: Next
'//////////////
d = d + e: For x = 255 To 90 Step -1: For y = d To d + e
PSet (x - 90, y), _RGB32(0, x, x):
Next: _Delay p: Next
d = d + e: For x = 255 To 90 Step -1: For y = d To d + e
PSet (x - 90, y), _RGB32(x, 0, x):
Next: _Delay p: Next
d = d + e: For x = 255 To 90 Step -1: For y = d To d + e
PSet (x - 90, y), _RGB32(x, x, 0):
Next: _Delay p: Next
'//////////////
d = d + e: For y = d + e To d Step -1: For x = 40 To 206
PSet (x - 40, y), _RGB32(205 - x, x, 0):
Next: _Delay p * 2: Next
d = d + e: For y = d + e To d Step -1: For x = 40 To 206
PSet (x - 40, y), _RGB32(x, 205 - x, 0):
Next: _Delay p * 3: Next
d = d + e: For y = d + e To d Step -1: For x = 40 To 206
PSet (x - 40, y), _RGB32(205 - x, 0, x):
Next: _Delay p * 5: Next
d = d + e: For y = d To d + e: For x = 205 To 40 Step -1
PSet (x - 40, y), _RGB32(0, x, 205 - x)
Next: _Delay p * 7: Next
d = d + e: For y = d To d + e: For x = 205 To 40 Step -1
PSet (x - 40, y), _RGB32(x, 0, 205 - x)
Next: _Delay p * 5: Next
d = d + e: For y = d To d + e: For x = 205 To 40 Step -1
PSet (x - 40, y), _RGB32(0, 205 - x, x)
Next: _Delay p * 8: Next
e = 206: d = -e
d = d + e: For x = 30 To 256: For y = 50 To 256
PSet (136 + x, d + y - 50), _RGB32(x, 0, y)
Next: _Delay p * 5: Next
d = d + e: For x = 255 To 30 Step -1: For y = 50 To 256
PSet (136 + x, d + y - 50), _RGB32(0, x, y)
Next: _Delay p * 3: Next
d = d + e: For y = 255 To 50 Step -1: For x = 255 To 30 Step -1
PSet (136 + x, d + y - 50), _RGB32(x, y, 0)
Next: _Delay p * 2: Next
Цветные секторы эксперимент c#
using System; using System.Drawing; // diagcol.cs
using System.Windows.Forms; class diagcol: Form
{ public static void Main()
{ Application.Run(new diagcol());}
public diagcol()
{ Text = "diagcol"; Width = w; Height = h;
BackColor = System.Drawing.Color.Blue;
ForeColor = System.Drawing.Color.Red;
}
int w=300, h=200;
protected override void OnPaint(PaintEventArgs dan)
{ Graphics dav = dan.Graphics; int i,j,col; int n=13;
Random rand = new Random(); float s=0,u=0;
float[] d = new float[n]; // случайные
float[] a = new float[n]; // углы
float[] r = new float[n+1]; // дуга градусы
int [,] c = new int[n+1,21]; // цвета
Pen pmag = new Pen(Color.Magenta, 3);
Pen pgre = new Pen(Color.Green, 3);
Pen pred = new Pen(Color.Red, 3);
for (i=0; i<n-1; i++)
{ d[i] = (9+rand.Next(88)); s += d[i];}
for (i=0; i<n; i++)
{ a[i] = d[i]*360/s; u += a[i];}
for (i=0; i<n; i++)
{ col = (90+rand.Next(160));
for (j=0; j<11; j++) c[i,j] = col;
}
for (i=0; i<n; i++)
{ col = (90+rand.Next(160));
for (j=11; j<21; j++)c[i,j] = col;
}
r[0]=0;
for (i=1; i < n-1; i++)
r[i] = r[i-1] + a[i-1];
for (i=0; i < n; i++)
for (j=1; j <= 20; j++)
for (int k=1; k < 200; k++)
{ if (0== i % 2) dan.Graphics.DrawArc((new Pen(Color.FromArgb(c[i,j],0,c[i,j]),3)), 60-2*j,60-2*j, 20+4*j,20+4*j, r[i], a[i]);
if (1== i % 2) dan.Graphics.DrawArc(pgre, 60-2*j,60-2*j, 20+4*j,20+4*j, r[i], a[i]);
// System.Threading.Thread.Sleep(10);
}
for (j=1; j <= 20; j++)
{ for (i=0; i < n; i++)
{ if (0== i % 2) dan.Graphics.DrawArc(pred, 170-2*j,60-2*j, 20+4*j,20+4*j, r[i], a[i]);
if (1== i % 2) dan.Graphics.DrawArc(pmag, 170-2*(21-j),60-2*(21-j), 20+4*(21-j),20+4*(21-j), r[i], a[i]);
} System.Threading.Thread.Sleep(100);
}
}}
Технологический цикл замкнулся
раньше в ЯП бэйсик кнопки сочиняли вручную
и потом появились среды визуальные
и сейчас опять кто пишет кнопки сам как я
те экономят время и получают 1 программу 1cs=1exe
зато среды ЯП создают лишнюю кучу файлов
Technological cycle closed
earlier in PL basic buttons were composed manually
and then visual environments appeared
and now again those who write buttons themselves like me
save time and get 1 program 1cs=1 exe
but PL environments create an extra bunch of files
Русский школьный алгоритм: массив и точки и сетка анимированная
Видим вектор движения делится половинами 5=(1+9)/2
3=(1+5)/2: 2=(1+3)/2: 4=(3+5)/2: 7=(5+9)/2: 6=(5+7)/2: 8=(7+9)/2
Главная цель: перевод на другие языки особенно JavaScript
Russian school algorithm: array and dots and animated mesh
We see that motion vector is divided into halves 5=(1+9)/2
3=(1+5)/2: 2=(1+3)/2: 4=(3+5)/2: 7=(5+9)/2: 6=(5+7)/2: 8=(7+9)/2
Main target: translation into other languages especially JavaScript
damesh.bas qbjs.org
Randomize Timer ' damesh.bas Danilin from Russia
Screen 12 ' 1! 2 3? 4 5! 6 7? 8 9!
n=8: u=256: Dim x(n,9),y(n,9)
For i=1 To n
x(i,1)=Int(Rnd*u+3): y(i,1)=Int(Rnd*u+3)
x(i,9)=Int(Rnd*u+3): y(i,9)=Int(Rnd*u+3)
Next
Data -5,1,9,-3,1,5,-2,1,3,-4,3,5,-7,5,9,-6,5,7,-8,7,9
For g=1 To 9 - 2: Read d,a,v
For i=1 To n: x(i,-d)=(x(i,a) +x(i,v))/2: y(i,-d)=(y(i,a) +y(i,v))/2: Next
Next
For g=1 To 10: For k=1 To 9: _Delay .1: Cls
For i=1 To n: For j=1 To n: Circle (x(i,k),y(i,k)),2: Next: Next
For i=1 To n - 1: For j=i To n
Line (x(i,k),y(i,k))-(x(j,k),y(j,k)),i
Next: Next: Next
For k=8 To 2 Step -1: _Delay .1: Cls
For p=1 To 9
For i=1 To n: For j=1 To n: Circle (x(i,p),y(i,p)),2,i: Next: Next
Next
For i=1 To n - 1: For j=i To n
Line (x(i,k),y(i,k))-(x(j,k),y(j,k)),i
Next: Next: Next
Next
Очевидное развитие: циклы без кругов и циклы с кругами
Сейчас массив 2-мерный: номер точки и номер на векторе
Возможен массив 3-мерный: несколько векторов подряд
Возможен поворот фигуры и масштабирование масштабируя алгоритм
Математическая основа: моя универсальная таблица связи 2-х точек
Obvious development: cycles without circles and cycles with circles
Now array is 2-dimensional: point number and number on vector
A 3-dimensional array is possible: several vectors in a row
It is possible to rotate shape and scale by scaling algorithm
Mathematical basis: my universal table of connection of 2 points
<!DOCTYPE html> <html> <body>
<canvas id = "image_1" width = "200px" height = "100px" style = "border:solid 2px black"> </canvas>
<canvas id = "image_2" width = "200px" height = "100px" style = "border:solid 2px black"> </canvas>
<canvas id = "image_3" width = "200px" height = "100px" style = "border:solid 2px black"> </canvas>
<script> // SOEDIN.htm
var i,j,k; var n=6; var x=[n],y=[n] // Массивы
for (k=0; k<1; k++)
{ var im_1 = image_1.getContext('2d');
for (i=0; i<n; i++) // Случайные
{ x[i] = Math.floor(Math.random()*200);
y[i] = Math.floor(Math.random()*100);
}
for (i=0; i<n-1; i++) for (j=i+1; j<n; j++)
{ im_1.lineWidth = 2; // толщина
im_1.strokeStyle = 'red'; // цвет буквами
im_1.moveTo(x[i],y[i]); // Начальная точка
im_1.lineTo(x[j],y[j]); // Линия в точку
im_1.stroke(); // Рисуем
}
var im_2 = image_2.getContext('2d');
for (i=0; i<n; i++) // Случайные
{ x[i] = Math.floor(Math.random()*200);
y[i] = Math.floor(Math.random()*100);
}
for (i=0; i<n-1; i++) for (j=i+1; j<n; j++)
{ im_2.lineWidth = 2; // толщина
im_2.strokeStyle = 'blue'; // цвет буквами
im_2.moveTo(x[i],y[i]); // Начальная точка
im_2.lineTo(x[j],y[j]); // Линия в точку
im_2.stroke(); // Рисуем
}
var im_3 = image_3.getContext('2d');
for (i=0; i<n; i++) // Случайные
{ x[i] = Math.floor(Math.random()*200);
y[i] = Math.floor(Math.random()*100);
}
for (i=0; i<n-1; i++) for (j=i+1; j<n; j++)
{ im_3.lineWidth = 2; // толщина
im_3.strokeStyle = 'magenta'; // цвет буквами
im_3.moveTo(x[i],y[i]); // Начальная точка
im_3.lineTo(x[j],y[j]); // Линия в точку
im_3.stroke(); // Рисуем
}
}
</script> </body></html>
|