-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #421 from scarpe-team/schwad_oval_nation
let us just all have one big oval party but only invite our best friends and not post on social media about it so no one ever knows it happened
- Loading branch information
Showing
11 changed files
with
132 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Shoes.app do | ||
oval top: 20, left: 20, radius: 160, center: true, fill: fuchsia | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
#TODO: Support color methods as argument | ||
#TODO: Allow strokewidth to go wider than container? | ||
#TODO: Support strokewidth draw context | ||
|
||
Shoes.app( | ||
title: "Schwad's unbelievable desktop application that renders an oval", | ||
height: 700, | ||
) do | ||
flow do | ||
para "Positional arguments:" | ||
oval 30, 30, 80, 200, center: true | ||
end | ||
flow do | ||
para "As a circle" | ||
stroke "blue" | ||
fill "pink" | ||
oval 30, 30, 80, center: true | ||
end | ||
flow do | ||
para "Keyword arguments:" | ||
fill "green" | ||
oval top: 20, left: 20, height: 160, width: 90, center: true, stroke: "red", strokewidth: 4 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
Shoes.app do | ||
star 230, 100, 6, 50, 25 | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
class Shoes | ||
# Docs: https://github.com/scarpe-team/scarpe/blob/main/docs/static/manual.md#ovalleft-top-radius--shoesshape | ||
class Oval < Shoes::Drawable | ||
shoes_styles :height, :center, :draw_context, :stroke | ||
|
||
shoes_style(:left) { |val| convert_to_integer(val, "left") } | ||
shoes_style(:top) { |val| convert_to_integer(val, "top") } | ||
shoes_style(:radius) { |val| convert_to_integer(val, "radius") } | ||
shoes_style(:height) { |val| convert_to_integer(val, "height") } | ||
shoes_style(:width) { |val| convert_to_integer(val, "width") } | ||
shoes_style(:strokewidth) { |val| convert_to_integer(val, "strokewidth") } | ||
|
||
def initialize(left = nil, top = nil, radius = nil, height = nil, **options) | ||
super | ||
self.left, self.top, self.radius, self.height = | ||
left || options[:left], | ||
top || options[:top], | ||
radius || options[:radius] || options[:width] / 2, # The radius positional arg change forces us to do this | ||
height || options[:height] | ||
|
||
@draw_context = Shoes::App.instance.current_draw_context | ||
|
||
create_display_drawable | ||
end | ||
|
||
def self.convert_to_integer(value, attribute_name) | ||
begin | ||
value = Integer(value) | ||
raise InvalidAttributeValueError, "Negative num '#{value}' not allowed for attribute '#{attribute_name}'" if value < 0 | ||
|
||
value | ||
rescue ArgumentError | ||
error_message = "Invalid value '#{value}' provided for attribute '#{attribute_name}'. The value should be a number." | ||
raise InvalidAttributeValueError, error_message | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module Scarpe::Webview | ||
class Oval < Drawable | ||
def initialize(properties) | ||
super(properties) | ||
end | ||
|
||
def element(&block) | ||
render("oval", &block) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters