Advertisement
thebys

Leženka OpenScad v2

Oct 26th, 2020 (edited)
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.96 KB | None | 0 0
  1. include<A2D.scad>;
  2. //import("logo-charita.svg");
  3.  
  4. qr_data = [ [ 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1 ],
  5.             [ 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1 ],
  6.             [ 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1 ],
  7.             [ 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ],
  8.             [ 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ],
  9.             [ 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1 ],
  10.             [ 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1 ],
  11.             [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 ],
  12.             [ 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1 ],
  13.             [ 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0 ],
  14.             [ 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1 ],
  15.             [ 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0 ],
  16.             [ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0 ],
  17.             [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0 ],
  18.             [ 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0 ],
  19.             [ 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1 ],
  20.             [ 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1 ],
  21.             [ 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0 ],
  22.             [ 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1 ],
  23.             [ 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1 ],
  24.             [ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 ] ];
  25.  
  26. qr_module_size = 1.8;
  27. qr_height = 0.2;
  28.  
  29. mark_border = 3;
  30. mark_size = (21 * qr_module_size) + (2 * mark_border);
  31. mark_height = 1.6;
  32.  
  33. mark_text_line_height = 14;
  34. title = "Hradecká";
  35. title_font_size = 5.6;
  36.  
  37. cena_text = "40 Kč";
  38. cena_font_size = 5;
  39. cena_spacing = 0.9;
  40.  
  41. mark_bottom_line_height = 5;
  42. subtitle = "Leženka";
  43. bottom_font_size = 4.2;
  44. bottom_spacing = 0.95;
  45. bottom = "poukaz na nocleh";
  46.  
  47. vodoznak_height = 0.6;
  48.  
  49. main();
  50.  
  51. module main()
  52. {
  53.     //marka
  54.     difference()
  55.     {
  56.         union()
  57.         {
  58.             //marka
  59.             translate([ 0, 0 ])
  60.             {
  61.                 color("#FF8844") linear_extrude(mark_height) make_round(ro = 5) square([ mark_size, mark_size + mark_text_line_height + mark_bottom_line_height ]);
  62.             }
  63.             //Poutko
  64.             translate([ mark_size / 2, mark_size + mark_bottom_line_height + mark_text_line_height, 0 ])
  65.             {
  66.                 color("#FF8844") linear_extrude(mark_height) circle(5, $fn = 128);
  67.             }
  68.         }
  69.         //vodoznak charity
  70.         translate([ mark_border + 1, mark_border, 0.4 ])
  71.         {
  72.             linear_extrude(height = vodoznak_height)
  73.             {
  74.                 color("#FF0000")
  75.                     scale(1.0)
  76.                         import("logo-charita.svg");
  77.             }
  78.         }
  79.         //díra v poutku
  80.         translate([ mark_size / 2, mark_size + mark_bottom_line_height + mark_text_line_height, -0.1 ])
  81.         {
  82.             color("#FF0000") linear_extrude(mark_height + 1) circle(2.8, $fn = 128);
  83.         }
  84.     }
  85.     //Nadpis a podnadpis a cena
  86.     translate([ mark_border, mark_size + mark_text_line_height - mark_border, mark_height ])
  87.     {
  88.         //Nadpis
  89.         color("#000000") linear_extrude(qr_height) text(title, size = title_font_size, font = "impact");
  90.         //Podnadpis
  91.         translate([ 0, (title_font_size + mark_border / 2) * -1, 0 ])
  92.         {
  93.             color("#000000") linear_extrude(qr_height) text(subtitle, size = title_font_size, font = "impact");
  94.         }
  95.         //Cena
  96.         rotate(90){
  97.             translate([ (title_font_size+2) *-1, (mark_size - cena_font_size - (mark_border/2)) *-1, 0 ])
  98.             {
  99.                 color("#000000") linear_extrude(qr_height) text(cena_text, size = cena_font_size, spacing=cena_spacing, font = "impact");
  100.             }}
  101.     }
  102.     //Dolní text
  103.     translate([ mark_border - 0.5, mark_border - 1, mark_height ])
  104.     {
  105.         color("#000000") linear_extrude(qr_height) text(bottom, size = bottom_font_size, font = "impact", spacing = bottom_spacing);
  106.     }
  107.     //QR Kod
  108.     translate([ mark_border, mark_border + mark_bottom_line_height, mark_height ])
  109.     {
  110.         color("#000000") qr_render(qr_data);
  111.     }
  112. }
  113. // QR code rendering method
  114. module qr_render(data, module_size = qr_module_size, height = qr_height)
  115. {
  116.     maxmod = len(data) - 1;
  117.     union()
  118.     {
  119.         for (r = [0:maxmod])
  120.         {
  121.             for (c = [0:maxmod])
  122.             {
  123.                 if (data[r][c] == 1)
  124.                 {
  125.                     xo = c * module_size;
  126.                     yo = (maxmod - r) * module_size;
  127.                     translate([ xo, yo, 0 ]) cube([ module_size, module_size, height ]);
  128.                 }
  129.             }
  130.         }
  131.     }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement