1. cheery
  2. vectorboobs

Commits

cheery  committed 5260e64

wireframe, on/off contour click

  • Participants
  • Parent commits 852c661
  • Branches default

Comments (0)

Files changed (5)

File color.py

View file
  • Ignore whitespace
 colors = dict(
     outline = (0.0, 0.0, 0.0),
     background = (0.0, 0.0, 0.16363636363636339),
-    on_contour = (0.5, 0.5, 0.5),
+    on_contour = (0.0, 0.35499999999999959, 0.27909090909090911),
     fill = (0.22727272727272721, 0.72727272727272751, 0.67045454545454575),
     contour = (0.5, 0.0, 0.24999999999999997),
     off_contour = (0.49999999999999978, 0.26136363636363619, 0.26136363636363658),
     vertex_hilight = (0.57954545454545436, 0.75000000000000022, 0.88636363636363646),
+    wireframe = (0.0, 0.0, 0.0),
 )
 
 class ColorBox(Canvas):

File editor.py

View file
  • Ignore whitespace
 from shape import Contour, Shape
 from pyglet.gl import *
 from math import cos, sin, pi
-from halogen import Workspace, Column, Row, Label, Widget, Slider, Input, Button, Area, here
+from halogen import Workspace, Column, Row, Label, Widget, Slider, Input, Button, Area, Checkbox, here
 from halogen.scrollable import Scrollable
 from colorsys import hsv_to_rgb
 from panel import Panel
     def __exit__(self, type, value, traceback):
         glPopAttrib()
 
+class PolygonMode(object):
+    def __init__(self, face, mode):
+        self.face = face
+        self.mode = mode
+    def __enter__(self):
+        glPushAttrib(GL_POLYGON_BIT)
+        glPolygonMode(self.face, self.mode)
+    def __exit__(self, type, value, traceback):
+        glPopAttrib()
+
 class Screen(object):
     def __init__(self, rect):
         self.rect = rect
         glPopAttrib()
 
 class View(Area):
+    debug_tesselation = False
     def __init__(self):
         Area.__init__(self)
         self.xoff = 0
         if button & 4:
             self.mousepos = x, y
             self.root.window.set_exclusive_mouse(True)
+        if button & 2 and self.pick:
+            contour, index = self.pick
+            contour.on_contour[index] = not contour.on_contour[index]
+            shape.refresh()
+
         self.root.window.push_handlers(
             on_mouse_release = self.on_mouse_release,
             on_mouse_drag = self.on_mouse_drag,
                 count = len(shape.triangles)/2
                 pyglet.graphics.draw(count, GL_TRIANGLES, ('v2f', shape.triangles))
 
+            if self.debug_tesselation:
+                set_color('wireframe')
+                with PolygonMode(GL_FRONT, GL_LINE):
+                    count = len(shape.triangles)/2
+                    pyglet.graphics.draw(count, GL_TRIANGLES, ('v2f', shape.triangles))
+
             if shape.outline:
                 set_color('outline')
                 glLineWidth(2.0)
 
 colortheme_panel().append_to(sidepanel)
 
+vis = Column()
+row = Row().append_to(vis)
+Label("wireframe").append_to(row)
+toggle_wireframe = Checkbox(view.debug_tesselation)
+toggle_wireframe.append_to(row)
+@toggle_wireframe.event
+def on_change(state):
+    view.debug_tesselation = state
+Panel("visualization", vis, removable=False).append_to(sidepanel)
+
 show_outline = True
 is_editable = True
 

File style/demo.hss

View file
  • Ignore whitespace
 
 #sidepanel > Column{
     width: 195px;
+    spacing: 0px;
 }
 
 Panel > Bar > Button{
     height: 100%;
     right: 0px;
 }
+
+Checkbox{
+    background: file(images/checkbox_off.png) image;
+    width: 27px;
+    height: 13px;
+}
+
+Checkbox:on{
+    background: file(images/checkbox_on.png) image;
+}

File style/images/checkbox_off.png

  • Ignore whitespace
Old
Old image
New
New image

File style/images/checkbox_on.png

  • Ignore whitespace
Old
Old image
New
New image