Skip to content

Instantly share code, notes, and snippets.

@jaymcgavren
Created May 15, 2019 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaymcgavren/68a9ac0ce3bf95df078b1109f4cfd624 to your computer and use it in GitHub Desktop.
Save jaymcgavren/68a9ac0ce3bf95df078b1109f4cfd624 to your computer and use it in GitHub Desktop.
The "orbit" sketch from ruby-processing, ported to work with Visor.
# Ported from http://nodebox.net/code/index.php/Graphics_State
# This sketch demonstrates how to use the frame rate as orbital state,
# as well as how to use system fonts in Ruby-Processing.
attr_reader :d_font
smooth
@d_font = create_font('Helvetica', 40, false, ('a'..'z').to_a)
# Note: Colors inverted from original to ease layer blending.
stroke 255
fill 255
def draw
background 0
translate 225, 225
text_font d_font
ellipse 0, 0, 10, 10
text 'sun', 10, 0
3.times do |i|
push_matrix
rotate frame_count / -180.0 * PI + i * PI / -1.5
line 0, 0, 120, 0
translate 120, 0
ellipse 0, 0, 10, 10
text_font d_font, 22
text 'planet', 10, 0
rotate frame_count / -30.0 * PI
line 0, 0, 30, 0
text_font d_font, 15
text 'moon', 32, 0
pop_matrix
end
end
# The MIT License (MIT)
#
# Copyright (c) 2019 Jay McGavren
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment