-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflip_leaf_clock.cpp
2762 lines (1832 loc) · 57 KB
/
flip_leaf_clock.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (C) 2022 BrerDawg
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//flip_leaf_clock.cpp
//v1.01 2022-jul-16 //x11 screensaver
//v1.0? 20?? //added: ?
#include "flip_leaf_clock.h"
#define FALSE 0
#define TRUE 1
#define BLACK 0x000000
#define WHITE 0xFFFFFF
#define RED 0xff0000
#define GREEN 0x00ff00
#define BLUE 0x0000ff
string s_m1_dbg; //used to write a debug file via 'm1_dbg'
mystr m1_dbg;
Window root;
Display *dpy;
XWindowAttributes gwa;
GC gc;
XftColor xftcolor;
XftFont *font25;
XftFont *font150;
XftDraw *xft_draw;
Pixmap pixbf0;
Pixmap pixbf1;
XImage* xshm_img0;
XImage* xshm_img1;
Visual *visual;
Colormap cmap;
XShmSegmentInfo shminfo0;
XShmSegmentInfo shminfo1;
flip_clock_wnd fc;
//user opts
bool b_app_mode = 0;
bool b_debug = 0;
float wander_period = 30.0f; //reduces screen burn 0-->100
float factor_scale = 0.5f;
bool b_24hr = 0; //military display
float gravity = 50; //flip speed 2-->100
bool b_show_secs = 0;
string sdebug;
void append_dbg( string ss )
{
s_m1_dbg += ss;
m1_dbg = s_m1_dbg;
//m1_dbg.writefile( "/home/gc/zzzscnsvr_dbg.txt" ); //un-comment to dump to a txt file
}
uint32_t make_color( unsigned char rr, unsigned char gg, unsigned char bb)
{
uint32_t col = rr;
col = col << 8;
col |= gg;
col = col << 8;
col |= bb;
return col;
}
flip_clock_wnd::flip_clock_wnd()
{
bytes_per_pixel = 3; //set this so a minimum, will be changed once x11 is polled
filter_type = fwt_blackman_harris;
kern_size0 = 15;
theta_hrs = pi;
theta_mins = pi;
theta_secs = pi;
ihrs = 0;
imins = 0;
isecs = 57;
prev_secs = 0;
prev_mins = 0;
prev_hrs = 0;
b_24hr = 0;
b_show_secs = 0;
first_tick = 1;
last_secs = 0;
last_mins = 0;
last_hrs = 0;
last_theta_hrs = 0;
last_theta_mins = 0;
last_theta_secs = 0;
last_redraw_time = 0;
set_flip_speed( gravity );
m1_timer.time_start( m1_timer.ns_tim_start );
b_preview = 0;
}
flip_clock_wnd::~flip_clock_wnd()
{
}
void flip_clock_wnd::set_flip_speed( float grav )
{
if( grav < 2.0f ) grav = 2.0f;
if( grav > 100.0f ) grav = 100.0f;
flip_speed = 5.0f * grav / 100.0f;
}
uint32_t flip_clock_wnd::make_color( unsigned int rr, unsigned int gg, unsigned int bb )
{
uint32_t col = rr;
col = col << 8;
col |= gg;
col = col << 8;
col |= bb;
return col;
}
void flip_clock_wnd::set_color( int rr, int gg, int bb )
{
XSetForeground( dpy, gc, make_color( rr, gg, bb ) );
}
void flip_clock_wnd::draw_rectf( int xx, int yy, int ww, int hh )
{
XFillRectangle(dpy, pixbf0, gc, xx, yy, ww, hh );
}
void flip_clock_wnd::draw_rectf( unsigned char *bf, int xx, int yy, int ww, int hh, int linedx, unsigned char rr, unsigned char gg, unsigned char bb )
{
for( int y = yy; y < (hh + yy); y++ )
{
for( int x = xx; x < (ww + xx); x++ )
{
int ptr = y * linedx * bytes_per_pixel + x * bytes_per_pixel;
if( bytes_per_pixel == 3 )
{
bf[ptr] = bb;
bf[ptr + 1 ] = gg;
bf[ptr + 2 ] = rr;
}
else{
bf[ptr] = bb;
bf[ptr + 1 ] = gg;
bf[ptr + 2 ] = rr;
bf[ptr + 3 ] = 0;
}
}
}
}
void flip_clock_wnd::copy_area( unsigned char *bfsrc, int srcx, int srcy, int srcwid, int srchei, int linedx, unsigned char *bfdest, int destx, int desty, int destlinedx )
{
int yy = desty;
for( int y = srcy; y < (srcy + srchei); y++ )
{
int xx = destx;
for( int x = srcx; x < (srcx + srcwid); x++ )
{
if( bytes_per_pixel == 3 )
{
unsigned char rr, gg, bb, aa;
int ptr0 = y * linedx * bytes_per_pixel + x * bytes_per_pixel;
bb = bfsrc[ptr0];
gg = bfsrc[ptr0 + 1 ];
rr = bfsrc[ptr0 + 2 ];
int ptr1 = yy * destlinedx * bytes_per_pixel + xx * bytes_per_pixel;
bfdest[ptr1] = bb;
bfdest[ptr1 + 1 ] = gg;
bfdest[ptr1 + 2 ] = rr;
}
else{
unsigned char rr, gg, bb, aa;
int ptr0 = y * linedx * bytes_per_pixel + x * bytes_per_pixel;
bb = bfsrc[ptr0];
gg = bfsrc[ptr0 + 1 ];
rr = bfsrc[ptr0 + 2 ];
aa = bfsrc[ptr0 + 3 ];
int ptr1 = yy * destlinedx * bytes_per_pixel + xx * bytes_per_pixel;
bfdest[ptr1] = bb;
bfdest[ptr1 + 1 ] = gg;
bfdest[ptr1 + 2 ] = rr;
bfdest[ptr1 + 3 ] = aa;
}
xx++;
}
yy++;
}
}
void flip_clock_wnd::line_style( int line_width, int line_style, int cap_style, int join_style )
{
XSetLineAttributes( dpy, gc, line_width, line_style, cap_style, join_style );
}
void flip_clock_wnd::draw_line( int x0, int y0, int x1, int y1 )
{
XDrawLine( dpy, pixbf0, gc, x0, y0, x1, y1 );
}
void flip_clock_wnd::get_pixel( unsigned char *bf, int xx, int yy, int &rr, int &gg, int &bb, int linedx )
{
int ix = nearbyint( xx );
int iy = nearbyint( yy );
int psrc = ( (iy) * (linedx)*bytes_per_pixel ) + (ix)*bytes_per_pixel;
bb = bf[ psrc++ ];
gg = bf[ psrc++ ];
rr = bf[ psrc ];
}
void flip_clock_wnd::set_pixel( unsigned char *bf, int xx, int yy, int rr, int gg, int bb, int linedx )
{
int ix = nearbyint( xx );
int iy = nearbyint( yy );
int psrc = ( (iy) * (linedx)*bytes_per_pixel ) + (ix)*bytes_per_pixel;
bf[ psrc++ ] = bb;
bf[ psrc++ ] = gg;
bf[ psrc++ ] = rr;
if( bytes_per_pixel == 4 )
{
bf[ psrc ] = 0;
}
}
//draw a line in spec buf
void flip_clock_wnd::line_plot_in_buf( unsigned char *bf, int x1, int y1, int x2, int y2, int rr, int gg, int bb, int linedx )
{
float xx1 = x1;
float yy1 = y1;
float xx2 = x2;
float yy2 = y2;
if( 1 )
{
float dx = xx2 - xx1;
float dy = yy2 - yy1;
if( fabsf( dx ) >= fabsf( dy ) )
{
if( xx1 > xx2 )
{
float swap = xx1;
xx1 = xx2;
xx2 = swap;
swap = yy1;
yy1 = yy2;
yy2 = swap;
dx = -dx;
dy = -dy;
}
float m = ( yy2 - yy1 ) / ( xx2 - xx1 );
float b = -(m*xx1 - yy1);
//printf("%03d dx %f %f b %f m %f\n", dbg_line_idx, dx, dy, b, m );
int sub = 0;
for( int i = xx1; i < xx2; i+=1 )
{
int xx = i;
int yy = m*i + b;
set_pixel( bf, xx, yy, rr, gg, bb, linedx );
}
}
else{
//dy > dx
if( yy1 > yy2 )
{
float swap = xx1;
xx1 = xx2;
xx2 = swap;
swap = yy1;
yy1 = yy2;
yy2 = swap;
dx = -dx;
dy = -dy;
}
float m = ( xx2 - xx1 ) / ( yy2 - yy1 );
float b = -(m*yy1 - xx1);
int sub = 0;
for( int i = yy1; i < yy2; i+=1 )
{
int yy = i;
int xx = m*i + b;
set_pixel( bf, xx, yy, rr, gg, bb, linedx );
}
}
}
}
//rough circle, vars vals are not checked, 'theta_start' <= 'theta_end'
void flip_clock_wnd::arc_plot_in_buf( unsigned char *bf, int centrex, int centrey, int radius, float theta_start, float theta_end, float theta_step, int rr, int gg, int bb, int linedx )
{
if( theta_step < 0.0001 ) theta_step = 0.0001;
for( float theta = theta_start; theta < theta_end; theta += theta_step )
{
float xx = centrex + radius * cosf( theta );
float yy = centrey + radius * sinf( theta );
set_pixel( bf, nearbyint(xx), nearbyint(yy), rr, gg, bb, linedx ); //dest pixel
}
}
//'px,py' is 'left,top' corner
void flip_clock_wnd::draw_text_line_black( int px, int py, int rectww, int recthh, int text_offx, int text_offy, int line_black_offx, int line_black_offy, XftFont *text_font, string stext, int line_width, int rr, int gg, int bb )
{
string s1;
int col_bkgd_r = 60;
int col_bkgd_g = 60;
int col_bkgd_b = 60;
strpf( s1, "%s", stext.c_str() );
XGlyphInfo extents;
XftTextExtentsUtf8( dpy, text_font, (XftChar8 *)s1.c_str(), s1.length(), &extents );
int textww = extents.width - extents.x;
int texthh = extents.height;
set_color( col_bkgd_r, col_bkgd_g, col_bkgd_b );
draw_rectf( px, py, rectww, recthh );
//fc.draw_rectf( (unsigned char*)pixbf0->image, 0, 0, xshm_img1->width, xshm_img1->height, xshm_img1->width, 0, 0, 0 );
//return;
//set_color( 130, 130, 130 );
//line_style ( line_width, LineSolid, CapRound, JoinRound );
set_color( rr, gg, bb );
XftDrawStringUtf8( xft_draw, &xftcolor, text_font, px + text_offx, py + text_offy + texthh, (const FcChar8 *) s1.c_str(), s1.length() );
int col_line_r = 40;
int col_line_g = 40;
int col_line_b = 40;
//black line
set_color( col_line_r, col_line_g, col_line_b );
line_style ( line_width, LineSolid, CapRound, JoinRound );
draw_line( px, py + recthh/2 + line_black_offy, px + 200, py + recthh/2 + line_black_offy );
}
//'px,py' is 'left,top' corner
void flip_clock_wnd::draw_text( int px, int py, string stext, XftFont *text_font, int rr, int gg, int bb, int align )
{
int col_bkgd_r = 60;
int col_bkgd_g = 60;
int col_bkgd_b = 60;
set_color( rr, gg, bb );
string s1;
strpf( s1, "%s", stext.c_str() );
XGlyphInfo extents;
XftTextExtentsUtf8( dpy, text_font, (XftChar8 *)s1.c_str(), s1.length(), &extents );
XftDrawStringUtf8( xft_draw, &xftcolor, text_font, px, py, (const FcChar8 *) s1.c_str(), s1.length() );
}
//render text numerals offscreen
void flip_clock_wnd::render_text()
{
string s1;
int px = 0;
int py = 0;
int rectww = 200;
int recthh = 200;
int text_offx = 17;
int text_offy = 45;
int line_break_offx = 0;
int line_break_offy = 0;
//int text_font = 0;
//int text_size = 150;
int break_line_width = 4;
int rr = 220;
int gg = 220;
int bb = 220;
int disp_secs = isecs;
int disp_mins = imins;
int disp_hrs = ihrs;
//b_show_secs = 1;
//if(b_show_alarm)
// {
// disp_secs = alarm_secs[alarm_idx];
// disp_mins = alarm_mins[alarm_idx];
// disp_hrs = alarm_hrs[alarm_idx];
// }
int hrs_minus1 = disp_hrs - 1;
if (hrs_minus1 < 0 ) hrs_minus1 = 23;
int mins_minus1 = disp_mins - 1;
if (mins_minus1 < 0 ) mins_minus1 = 59;
int secs_minus1 = disp_secs - 1;
if (secs_minus1 < 0 ) secs_minus1 = 59;
hrs_minus1 = prev_hrs;
mins_minus1 = prev_mins;
secs_minus1 = prev_secs;
//----- hrs - large font
if( b_24hr ) //prev hr
{
strpf( s1, "%02d", hrs_minus1 );
if( hrs_minus1 == 0 ) s1 = "00";
}
else{
int ii = hrs_minus1;
if( ii > 12 ) ii -= 12;
if( ii < 10 )
{
strpf( s1, " %d", ii ); //single digit
}
else{
strpf( s1, "%02d", ii);
}
if( ii == 0 ) s1 = "12";
}
draw_text_line_black( px, py, rectww, recthh, text_offx, text_offy, line_break_offx, line_break_offy, font150, s1, break_line_width, rr, gg, bb );
if( b_24hr ) //cur hr
{
strpf( s1, "%02d", disp_hrs );
if( disp_hrs == 0 ) s1 = "00";
}
else{
int ii = disp_hrs;
if( ii > 12 ) ii -= 12;
if( ii < 10 )
{
strpf( s1, " %d", ii ); //single digit
}
else{
strpf( s1, "%02d", ii);
}
if( ii == 0 ) s1 = "12";
}
//draw_text_line_black( px + 250, py, 0, -4, 0, -1, font_type, font_size, s1, break_line_width, 220, 220, 220 );
draw_text_line_black( px + 250, py, rectww, recthh, text_offx, text_offy, line_break_offx, line_break_offy, font150, s1, break_line_width, rr, gg, bb );
//-----
//----- AM/PM - small font
string smeridian_old = "AM";
if( hrs_minus1 > 11 ) smeridian_old = "PM";
string smeridian_new = "AM";
if( disp_hrs > 11 ) smeridian_new = "PM";
int text_align = 0;
if( !b_24hr )
{
draw_text( px + 5, py + 190, smeridian_old, font25, rr, gg, bb, text_align ); //AM/PM indicator
draw_text( px + 250 + 5, py + 190, smeridian_new, font25, rr, gg, bb, text_align );
}
//if(b_show_alarm)draw_text( px + 250+5, py + 17, "ALARM", font_type, font_size2, 220, 220, 220, text_align );
//-----
//----- mins - large font
//if( b_show_secs ) strpf( s1, "%02d", disp_secs );
//else strpf( s1, "%02d", mins_minus1 );
strpf( s1, "%02d", mins_minus1 );
draw_text_line_black( px + 500, py, rectww, recthh, text_offx, text_offy, line_break_offx, line_break_offy, font150, s1, break_line_width, rr, gg, bb );
strpf( s1, "%02d", disp_mins );
draw_text_line_black( px + 750, py, rectww, recthh, text_offx, text_offy, line_break_offx, line_break_offy, font150, s1, break_line_width, rr, gg, bb );
//-----
//----- secs - large font
if( b_show_secs );
{
strpf( s1, "%02d", secs_minus1 );
draw_text_line_black( px + 1000, py, rectww, recthh, text_offx, text_offy, line_break_offx, line_break_offy, font150, s1, break_line_width, rr, gg, bb );
strpf( s1, "%02d", disp_secs );
draw_text_line_black( px + 1250, py, rectww, recthh, text_offx, text_offy, line_break_offx, line_break_offy, font150, s1, break_line_width, rr, gg, bb );
}
//-----
}
//render leaf flipping numerals and compose
void flip_clock_wnd::render( unsigned char *bf, int wid, int hei, int destx, int desty )
{
string s1;
int linedx = wid;
float sub_pixel_factor = 0.5f;
//theta_hrs += 0.1;
int drwx = 0;
int drwy = 0;
float drw_offset_z = 400.0f;
float drw_scle = 400.0f;
float scale_ratio = drw_scle / drw_offset_z;
st_3d_pixel_block_texture_wrap_single_axis_tag ot;
/*
int px = 0;
int py = 0;
int rectww = 200;
int recthh = 200;
int text_offx = 17;
int text_offy = 45;
int line_break_offx = 0;
int line_break_offy = 0;
int text_font = 0;
int text_size = 150;
int break_line_width = 4;
int rr = 220;
int gg = 220;
int bb = 220;
*/
/*
int disp_secs = isecs;
int disp_mins = imins;
int disp_hrs = ihrs;
b_show_secs = 1;
//if(b_show_alarm)
// {
// disp_secs = alarm_secs[alarm_idx];
// disp_mins = alarm_mins[alarm_idx];
// disp_hrs = alarm_hrs[alarm_idx];
// }
int hrs_minus1 = disp_hrs - 1;
if (hrs_minus1 < 0 ) hrs_minus1 = 23;
int mins_minus1 = disp_mins - 1;
if (mins_minus1 < 0 ) mins_minus1 = 59;
int secs_minus1 = disp_secs - 1;
if (secs_minus1 < 0 ) secs_minus1 = 59;
hrs_minus1 = prev_hrs;
mins_minus1 = prev_mins;
secs_minus1 = prev_secs;
//----- hrs - large
if( b_24hr ) //current hr
{
strpf( s1, "%02d", hrs_minus1 );
if( hrs_minus1 == 0 ) s1 = "00";
}
else{
int ii = hrs_minus1;
if( ii > 12 ) ii -= 12;
if( ii < 10 )
{
strpf( s1, " %d", ii ); //single digit
}
else{
strpf( s1, "%02d", ii);
}
if( ii == 0 ) s1 = "12";
}
s1 = "38" ;
fc.draw_text_line_black( px, py, rectww, recthh, text_offx, text_offy, line_break_offx, line_break_offy, text_font, text_size, s1, break_line_width, rr, gg, bb );
XCopyArea( dpy, double_buffer, root, gc, 0, 0, wid, hei, 0, 0);
//XCopyArea( dpy, double_buffer, root, gc, 0, 0, wid, hei, 0, 0);
//draw_text_line_black( drwx, drwy, 0, -4, 0, -1, font_type, font_size, s1, break_line_width, 220, 220, 220 );
*/
//------- hrs rotated composite large size -------
int drw_cmpst_dest_hrs_x = destx - 100;
int drw_cmpst_dest_hrs_y = desty - 200;
float theta1 = theta_hrs;
if( theta1 > 0.0f )
{
//----- back image (full)
ot.bflip_vert = 0;
ot.bf = bf;
ot.srcx = drwx + 0; //'left,top corner' pixel position to be used for texture wrapping
ot.srcy = drwy;
ot.linedx = linedx;
ot.wid = 200;
ot.hei = 200;
ot.bfdest = bf;
ot.destx = destx;
ot.desty = desty;
ot.destlinedx = linedx;
ot.rotation_axis = 0;
ot.origin3d_x = 0;
ot.origin3d_y = -ot.hei/2;
ot.origin3d_z = 0;
ot.theta = 0;
ot.offset_z = drw_offset_z;
ot.scale = drw_scle;
tw.draw_texture_rot3d_single_axis( ot, sub_pixel_factor, 0 );
if( theta1 > 0.0f )
{
//behind top half leaf (stationary - shows the next number behind)
ot.bflip_vert = 0;
ot.bf = bf;
ot.srcx = drwx+250; //'left,top corner' pixel position to be used for texture wrapping
ot.srcy = drwy;
ot.linedx = linedx;
ot.wid = 200;
ot.hei = 100 - 3;
ot.bfdest = bf;
ot.destx = destx;
ot.desty = desty - 100*scale_ratio - 1*scale_ratio;
ot.destlinedx = linedx;
ot.rotation_axis = 0;
ot.origin3d_x = 0;
ot.origin3d_y = -ot.hei/2 - 3;
ot.origin3d_z = 0;
ot.theta = 0;
ot.offset_z = drw_offset_z;
ot.scale = drw_scle;
tw.draw_texture_rot3d_single_axis( ot, sub_pixel_factor, 0 );
}
//----- rotating image
if( theta1 != 0.0f )
{
if( theta1 < pi/2 )
{
//----top of flip ----
ot.bflip_vert = 0;
ot.bf = bf;
ot.srcx = drwx; //'left,top corner' pixel position to be used for texture wrapping
ot.srcy = drwy;
ot.linedx = linedx;
ot.wid = 200;
ot.hei = 100;
ot.bfdest = bf;
ot.destx = destx;
ot.desty = desty - 100*(scale_ratio);
ot.destlinedx = linedx;
ot.rotation_axis = 0;
ot.origin3d_x = 0;
ot.origin3d_y = -ot.hei/2;
ot.origin3d_z = 0;
ot.theta = theta1;
ot.offset_z = drw_offset_z;
ot.scale = drw_scle - 0.0f;
tw.draw_texture_rot3d_single_axis( ot, sub_pixel_factor, 0 );
}
else{
//--- bottom of flip ----
ot.bflip_vert = 1;
ot.bf = bf;
ot.srcx = drwx + 250; //'left,top corner' pixel position to be used for texture wrapping
ot.srcy = drwy + 100;
ot.linedx = linedx;
ot.wid = 200;
ot.hei = 100-1;
ot.bfdest = bf;
ot.destx = destx;
ot.desty = desty - 100*(scale_ratio);
ot.destlinedx = linedx;
ot.rotation_axis = 0;
ot.origin3d_x = 0;
ot.origin3d_y = -ot.hei/2;
ot.origin3d_z = 0;
ot.theta = theta1;
ot.offset_z = drw_offset_z;
ot.scale = drw_scle;
tw.draw_texture_rot3d_single_axis( ot, sub_pixel_factor, 0 );
}
}
//-----
}
//-------
int drw_cmpst_src_offx = 500;
int drw_cmpst_src_offy = 0;
int drw_cmpst_dest_offx = 300;
int drw_cmpst_dest_offy = 0;
int drw_cmpst_dest_mins_x = destx + drw_cmpst_dest_offx - 100;
int drw_cmpst_dest_mins_y = desty + drw_cmpst_dest_offy - 200;
//------- mins rotated composite large size -------
theta1 = theta_mins;
if( theta1 > 0.0f )
{
//----- back image (full)
ot.bflip_vert = 0;
ot.bf = bf;
ot.srcx = drwx + drw_cmpst_src_offx; //'left,top corner' pixel position to be used for texture wrapping
ot.srcy = drwy + drw_cmpst_src_offy;
ot.linedx = linedx;
ot.wid = 200;
ot.hei = 200;
ot.bfdest = bf;
ot.destx = destx + drw_cmpst_dest_offx;
ot.desty = desty + drw_cmpst_dest_offy;
ot.destlinedx = linedx;
ot.rotation_axis = 0;