{"id":2189,"date":"2021-10-09T08:04:36","date_gmt":"2021-10-08T23:04:36","guid":{"rendered":"https:\/\/sirius10.net\/blog\/wordpress\/?p=2189"},"modified":"2021-10-09T08:04:38","modified_gmt":"2021-10-08T23:04:38","slug":"post-2189","status":"publish","type":"post","link":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/2021\/10\/09\/2189\/","title":{"rendered":"SDL2 \u3067\u5857\u308a\u3064\u3076\u3057\u305f\u6955\u5186\u306e\u56de\u8ee2"},"content":{"rendered":"\n<p>\u3000\u5857\u308a\u3064\u3076\u3057\u305f\u6955\u5186\u306f\u3001\u56de\u8ee2\u3055\u305b\u306a\u3051\u308c\u3070\u3001\u5186\u306e\u5857\u308a\u3064\u3076\u3057\u3068\u540c\u69d8\u306b\u63cf\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted file\">void fill_oval(SDL_Renderer *renderer, int sx, int sy, int a, int b, int angle) {\n    SDL_Point p1, p2;\n    int x, y;\n\n    for( x = -a; x &lt;= a; x++ ) {\n        y = sqrt(1.0 - (double)(x*x)\/(a*a))*b +0.5;\n        p1.x = x, p1.y = y;\n        rotate(&amp;p1, angle);\n        p2.x = x, p2.y = -y;\n        rotate(&amp;p2, angle);\n        SDL_RenderDrawLine(renderer, sx + p1.x, sy - p1.y, sx + p2.x, sy - p2.y);\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/fill_oval0.png\" alt=\"\" class=\"wp-image-2190\" srcset=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/fill_oval0.png 320w, https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/fill_oval0-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><figcaption>\u5857\u308a\u3064\u3076\u3057\u305f\u6955\u5186<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u3068\u3053\u308d\u304c\u3001\u56de\u8ee2\u3055\u305b\u308b\u3068\u3001\u3046\u307e\u304f\u5857\u308a\u3064\u3076\u305b\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/fill_oval45.png\" alt=\"\" class=\"wp-image-2191\" srcset=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/fill_oval45.png 320w, https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/fill_oval45-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><figcaption>\u5857\u308a\u3064\u3076\u3057\u305f\u6955\u5186\u3092\u300145 \u5ea6\u56de\u8ee2\u3055\u305b\u308b<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u5225\u306a\u8003\u3048\u65b9\u3067\u5857\u308a\u3064\u3076\u3057\u307e\u3059\u3002\u6955\u5186\u306e\u65b9\u7a0b\u5f0f\u306f\u4ee5\u4e0b\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"138\" height=\"60\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/oval.png\" alt=\"\" class=\"wp-image-2162\"\/><figcaption>\u6955\u5186\u306e\u65b9\u7a0b\u5f0f<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u3042\u308b\u70b9\u304c\u3001\u3053\u306e\u6955\u5186\u306e\u4e2d\u306b\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u65ad\u3057\u3001\u6955\u5186\u306e\u4e2d\u306b\u3042\u308c\u3070\u70b9\u3092\u63cf\u753b\u3057\u3001\u7121\u3051\u308c\u3070\u63cf\u753b\u3057\u306a\u3044\u3002\u3068\u3044\u3046\u624b\u9806\u3067\u5857\u308a\u3064\u3076\u3057\u3092\u884c\u3044\u307e\u3059\u3002(x, y) \u304c\u6955\u5186\u5185\u306b\u3042\u308b\u304b\u3069\u3046\u304b\u306f\u3001\u6b21\u306e\u5f0f\u3067\u5224\u65ad\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"138\" height=\"60\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/fill_oval.png\" alt=\"\" class=\"wp-image-2195\"\/><figcaption>\u6955\u5186\u5185\u304b\u3069\u3046\u304b\u306e\u6761\u4ef6<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u4e0a\u8a18\u306e\u5f0f\u3092\u3061\u3087\u3063\u3068\u5909\u5f62\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"33\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/fill_oval2.png\" alt=\"\" class=\"wp-image-2196\"\/><figcaption>\u6955\u5186\u5185\u304b\u3069\u3046\u304b\u306e\u6761\u4ef6<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u3053\u308c\u3092\u4f7f\u3044\u3001\u6955\u5186\u3092\u5857\u308a\u3064\u3076\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted file\">void fill_oval(SDL_Renderer *renderer, int cx, int cy, int a, int b) \n{\n    int x, y, result, out;\n\n    out = a*a * b*b;\n\n    for( x = -a; x &lt;= a; x++ ) {\n        for( y = -b; y &lt;= b; y++ ) {\n            result = (x * x)*(b * b) + (y * y)*(a * a);\n            if( result &lt;= out ) {\n                SDL_RenderDrawPoint(renderer, cx + x, cy - y);\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/sfill_oval0.png\" alt=\"\" class=\"wp-image-2193\" srcset=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/sfill_oval0.png 320w, https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/sfill_oval0-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><figcaption>\u5857\u308a\u3064\u3076\u3057\u305f\u6955\u5186<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u3053\u308c\u3092\u56de\u8ee2\u51fa\u6765\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u8003\u3048\u65b9\u3068\u3057\u3066\u306f\u3001\u6955\u5186\u3092\u542b\u3080\u77e9\u5f62\u3092\u56de\u8ee2\u3055\u305b\u3001\u8abf\u3079\u308b\u9818\u57df\u3092\u6c42\u3081\u3001\u5404\u70b9\u3092\u8abf\u3079\u308b\u3068\u304d\u306b\u3001\u9006\u306b\u56de\u8ee2\u3055\u305b\u3001\u8abf\u3079\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted file\">void rotate(SDL_Point *pt, int angle) {\n    int x, y;\n    double r;\n\n    x = pt-&gt;x, y = pt-&gt;y;\n    r = M_PI * angle \/ 180.;\n\n    pt-&gt;x = x * cos(r) - y * sin(r);\n    pt-&gt;y = x * sin(r) + y * cos(r);\n}\n\nvoid min_max(SDL_Point *p, SDL_Point *min, SDL_Point *max, int angle) {\n    rotate(p, angle);\n    min-&gt;x = min-&gt;x &gt; p-&gt;x ? p-&gt;x : min-&gt;x;\n    min-&gt;y = min-&gt;y &gt; p-&gt;y ? p-&gt;y : min-&gt;y;\n    max-&gt;x = max-&gt;x &lt; p-&gt;x ? p-&gt;x : max-&gt;x;\n    max-&gt;y = max-&gt;y &lt; p-&gt;y ? p-&gt;y : max-&gt;y;\n}\n\nvoid fill_oval(SDL_Renderer *renderer, int cx, int cy, int a, int b, int angle) {\n    int x, y, result, out;\n    SDL_Point p, min, max;\n\n    \/* \u56de\u8ee2\u5f8c\u306e\u63cf\u753b\u7bc4\u56f2\u3092\u6c42\u3081\u308b *\/\n    min.x = max.x = 0;\n    min.y = max.y = 0;\n    p.x = -a, p.y = -b;\n    min_max(&amp;p, &amp;min, &amp;max, angle);\n    p.x = -a, p.y = b;\n    min_max(&amp;p, &amp;min, &amp;max, angle);\n    p.x = a, p.y = b;\n    min_max(&amp;p, &amp;min, &amp;max, angle);\n    p.x = a, p.y = -b;\n    min_max(&amp;p, &amp;min, &amp;max, angle);\n\n    out = a*a * b*b;\n    for( x = min.x; x &lt;= max.x; x++ ) {\n        for( y = min.y; y &lt;= max.y; y++ ) {\n            p.x = x, p.y = y;\n            rotate(&amp;p, -angle);\n            result = (p.x * p.x)*(b * b) + (p.y * p.y)*(a * a);\n            if( result &lt;= out ) {\n                SDL_RenderDrawPoint(renderer, cx + x, cy - y);\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/sfill_oval45.png\" alt=\"\" class=\"wp-image-2194\" srcset=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/sfill_oval45.png 320w, https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/sfill_oval45-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><figcaption>\u5857\u308a\u3064\u3076\u3057\u305f\u6955\u5186\u3092\u300145 \u5ea6\u56de\u8ee2\u3055\u305b\u308b<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u3053\u308c\u3067\u5857\u308a\u3064\u3076\u3057\u304c\u304a\u304b\u3057\u304f\u306a\u308b\u3053\u3068\u306f\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002\u5857\u308a\u3064\u3076\u3057\u306e\u6642\u306f\u3001\u3053\u306e\u65b9\u6cd5\u3092\u4f7f\u3063\u305f\u307b\u3046\u304c\u3044\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u5857\u308a\u3064\u3076\u3057\u305f\u6955\u5186\u306f\u3001\u56de\u8ee2\u3055\u305b\u306a\u3051\u308c\u3070\u3001\u5186\u306e\u5857\u308a\u3064\u3076\u3057\u3068\u540c\u69d8\u306b\u63cf\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 void fill_oval(SDL_Renderer *renderer, int sx, int sy, int a, int b, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-2189","post","type-post","status-publish","format-standard","hentry","category-sdl2"],"_links":{"self":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=2189"}],"version-history":[{"count":4,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2189\/revisions"}],"predecessor-version":[{"id":2205,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2189\/revisions\/2205"}],"wp:attachment":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=2189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=2189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=2189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}