Răsfoiți Sursa

draw circle outline

Karl Zylinski 6 luni în urmă
părinte
comite
d27a7d9c67
3 a modificat fișierele cu 16 adăugiri și 0 ștergeri
  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
 Here follows my near-future TODO list
 
 
+* bunnymark
 * should gamepad come from separate interface than window?
 * should gamepad come from separate interface than window?
 	* keyboard input could also come from some input interface, but
 	* keyboard input could also come from some input interface, but
 	  it is tightly bound to window in windows, so we'll see.
 	  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: Make the sampler state configurable
 * Textures D3D11: Do we need the SRV in the texture?
 * Textures D3D11: Do we need the SRV in the texture?
 * Shaders: Reflect and expose samplers
 * Shaders: Reflect and expose samplers
+* mipmap support
+* set filtering: for scaling up, down and mipmap
 
 
 ## DONE
 ## DONE
 * win32: Resizable window
 * 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 :: 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_line :: proc(start: Vec2, end: Vec2, thickness: f32, color: Color)
 
 
 draw_texture :: proc(tex: Texture, pos: Vec2, tint := WHITE)
 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) {
 draw_line :: proc(start: Vec2, end: Vec2, thickness: f32, color: Color) {
 	p := Vec2{start.x, start.y + thickness*0.5}
 	p := Vec2{start.x, start.y + thickness*0.5}
 	s := Vec2{linalg.length(end - start), thickness}
 	s := Vec2{linalg.length(end - start), thickness}