소스 검색

draw circle outline

Karl Zylinski 6 달 전
부모
커밋
d27a7d9c67
3개의 변경된 파일16개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      README.md
  2. 2 0
      karl2d.doc.odin
  3. 11 0
      karl2d.odin

+ 3 - 0
README.md

@@ -16,6 +16,7 @@ Might not be included:
 
 Here follows my near-future TODO list
 
+* bunnymark
 * should gamepad come from separate interface than window?
 	* keyboard input could also come from some input interface, but
 	  it is tightly bound to window in windows, so we'll see.
@@ -34,6 +35,8 @@ Here follows my near-future TODO list
 * Textures: Make the sampler state configurable
 * Textures D3D11: Do we need the SRV in the texture?
 * Shaders: Reflect and expose samplers
+* mipmap support
+* set filtering: for scaling up, down and mipmap
 
 ## DONE
 * win32: Resizable window

+ 2 - 0
karl2d.doc.odin

@@ -123,6 +123,8 @@ draw_rect_outline :: proc(r: Rect, thickness: f32, color: Color)
 
 draw_circle :: proc(center: Vec2, radius: f32, color: Color, segments := 16)
 
+draw_circle_outline :: proc(center: Vec2, radius: f32, thickness: f32, color: Color, segments := 16)
+
 draw_line :: proc(start: Vec2, end: Vec2, thickness: f32, color: Color)
 
 draw_texture :: proc(tex: Texture, pos: Vec2, tint := WHITE)

+ 11 - 0
karl2d.odin

@@ -438,6 +438,17 @@ draw_circle :: proc(center: Vec2, radius: f32, color: Color, segments := 16) {
 	}
 }
 
+draw_circle_outline :: proc(center: Vec2, radius: f32, thickness: f32, color: Color, segments := 16) {
+	prev := center + {radius, 0}
+	for s in 1..=segments {
+		sr := (f32(s)/f32(segments)) * 2*math.PI
+		rot := linalg.matrix2_rotate(sr)
+		p := center + rot * Vec2{radius, 0}
+		draw_line(prev, p, thickness, color)
+		prev = p
+	}
+}
+
 draw_line :: proc(start: Vec2, end: Vec2, thickness: f32, color: Color) {
 	p := Vec2{start.x, start.y + thickness*0.5}
 	s := Vec2{linalg.length(end - start), thickness}